Auto-create variable names for Function Module/Method Call

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,

  1. Go to transaction code SE38
  2. Choose Menu->Utilities->Settings
  3. Choose Tab, ABAP Editor
  4. Navigate to the tab Pattern
  5. 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.

Technology professional with over 15 years of experience in leading business transformation initiatives. With a passion for technology and business, specialize in applying innovations in consumer technology to address the business needs.

About the author

Ramprasad Burugu
Ramprasad Burugu

Technology professional with over 15 years of experience in leading business transformation initiatives. With a passion for technology and business, specialize in applying innovations in consumer technology to address the business needs.

Add comment

Ramprasad Burugu By Ramprasad Burugu
Welcome to Miracle's Blog

Our blog is a great stop for people who are looking for enterprise solutions with technologies and services that we provide. Over the years Miracle has prided itself for our continuous efforts to help our customers adopt the latest technology. This blog is a diary of our stories, knowledge and thoughts on the future of digital organizations.


For contacting Miracle’s Blog Team for becoming an author, requesting content (or) anything else please feel free to reach out to us at blog@miraclesoft.com.

Who we are?

Miracle Software Systems, a Global Systems Integrator and Minority Owned Business, has been at the cutting edge of technology for over 24 years. Our teams have helped organizations use technology to improve business efficiency, drive new business models and optimize overall IT.

Recent Posts