HP RPG/XL Programmer's Guide (30318-90001)

5- 18
Calculation Specification to perform it.
RPG has two kinds of subroutines. Internal subroutines are part of an
RPG program. External subroutines are independent load modules that are
written in Business BASIC, C, Pascal, SPL or COBOL.
Internal Subroutines
To perform an internal subroutine, enter an EXSR Calculation
Specification operation. Place the subroutine, itself, after the last
Calculation Specification in the program. The BEGSR operation marks the
beginning of an internal subroutine and always has a tag associated with
it. You use this tag to execute the subroutine. To end an internal
subroutine, follow the last line in the subroutine with an ENDSR
operation.
Figure 5-14 shows how internal subroutines are coded. In this example,
the subroutine is named, INQRY.
Figure 5-14. Using an Internal Subroutine
Comments
1 This line performs the internal subroutine INQRY when a user
presses function key F3. (Conditioning the EXSR operation is
optional.)
Columns 28-32 contain EXSR to execute an internal subroutine.
Columns 33-38 contain the name of the internal subroutine,
INQRY.
2 This line begins the INQRY internal subroutine.
Columns 7-8 contain SR to indicate that this is a subroutine
line (SR is optional on this and subsequent subroutine lines).