Start IF-BLOCK-ERROR block
Component: | SDF-P-BASYS |
Functional area: | Procedures |
Domain: | PROCEDURE |
Privileges: | STD-PROCESSING |
Function
IF-BLOCK-ERROR is an SDF-P control flow command.
The IF-BLOCK-ERROR command initiates block-specific error handling within an S procedure. The command block initiated in this way must be terminated by an END-IF command.
Restrictions
Users with SECURITY-ADMINISTRATION, SAT-FILE-EVALUATION or SAT-FILE-MANAGEMENT privilege can use the command in procedures only.
Type of error handling
The type of error handling in an S procedure depends on the setting of the ERROR-MECHANISM operand of the SET-PROCEDURE-OPTIONS command.
If nothing is specified in the procedure with regard to ERROR-MECHANISM or ERROR-MECHANISM=*SPIN-OFF-COMPATIBLE is defined, SDF-P activates error handling if a command supplies spin-off. Error handling in this instance does not on the command return code.
This error mechanism is the default case and means that S procedures do not change their behavior in the event of errors if commands contained in such procedures supply a command-specific command return code for the first time in a future version (whereas previously this was formed by SDF by analogy with spin-off).
If ERROR-MECHANISM=*BY-RETURNCODE is defined, SDF-P activates error handling when a command returns a command return code with a nonzero subcode 1. Error handling is in this case not dependent on the spin-off behavior of the command.
This error mechanism must be defined explicitly.
SDF-P Error handling
Command processing resumes with the next IF-BLOCK-ERROR command; only the current command block, or in the case of nested blocks also the higher-level command blocks, is/are searched in the direction of the end of the file. If no IF-BLOCK-ERROR block is found, the procedure terminates when the end of the procedure file is reached. The error is passed on to the caller. The error situation is terminated when an IF-BLOCK-ERROR block or procedure level 0 is reached.
For compatibility reasons the error situation is also terminated when a SET-JOB-STEP command is encountered.
Note
Error handling can be performed for the command currently being terminated with the aid of the IF-CMD-ERROR command (contained in the chargeable SDF-P subsystem).
In non-S procedures, error handling continues to be controlled by the spin-off (see error handling using the SET-JOB-STEP command).
Format
IF-BLOCK-ERROR |
Return codes
(SC2) | SC1 | Maincode | Meaning |
---|---|---|---|
0 | CMD0001 | No error | |
1 | CMD0202 | Syntax error | |
1 | SDP0118 | Command in incorrect context | |
1 | SDP0223 | Incorrect environment | |
3 | CMD2203 | Incorrect syntax file | |
32 | CMD0221 | System error (internal error) | |
130 | SDP0099 | No further address space available |
Example
Error recovery in an S procedure is illustrated using the PROC.SORT2 procedure.
Contents of procedure PROC.SORT2:
/BEG-PAR-DECL / DECL-PAR INPUT-FILE-1 (INIT = *PROMPT) / DECL-PAR OUTPUT-FILE-1 (INIT = *PROMPT) /END-PAR-DECL /INPUT-FILE-EXIST: SHOW-FILE-ATTRIBUTES &(INPUT-FILE-1) /COND-1: IF ( INPUT-FILE-1 = OUTPUT-FILE-1 ) / WRITE-TEXT 'Input file = output file !!!' / WRITE-TEXT 'Output file with suffix COPY.<tsn>' / SET-VAR OUTPUT-FILE-1 = '&(OUTPUT-FILE-1).COPY.&(TSN())' / CREATE-FILE &(OUTPUT-FILE-1) /ERR-1: IF-BLOCK-ERROR / WRITE-TEXT 'New output file not possible' / HELP-MSG &(MC) / EXIT-PROC ERROR=*YES / ELSE / WRITE-TEXT 'New output file &(OUTPUT-FILE-1) generated' /ERR-1-END: END-IF / ELSE "Input file unequal output file" / SHOW-FILE-ATTRIBUTES &(OUTPUT-FILE-1) /ERR-2: IF-BLOCK-ERROR / WRITE-TEXT 'Output file being regenerated' / CREATE-FILE &(OUTPUT-FILE-1) / ELSE / WRITE-TEXT 'Output file already exists. Cancel' / EXIT-PROC ERROR=*YES /ERR-2-END: END-IF /COND-1-END: END-IF /WORK-1: "Sorting file 1" / ADD-FILE-LINK LINK=SORTIN, - / FILE-NAME= &(INPUT-FILE-1) / ADD-FILE-LINK LINK=SORTOUT, - / FILE-NAME= &(OUTPUT-FILE-1) / SORT-FILE /WORK-1-ERROR: IF-BLOCK-ERROR / WRITE-TEXT 'Input file does not exist or' / WRITE-TEXT 'Error in WORK-1: SC1 = &(SC1)' / HELP-MSG &(MC) / ELSE / WRITE-TEXT 'WORK-1 terminated without errors' / END-IF
Case 1:
/call-proc alf.proc.sort2,log=*yes
% 1 1 /BEG-PAR-DECL % 2 1 /DECL-PAR INPUT-FILE-1 (INIT = *PROMPT) % 3 1 /DECL-PAR OUTPUT-FILE-1 (INIT = *PROMPT) % 4 1 /END-PAR-DECL %INPUT-FILE-1: abk.v110 % 5 1 /INPUT-FILE-EXIST: % 5 1 / SHOW-FILE-ATTRIBUTES ABK.V110 % 99 :2OSG:$USER1.ABK.V110 %:2OSG: PUBLIC: 1 FILE RES= 99 FRE= 1 REL= 0 PAGES % 6 1 /COND-1: % 6 1 / IF ( INPUT-FILE-1 = OUTPUT-FILE-1 ) %OUTPUT-FILE-1: abk.v110 % 7 1 /WRITE-TEXT 'Input file = output file !!!' Input file = output file !!! % 8 1 /WRITE-TEXT 'Output file with suffix COPY.<tsn>' Output file with suffix COPY.<tsn> % 9 1 /SET-VAR OUTPUT-FILE-1 = 'ABK.V110.COPY.3ZAA' % 10 1 /CREATE-FILE ABK.V110.COPY.3ZAA % 11 1 /ERR-1: % 11 1 / IF-BLOCK-ERROR % 15 1 /ELSE % 16 1 /WRITE-TEXT 'New output file ABK.V110.COPY.3ZAA generated' New output file ABK.V110.COPY.3ZAA generated % 17 1 /ERR-1-END: % 17 1 / END-IF % 27 1 /COND-1-END: % 27 1 / END-IF % 28 1 /WORK-1: % 29 1 /ADD-FILE-LINK LINK=SORTIN, FILE-NAME = ABK.V110 % 31 1 /ADD-FILE-LINK LINK=SORTOUT, FILE-NAM E= ABK.V110.COPY.3ZAA % 33 1 /SORT-FILE % BLS0523 ELEMENT 'SRT80', VERSION '079', TYPE 'L' FROM LIBRARY ':1OSH:$TSOS.SY SLNK.SORT.079' IN PROCESS % BLS0524 LLM 'SRT80', VERSION '079' OF '2009-03-09 15:55:15' LOADED % BLS0551 COPYRIGHT (C) FUJITSU TECHNOLOGY SOLUTIONS 2009. ALL RIGHTS RESERVED % SRT1001 2012-04-28/17:59:44/000000.00 SORT/MERGE STARTED, VERSION 07.9C00/BS 2000V19.0 % SRT1130 PLEASE ENTER SORT STATEMENTS % SRT1016 SORT/MERGE INPUT RECORDS:............................2.924 (FROM 01) % SRT1030 SORT/MERGE OUTPUT RECORDS:...........................2.924 % SRT1002 2012-04-28/17:59:45/000000.43 SORT/MERGE COMPLETED % 34 1 /WORK-1-ERROR: % 34 1 / IF-BLOCK-ERROR % 38 1 /ELSE % 39 1 /WRITE-TEXT 'WORK-1 terminated without errors!' WORK-1 terminated without errors! % 40 1 /END-IF % 1 /EXIT-PROCEDURE ERROR=*NO
A new output file is generated because the input file was also specified as the output file. Processing is error-free, i.e. when an error handling block is reached, the ELSE branch is processed.
Case 2:
/call-proc proc.sort2,log=*yes
% 1 1 /BEG-PAR-DECL % 2 1 /DECL-PAR INPUT-FILE-1 (INIT = *PROMPT) % 3 1 /DECL-PAR OUTPUT-FILE-1 (INIT = *PROMPT) % 4 1 /END-PAR-DECL %INPUT-FILE-1: abk.v111 % 5 1 /INPUT-FILE-EXIST: % 5 1 / SHOW-FILE-ATTRIBUTES ABK.V111 % DMS0533 REQUESTED FILE NOT CATALOGED IN PUBSET '2OSG'. COMMAND TERMINATED % SDP0004 ERROR DETECTED AT COMMAND LINE: 5 IN PROCEDURE ':2OSG:$USER 1.ALF.PROC.SORT2' % 34 1 /WORK-1-ERROR: % 34 1 / IF-BLOCK-ERROR % 35 1 /WRITE-TEXT 'Input file does not exist or' Input file does not exist or % 36 1 /WRITE-TEXT 'Error in WORK-1: SC1 = 64' Error in WORK-1: SC1 = 64 % 37 1 /HELP-MSG DMS0533 % DMS0533 REQUESTED FILE NOT CATALOGED IN PUBSET '(&00)'. COMMAND TERMINATED % ? This message is issued by DMS commands. The requested file is not % cataloged in the requested pubset. % RESPONSE : NONE % 40 1 /END-IF % 1 /EXIT-PROCEDURE ERROR=*NO
The input file ABK.V111 does not exist and leads to an error upon SHOW-FILE-ATTRIBUTES. A branch is made to the next error handling block, in this case the command block initiated with the tag WORK-1-ERROR. The error handling blocks in the subordinate IF block (IF and ELSE-branches) are not taken into account. Since the error was “handled” the procedure is implicitly terminated with ERROR=*NO.
Case 3:
/call-proc proc.sort2,log=*yes
% 1 1 /BEG-PAR-DECL % 2 1 /DECL-PAR INPUT-FILE-1 (INIT = *PROMPT) % 3 1 /DECL-PAR OUTPUT-FILE-1 (INIT = *PROMPT) % 4 1 /END-PAR-DECL %INPUT-FILE-1: abk.v110 % 5 1 /INPUT-FILE-EXIST: % 5 1 / SHOW-FILE-ATTRIBUTES ABK.V110 % 99 :2OSG:$USER1.ABK.V110 %:2OSG: PUBLIC: 1 FILE RES= 99 FRE= 1 REL= 0 PAGES % 6 1 /COND-1: % 6 1 / IF ( INPUT-FILE-1 = OUTPUT-FILE-1 ) %OUTPUT-FILE-1: abk.v110.sort % 18 1 /ELSE "Input file unequal output file" % 19 1 /SHOW-FILE-ATTRIBUTES ABK.V110.SORT % 138 :2OSG:$USER1.ABK.V110.SORT %:2OSG: PUBLIC: 1 FILE RES= 138 FRE= 40 REL= 39 PAGES % 20 1 /ERR-2: % 20 1 / IF-BLOCK-ERROR % 23 1 /ELSE % 24 1 /WRITE-TEXT 'Output file already exists. Cancel' Output file already exists. Cancel % 25 1 /EXIT-PROC ERROR=*YES
The output file exists already. The SHOW-FILE-ATTRIBUTES command for file ABK.V110.SORT does not lead to an error. Consequently, the ELSE branch in the subsequent error handling block (at ERR-2) is processed (explicit EXIT-PROCEDURE with ERROR=*YES).