BEGSR (Beginning of Subroutine)

Free-Form Syntax BEGSR subroutine-name
Code Factor 1 Factor 2 Result Field Indicators
BEGSR subroutine-name

The BEGSR operation identifies the beginning of an RPG IV subroutine. subroutine-name is the subroutine name. You may specify the same name as the subroutine-name on the EXSR operation referring to the subroutine, in the result field of the CASxx operation referring to the subroutine, or in the entry of an INFSR file specification keyword of the subroutine is a file-error subroutine. The control level entry (positions 7 and 8) can be SR or blank. Conditioning indicator entries are not permitted.

Every subroutine must have a unique symbolic name. The keyword *PSSR used in factor 1 specifies that this is a program exception/error subroutine to handle program-detected exception/errors. Only one subroutine can be defined by this keyword. *INZSR in factor 1 specifies a subroutine to be run during the initialization step. Only one subroutine can be defined *INZSR.

See Figure 183 for an example of coding subroutines; see Subroutine Operations for general information on subroutine operations.



[ Top of Page | Previous Page | Next Page | Contents | Index ]