Calling a Function Module from REPORT/ABAP/Driver Program.
Step 1: Go to SE38 and create a Program, as shown below.
Step 2: Write the title of the Program in “Title” and select “Executable Program” as Type under Attributes and click on save.
Step 3: Now enter the Package name in the ‘Package’ Attribute and click on the button.
Step 4: A new pop-up will open, select the TR and click the button.
Step 5: Now write the ABAP program as shown below.
Step 6: Now call Function Module by clicking the “Pattern” button or CTRL+F6. A pop will open, enter the name of the Function Module you want to call, and click on the button.
Step 7: Now type the following code into the program Editor.
Code:
REPORT ZUSING_FUNCMOD.
TABLES : VBAP.
DATA : WA_VBAP TYPE VBAP.
PARAMETERS : P_VBELN TYPE VBAP-VBELN.
START-OF-SELECTION.
CALL FUNCTION ‘ZFUNCMOD’
EXPORTING
i_vbeln = P_VBELN
IMPORTING
E_VBAP = WA_VBAP
EXCEPTIONS
NO_PARAMETER = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE :/ WA_VBAP-VBELN , WA_VBAP-POSNR , WA_VBAP-MATNR. “DISPLAYING THE RESULT.
Step 8: Save and Activate the program.
OUTPUT
Step 9: Now run the program by pressing the F8 button.
Step 10: Again Press F8 or the Above marked button.