A procedure is a named, functional collection of statements. Procedures can divide a program or subprogram into logical subcomponents.
This statement has the following format:
<<procedure_name>> {PROC }
{PROCEDURE }
statements
[ENDPROC ]
[ENDPROCEDURE]
A 1‑ to 15‑character user‑defined label for the procedure. The chevrons (<< and >>) are required. The chevrons are not included in the label length. Blanks are left‑ and right‑justified. Internal blanks are not allowed.
A reserved word that designates the beginning of a new procedure. The procedure name and this reserved word are optional for the first or main procedure of the program.
A reserved word that designates the end of the procedure. This reserved word is optional and, when omitted, the next procedure or the end of the program terminates the procedure.
You can omit the label and the reserved word PROC or PROCEDURE on the first (or main) procedure only.
Any statements occurring after an ENDPROCEDURE and before the next PROCEDURE are treated as errors.
You can use a procedure with the name <<ERROR>> in a program to handle execution time errors at runtime without necessarily aborting the RUN or take action before quitting execution of the program. See the Error Procedure topic in this chapter.
Example
This example illustrates two procedures, which are the main procedure and procedure ADD_REC. Two other procedures referenced by the main procedure, DEL_REC and OTHER_PROC, are not shown.
<<MAIN>> PROCEDURE
LOOP
TRANSMIT MAINPNL
UNTIL TRANSCODE = 'T'
SET MAINPNL.MSG = ' '
SELECT TRANS_CODE
WHEN 'A'
DO ADD_REC
WHEN 'B'
DO DEL_REC
WHEN OTHER
DO OTHER_PROC
ENDSEL
ENDLOOP
ENDPROC
<<ADD_REC>> PROCEDURE
TRANSMIT ADDPNL CLEAR
FOR NEW EMPLOYEE
SET EMPLOYEE = ADDPNL BY NAME
SET MAINPNL.MSG = 'EMPLOYEE ADDED'
WHEN DUPLICATE
SET MAINPNL.MSG = 'RECORD ALREADY ON FILE'
ENDFOR
ENDPROC
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|