Module 3: Access Method Services (AMS)
IDCAMS- MODAL Commands
- As mentioned earlier, IDCAMS has two types of commands, Functional commands and MODAL commands. Functional commands are used to perform function (i.e. DEFINE, ALTER, LISTCAT etc.) and MODAL commands are used to control the execution sequence of functional commands
- This feature is useful when multiple functional commands are to be executed, and each command is dependent on the result of previous one.
- When IDCAMS functional commands are executed, a condition code is returned as a result. This condition code indicates the status of the command after execution. Below table list the condition codes, its error severity and meaning
Condition code Error Severity Meaning 0 Normal completion Command ran successfully as expected 4 Minor Error Problem occurred in executing a complete function, but still it completed. A warning message will be issued 8 Major Error Requested function completed, but major specifications were unavoidably bypassed 12 Logical Error Requested function could not completed due to logical error. Logical error may be result of inconsistent parameters specification, required parameters are missing etc. 16 Severe Error Severe error occurred which has not only caused command failure but also the entire AMS command stream is flushed
- MODAL commands are: LASTCC, MAXCC, SET, IF-THEN-ELSE, DO-END
- Note:- Condition code can also be referred as Return code
- LASTCC :- LASTCC can be considered as variable which holds the condition code from the most recently executed command
- MAXCC :- MAXCC can be considered as variable which holds the highest condition code from any of the previously executed functional command within the same job step
- SET :- SET command is used to reset the MAXCC or LASTCC. i.e. we have ability to modify the LASTCC and MAXCC value as per our requirement.
- IF-THEN-ELSE :- This statements are used to control the command execution sequence. With IF statement, we can check and test results via the keywords LASTCC and MAXCC. Required check on LASTCC and MAXCC can be done using following operators
Operator Meaning ‘EQ’ or ‘ = ‘ Equal to ‘NE’ or ‘¬= ‘ Not Equal to ‘GT’ or ‘ > ‘ Greater than ‘GE’ or ‘ >= ‘ Greater than or Equal to ‘LT’ or ‘ < ‘ Less than ‘LE’ or ‘ <= ‘ Less than or Equal to
- DO-END Sequence :- It is used to group two or more commands that will be treated as single unit. This command is helpful when we have to use multiple command inside ‘IF’ or ‘ELSE‘ part of IF-THEN-ELSE command
Example depicting use of MODAL commands:-
In below example, REPRO command backups the KSDS file to GDG file. Only if the condition code of REPRO command is zero, KSDS file will be deleted as its backup available in GDG. Otherwise, PRINT and LISTCAT will be performed on KSDS file to print content and check KSDS file attributes. At the end, MAXCC is set to zero to avoid non-zero return code since we don’t want job to be failed.
IMP note:- In ‘else’ part we have used DO-END because we had to group PRINT and LISTCAT command. And also closely observe continuation mark ‘-‘ as this may cause error if not coded properly