Monday, October 23, 2017

Function Module auto-generate variable names



It is known fact that you have the Pattern button in SE38 to generate code to call a function module. But do you know that the system can automatically generate the variable names for the parameters of the function modules?

This is very useful when you want to standard BAPIs which have hundreds of variable names.


How to turn on this setting?

In SE38, goto menu Utilities->ABAP Editor->Pattern

Turn on the checkbox for "Name of Actual Parameters Same as Formal parameter"







And next time when you use the Pattern to call a function module, you will see corresponding variable names auto-created by the system.


For example see below

-----------------------------------------------------------------------
*DATA PRHEADER               TYPE BAPIMEREQHEADER.
*DATA PRHEADERX              TYPE BAPIMEREQHEADERX.
*DATA TESTRUN                TYPE BAPIFLAG-BAPIFLAG.
*DATA NUMBER                 TYPE BAPIMEREQHEADER-PREQ_NO.
*DATA PRHEADEREXP            TYPE BAPIMEREQHEADER.
*DATA RETURN                 TYPE STANDARD TABLE OF BAPIRET2.
*DATA PRITEM                 TYPE STANDARD TABLE OF BAPIMEREQITEMIMP.
*DATA PRITEMX                TYPE STANDARD TABLE OF BAPIMEREQITEMX.
*DATA PRITEMEXP              TYPE STANDARD TABLE OF BAPIMEREQITEM.
*DATA PRITEMSOURCE           TYPE STANDARD TABLE OF BAPIMEREQSOURCE.
*DATA PRACCOUNT              TYPE STANDARD TABLE OF BAPIMEREQACCOUNT.
*DATA PRACCOUNTPROITSEGMENT  TYPE STANDARD TABLE OF BAPIMEREQACCOUNTPROFITSEG.
*DATA PRACCOUNTX             TYPE STANDARD TABLE OF BAPIMEREQACCOUNTX.
*DATA PRADDRDELIVERY         TYPE STANDARD TABLE OF BAPIMERQADDRDELIVERY.
*DATA PRITEMTEXT             TYPE STANDARD TABLE OF BAPIMEREQITEMTEXT.
*DATA PRHEADERTEXT           TYPE STANDARD TABLE OF BAPIMEREQHEADTEXT.
*DATA EXTENSIONIN            TYPE STANDARD TABLE OF BAPIPAREX.
*DATA EXTENSIONOUT           TYPE STANDARD TABLE OF BAPIPAREX.
*DATA PRVERSION              TYPE STANDARD TABLE OF BAPIMEREQDCM.
*DATA PRVERSIONX             TYPE STANDARD TABLE OF BAPIMEREQDCMX.
*DATA ALLVERSIONS            TYPE STANDARD TABLE OF BAPIMEDCM_ALLVERSIONS.
*DATA PRCOMPONENTS           TYPE STANDARD TABLE OF BAPIMEREQCOMPONENT.
*DATA PRCOMPONENTSX          TYPE STANDARD TABLE OF BAPIMEREQCOMPONENTX.
*DATA SERVICEOUTLINE         TYPE STANDARD TABLE OF BAPI_SRV_OUTLINE.
*DATA SERVICEOUTLINEX        TYPE STANDARD TABLE OF BAPI_SRV_OUTLINEX.
*DATA SERVICELINES           TYPE STANDARD TABLE OF BAPI_SRV_SERVICE_LINE.
*DATA SERVICELINESX          TYPE STANDARD TABLE OF BAPI_SRV_SERVICE_LINEX.
*DATA SERVICELIMIT           TYPE STANDARD TABLE OF BAPI_SRV_LIMIT_DATA.
*DATA SERVICELIMITX          TYPE STANDARD TABLE OF BAPI_SRV_LIMIT_DATAX.
*DATA SERVICECONTRACTLIMITS  TYPE STANDARD TABLE OF BAPI_SRV_CONTRACT_LIMITS.
*DATA SERVICECONTRACTLIMITSX TYPE STANDARD TABLE OF BAPI_SRV_CONTRACT_LIMITSX.
*DATA SERVICEACCOUNT         TYPE STANDARD TABLE OF BAPI_SRV_ACC_DATA.
*DATA SERVICEACCOUNTX        TYPE STANDARD TABLE OF BAPI_SRV_ACC_DATAX.
*DATA SERVICELONGTEXTS       TYPE STANDARD TABLE OF BAPI_SRV_LONGTEXTS.
*DATA SERIALNUMBER           TYPE STANDARD TABLE OF BAPIMEREQSERIALNO.
*DATA SERIALNUMBERX          TYPE STANDARD TABLE OF BAPIMEREQSERIALNOX.

CALL FUNCTION 'BAPI_PR_CREATE'
* EXPORTING
*   PRHEADER                     = PRHEADER
*   PRHEADERX                    = PRHEADERX
*   TESTRUN                      = TESTRUN
* IMPORTING
*   NUMBER                       = NUMBER
-----------------------------------------------------------------------