When you are making a Function Module call or a Method call from your program, it is required to declare the variables matching with the interface of the function module. The variables have to be of the same type of import/export parameters to avoid a mismatch short dump.
Traditionally, one has to navigate to SE37, copy the declaration type and use it in the program. This approach is fine for function modules with simple parameters, but it would get too boring for a Function Module that is loaded with a large number of parameters, especially standard BAPIs.
SAP has introduced a very nice feature in the latest Netweaver versions, that automatically declares the variables with the respective types. This has been there for a while but I have seen very few developers that are aware of this feature.
For example, see below auto-code generation for a call to “BAPI_GOODSMVT_CREATE“.
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } *DATA GOODSMVT_HEADER TYPE BAPI2017_GM_HEAD_01. *DATA GOODSMVT_CODE TYPE BAPI2017_GM_CODE. *DATA TESTRUN TYPE BAPI2017_GM_GEN-TESTRUN. *DATA GOODSMVT_REF_EWM TYPE /SPE/BAPI2017_GM_REF_EWM. *DATA GOODSMVT_HEADRET TYPE BAPI2017_GM_HEAD_RET. *DATA MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC. *DATA MATDOCUMENTYEAR TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR. *DATA GOODSMVT_ITEM TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE. *DATA GOODSMVT_SERIALNUMBER TYPE STANDARD TABLE OF BAPI2017_GM_SERIALNUMBER. *DATA RETURN TYPE STANDARD TABLE OF BAPIRET2. *DATA GOODSMVT_SERV_PART_DATA TYPE /SPE/BAPI2017_SERVICEPART_DATA. *DATA EXTENSIONIN TYPE STANDARD TABLE OF BAPIPAREX. CALL FUNCTION 'BAPI_GOODSMVT_CREATE' EXPORTING goodsmvt_header = goodsmvt_header goodsmvt_code = goodsmvt_code * TESTRUN = ' ' * GOODSMVT_REF_EWM = GOODSMVT_REF_EWM * IMPORTING * GOODSMVT_HEADRET = GOODSMVT_HEADRET * MATERIALDOCUMENT = MATERIALDOCUMENT * MATDOCUMENTYEAR = MATDOCUMENTYEAR TABLES goodsmvt_item = goodsmvt_item * GOODSMVT_SERIALNUMBER = GOODSMVT_SERIALNUMBER return = return * GOODSMVT_SERV_PART_DATA = GOODSMVT_SERV_PART_DATA * EXTENSIONIN = EXTENSIONIN
How to turn on this feature?
This option can be turned on in the user-specific settings of ABAP editor. Below are the step-by-step instructions,
- Go to transaction code SE38
- Choose Menu->Utilities->Settings
- Choose Tab, ABAP Editor
- Navigate to the tab Pattern
- Here you will find multiple options for code-generation, enable “Name of Actual Parameters same as Formal Parameter”
After this feature is turned-on, anytime you add a Function Module by a pattern, the variables names are automatically declared with the respective types.
Thanks Ram,
It was nice option to make use of :).
Looking forward for more suggations.
Thanks for valuable tip Ram,
It should be used by all the ABAPer for better understanding of variables.