An excellent usage of FIELD-SYMBOL
2007-10-04 19:49
363 查看
Simply,we can use field symbol to identify a specify memory area. Below is the example.
There is a requirement about the enhancement of account document that generated after saving MIRO.The user want to write invice party(Vendor) to the account document item text. Which item-buzid equal 'T' which indicate taxing.
I found the BADI:AC_DOCUMENT to implement this requirement.The method is CHANGE_INITIAL.The exporting parameter of this method is EX_DOCUMENT ,data type is ACC_DOCUMENT_SUBST.So i must use importing parameter IM_DOCUMENT to construct EX_DOCUMENT.But very unluckily,the field PRZNR of ex_document-item-prznr is RAW. And the value will always be '0000'. After executing this BADI ,the field value of prznr of internal table t_accit[] of calling program is also set to '0000'.The MIRO throw an error message about the definition of BUSSINESS PROCESS.After several hours study i found that the field symbol can achieve my requirement by pass the exporting parameter EX_DOCUMENT.
The method CHANGE_INITIAL OF BADI AC_DOCUMENT is called in FM:AC_DOCMENT_CREATE.
The FM: AC_DOCUMENT_CREATE is called in FM:MRM_INVOICE_POST.
AND the FM: MRM_INVOICE_POST is called in MIRO when SAVING.
The TABLES parameter T_ACCIT of FM:AC_DOCUMENT_CREATE contain the line items of account document. And this table is transfered from MRM_INVOICE_POST. The correspond global data is XACCIT in program SAPLMRMP.So we can use field symbol to access data XACCIT in program SAPLMRMP.Below is the code.
method IF_EX_AC_DOCUMENT~CHANGE_INITIAL.
DATA: l_v_lifnr TYPE LIFNR.
CHECK SY-TCODE EQ 'MIRO'.
FIELD-SYMBOLS <ft> TYPE ACCIT_T.
FIELD-SYMBOLS <fs> TYPE ACCIT.
DATA: field TYPE CHAR18 VALUE '(SAPLMRMP)xaccit[]'.
ASSIGN (field) TO <ft>.
CHECK SY-SUBRC EQ 0.
LOOP AT <fT> ASSIGNING <fs>.
IF SY-TABIX EQ 1.
l_v_lifnr = <fs>-lifnr.
ENDIF.
CHECK <fs>-buzid EQ 'T'.
<fs>-sgtxt = l_v_lifnr.
ENDLOOP.
endmethod.
I think this usage of field-symbol is very useful in enhancement.But before using this way to change data , we must check the consistency of the data.
There is a requirement about the enhancement of account document that generated after saving MIRO.The user want to write invice party(Vendor) to the account document item text. Which item-buzid equal 'T' which indicate taxing.
I found the BADI:AC_DOCUMENT to implement this requirement.The method is CHANGE_INITIAL.The exporting parameter of this method is EX_DOCUMENT ,data type is ACC_DOCUMENT_SUBST.So i must use importing parameter IM_DOCUMENT to construct EX_DOCUMENT.But very unluckily,the field PRZNR of ex_document-item-prznr is RAW. And the value will always be '0000'. After executing this BADI ,the field value of prznr of internal table t_accit[] of calling program is also set to '0000'.The MIRO throw an error message about the definition of BUSSINESS PROCESS.After several hours study i found that the field symbol can achieve my requirement by pass the exporting parameter EX_DOCUMENT.
The method CHANGE_INITIAL OF BADI AC_DOCUMENT is called in FM:AC_DOCMENT_CREATE.
The FM: AC_DOCUMENT_CREATE is called in FM:MRM_INVOICE_POST.
AND the FM: MRM_INVOICE_POST is called in MIRO when SAVING.
The TABLES parameter T_ACCIT of FM:AC_DOCUMENT_CREATE contain the line items of account document. And this table is transfered from MRM_INVOICE_POST. The correspond global data is XACCIT in program SAPLMRMP.So we can use field symbol to access data XACCIT in program SAPLMRMP.Below is the code.
method IF_EX_AC_DOCUMENT~CHANGE_INITIAL.
DATA: l_v_lifnr TYPE LIFNR.
CHECK SY-TCODE EQ 'MIRO'.
FIELD-SYMBOLS <ft> TYPE ACCIT_T.
FIELD-SYMBOLS <fs> TYPE ACCIT.
DATA: field TYPE CHAR18 VALUE '(SAPLMRMP)xaccit[]'.
ASSIGN (field) TO <ft>.
CHECK SY-SUBRC EQ 0.
LOOP AT <fT> ASSIGNING <fs>.
IF SY-TABIX EQ 1.
l_v_lifnr = <fs>-lifnr.
ENDIF.
CHECK <fs>-buzid EQ 'T'.
<fs>-sgtxt = l_v_lifnr.
ENDLOOP.
endmethod.
I think this usage of field-symbol is very useful in enhancement.But before using this way to change data , we must check the consistency of the data.
相关文章推荐
- AN APPROACH OF VECTOR FIELD TEXTURE VISUALIZATION BASED ON FIELD DRIVEN STRENGTH算法实现
- Innovation is An Eternal Topic of the Mill Field
- Here's an example that shows how to enumerate through the features of a selection set, returning the value of each field in the attribute table except for the geometry colum.
- An example of MFC ( help myself with beginning in this field )
- an excellent capability of C# language and compiler
- Quota Project: An effective way to manage the usage of your Swift-based storage cloud
- storm错误:msg:Field drpc.servers must be an Iterable of java.lang.String
- An excellent online source of C++ standard library
- An example usage of an encryption algorithm (AES, in this case) is:
- 模块不能插入的问题解决 disagrees about version of symbol struct_module
- Adding a custom method in an ADF BC Service Interface – update of a single attribute in a selected r
- Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity
- Why is the size of an empty class not zero?
- An A-Z Index of the Apple OS X command line
- leetcode Reverse digits of an integer
- 伪代码的使用 Usage of Pseudocode
- Use of @OneToMany or @ManyToMany targeting an unmapped class
- git push failed Because the Fault of insufficient permission for adding an object
- This text field does not specify an inputType or a hint
- POJ-3358-Period of an Infinite Binary Expansion 解题报告