Creating a Function Module with Import, Export, Table, and Exception Parameters Together
SAP Function Module With all Parameters
SAP ABAP Interview Questions – Real Time
Step 1: Go to T-code SE37. Enter the name of the Function Module and Click on Create.
Step 2: Enter the name of the Function Group you have created before and type the short text of the Function Module then Click on Save Button.
Step 3: A pop-up will display, click on button .
Step 4: Under the Attributes tab, you can change the Short Text, if you want.
Step 5: Under the Import tab, create an import parameter as shown below.
Step 6: Under the Export tab, create an export parameter as shown below.
Step 7: Under the Table tab, create a table parameter as shown below.
Step 8: Under the Exceptions tab, create an Exceptions Parameter with short text as shown below.
Step 9: Under the Source Code tab, write the code as shown below.
FUNCTION MODULE CODE:
FUNCTION ZFUNCMOD2.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” REFERENCE(I_VBELN) TYPE ZST_VBAP-VBELN
*” REFERENCE(I_POSNR) TYPE ZST_VBAP-POSNR
*” EXPORTING
*” REFERENCE(E_VBAP) TYPE ZST_VBAP
*” TABLES
*” T_VBAP STRUCTURE ZST_VBAP
*” EXCEPTIONS
*” NO_PARAMETER
*”———————————————————————-
IF I_VBELN IS INITIAL.
RAISE NO_PARAMETER.
ELSE.
SELECT VBELN
POSNR
MATNR
MATKL
ARKTX
FROM VBAP INTO TABLE T_VBAP
WHERE VBELN EQ I_VBELN AND POSNR EQ I_POSNR.
ENDIF.
ENDFUNCTION.
Step 10: Click on save button and activate it.
Step 11: Now click on button and enter the value in Import Parameters and click on button.
Step 12: Output is in the Export Parameter and Table Parameter. To view the output click on the button.
Step 13: To see the output of the table click onbutton.