INCLUDE <program_name>.
INCLUDE statement has the same effect as copying the source code of the include program <program_name> into another program. As include program can’t run independently, it has to be built into other programs. You may also nest include programs.
Following are a couple of restrictions while writing the code for Include programs −
- Include programs can't call themselves.
- Include programs must contain complete statements.
Step 1 − Create the program (Z_TOBEINCLUDED) to be included in ABAP Editor. Code to be included in ABAP Editor is −
PROGRAM Z_TOBEINCLUDED.
Write: / 'This program is started by:', SY-UNAME,
/ 'The Date is:', SY-DATUM,
/ 'Time is', SY-UZEIT.
Step 2 − Set the Type of the program to INCLUDE program, as shown in the following screenshot.
Step 3 − Click the ‘Save’ button and save the program in a package named ZINCL_PCKG.
Step 4 − Create another program where the program Z_TOBEINCLUDED has to be used. Here we have created another program named Z_INCLUDINGTEST and assigned the type for the program as Executable program.
Step 5 − The coding for Z_INCLUDINGTEST program includes the Z_TOBEINCLUDED program with the help of the INCLUDE statement as shown in the following code.
REPORT Z_INCLUDINGTEST.
INCLUDE Z_TOBEINCLUDED.
Step 6 − Save, activate and execute the program.
The above code produces the following output:
This program is started by: SAPUSER
The Date is: 06.10.2015
Time is 13:25:11
No comments:
Post a Comment