Domain: PROCEDURE
Command description
Command blocks which are to be treated as a logical unit begin with the BEGIN-BLOCK command and end with the END-BLOCK command. These command blocks are also called BEGIN blocks (BEGIN block: see section “Creating the procedure body”).
The command block can be identified by a tag. This tag can also be used as a branch destination (tags: see chapter “The procedure concept in SDF-P”).
The PROGRAM-INPUT operand controls the handling of commands within inputs to programs (statements and data) as well as the handling of the return codes from program statements.
Format
BEGIN-BLOCK |
PROGRAM-INPUT = *STD / *MIXED-WITH-CMD(...) *MIXED-WITH-CMD(...) PROPAGATE-STMT-RC = *STD / *TO-CMD-RC |
Operands
PROGRAM-INPUT =
Determines whether inputs to programs (statements and data) may contain commands and controls the handling of the return codes from program statements. The setting is not valid for subsequent procedure calls.
PROGRAM-INPUT = *STD
Commands are handled as in the enclosing BEGIN block. In the first-level BEGIN block, or if there is no BEGIN block, the commands must be bracketed by a HOLD-PROGRAM and a RESUME-PROGRAM command. In other words, if the data lines are interrupted by a command (except HOLD-PROGRAM), an end-of-file condition (EOF) is generated.
PROGRAM-INPUT = *MIXED-WITH-CMD(...)
No distinction is made between statements/data records and commands, i.e. commands do not generate an end-of-file condition (EOF).
PROPAGATE-STMT-RC =
Determines whether return codes from program statements are to be interpreted as command return codes and whether these return codes are to trigger SDF-P error handling.
PROPAGATE-STMT-RC = *STD
The handling of return codes from statements and SDF-P error handling are determined by the enclosing BEGIN block. In the first-level BEGIN block, or if there is no BEGIN block, return codes from statements are ignored; error handling at command level requires the use of the predefined function STMT-SPINOFF().
PROPAGATE-STMT-RC = *TO-CMD-RC
The return codes from program statements are available as command return codes and control SDF-P error handling. Further processing does not differentiate between command return codes and return codes from program statements.
SDF-P error handling is triggered only if SUBCODE1 is not equal to zero.
Note
The predefined function STMT-SPINOFF() is of no use in this case, since it will never return the value 'YES'.
Command return codes
(SC2) | SC1 | Maincode | Meaning |
0 | CMD0001 | No error |
Examples
Program statements separated from commands:
Program statements are bracketed by the commands HOLD-PROGRAM and RESUME-PROGRAM. A BEGIN block is not required.
/start-lms / hold-program / library = 'my-library' / write-text 'Elements of &library.' / resume-program // show-element-attributes *library-element(&library.) / hold-program / library = 'my-second-library' / write-text 'Elements of &library.' / resume-program // show-element-attributes *library-element(&library.) //end
Program statements mixed with commands:
Commands and program statements are enclosed by a BEGIN block. Commands are automatically distinguished from program statements.
/begin-block program-input = *mixed-with-cmd / start-lms / library = 'my-library' / write-text 'Elements of &library.' // show-element-attributes *library-element(&library.) / library = 'my-second-library' / write-text 'Elements of &library.' // show-element-attributes *library-element(&library.) // end /end-block
Return codes from program statements
Return codes from program statements and command return codes are treated alike.
/begin-block program-input = *mixed-with-cmd(propagate-stmt-rc = *to-cmd-rc) / &* Start a program which generates statement return codes / start-executable-program my-new-program // my-statement1 / if-cmd-error &* Test statement return code / write-text 'Error during execution of my-statement' / write-text 'Maincode: &mc; Subcode1: &sc1; Subcode2: &sc2' / end-if / show-file-attributes &my-file.
/ if-cmd-error &* Test command return code / write-text 'Error &mc during access to my-file' / end-if // my-statement2 / save-returncode &* Save statement return code / if (maincode <> 'CMD0001') / write-text 'Warning &mc during execution of my-statement2' / end-if // end /end-block
Processing of the STEP statement:
The STEP statement resets the SDF-P error handling triggered by errors in statements. If the return code is needed, separate error handling must be performed in an SDF-P error block (/IF-BLOCK-ERROR or /IF-CMD-ERROR instead of //STEP).
/begin-block program-input = *mixed-with-cmd(propagate-stmt-rc = *to-cmd-rc) / &* The following program generates statement return codes / start-executable-program <name> // <statement> // step / &* SDF-P error handling is reset // end /end-block
Processing of the END statement:
The END statement (//END) terminates program execution as well as SDF-P error handling triggered by errors in statements, if any. If the return code is needed, error handling must be performed in an SDF-P error block that precedes the END statement (/IF-BLOCK-ERROR or /IF-CMD-ERROR).
/begin-block program-input = *mixed-with-cmd(propagate-stmt-rc = *to-cmd-rc) / &* Start a program which generates statement return codes / start-program <name> // my-statement // end / if-block-error / &* the //END statement has been processed, / &* the return code which is available is the command / &* return code of the /start-program and NOT the statement / &* return code of //my-statement / write-text 'Error &mc returned by /start-program' / end-if /end-block