An include program is a program in which the contents are designed to be used by another program. It is not usually complete all by itself. Instead, other programs use the code the include program contains by copying the lines of code from the include program into themselves. The copy is performed at runtime via the include statement. An include program is also known as an included program.
A program that includes another is known as an including program.
An Including Program
This Program Is Included into ztx1901
This Program Is also Included into ztx1901
The code in Listings 19.1 through 19.3 produces this output:
ANALYSIS
A program that includes another is known as an including program.
Syntax for the include Statement
The following is the syntax for the include statement.where:include ipgm.
- ipgm is a type i program.
- An include program must be type i. You specify the program type in the Type field on the Program Attributes screen when you create the program.
- An include program can be included into one or more including programs.
- A type i program cannot contain partial or incomplete statements.
An Including Program
1 report ztx1901 no standard page heading. 2 tables: ztxlfa1, ztxlfb1. 3 parameters p_lifnr like ztxlfa1-lifnr obligatory default '1000'. 4 5 include: ztx1902, 6 ztx1903. 7 8 top-of-page. 9 write: / 'Company Codes for Vendor', p_lifnr. 10 uline.
This Program Is Included into ztx1901
2 select single * from ztxlfa1 where lifnr = p_lifnr.1 ***INCLUDE ZTX1902.
This Program Is also Included into ztx1901
1 ***INCLUDE ZTX1903. 2 select * from ztxlfb1 where lifnr = ztxlfa1-lifnr. 3 write: / ztxlfb1-bukrs. 4 endselect.
The code in Listings 19.1 through 19.3 produces this output:
3000Company Codes for Vendor 1000 --------------------------------- 1000
ANALYSIS
- At generation time for ztx1901, line 5 copies the code from program ztx1902 into ztx1901. The inserted code replaces line 5.
- Still during program generation of ztx1901, line 6 copies the code from program ztx1903 into ztx1901. The inserted code replaces line 6.
- When the program runs, ztx1901 behaves like a single program, as if those lines of code from the included programs had been typed directly into ztx1901.
TIP |
While viewing an including program, you can view the contents of an included program simply by double-clicking on its name. For example, while editing ztx1901 from the ABAP/4 Editor: Edit Program screen, double-click on the name ztx1902 orztx1903. The included program will be displayed immediately. |
TIP |
If you want to see the resulting code with all includes expanded in-line, run programRSINCL00. On the selection screen for RSINCL00, in the Program field, enter the name of a program that includes other programs. Place an X in the Program Source Code and Expand Include Lines fields and press Execute. A list of the resulting source code will be displayed on the next screen. |
No comments:
Post a Comment