IDCAMS basics


Access Method Services

Pre-VSAM data management required many utility programs for housekeeping –IEBGENER, IEBCOPY, IEHMOVE etc.
However, there is only a single utility for managing all of the housekeeping needs of VSAM -

IDCAMS:

It is the IDCAMS utility that provides the Access Method Services (AMS).
Following is the how the Basic IDCAMS job would look like.

***************************** Top of Data *************
//JOB00001 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID   
//STEP0001 EXEC PGM=IDCAMS                             
//SYSPRINT DD   SYSOUT=*                              
//SYSIN    DD *                                       
/*                                                    
**************************** Bottom of Data ***********

Some of the functions require additional DD statements when they are referenced , but SYSPRINT and SYSIN are the only absolute requirements.


Rules to Code IDCAMS Syntax statements:

·        The format of AMS commands is basically free form.
·        The default statement margins are positions 2 through 72. 
·        Any command statement may be continued from one line to the next by following the last parameter in a line with a hyphen (-).
·        A value may be continued by immediately following it with a plus sign (+).
·        A comment may be embedded in the command statements by enclosing the comment characters with /* and */. 
·         Positional parameters are not optional and must precede all keyword parameters.  

How to use the LASTCC and MAXCC variables:

LASTCC: Return code of Last command.
MAXCC: Maximum return code of the entire execution. This is needed as one execution of the IDCAMs utility can contain several commands. MAXX is used to capture highest return code of any of the commands.
These two are used to determine the outcome of the command and then decide what has to be done.
Ø  Following are the return codes set by the AMS:
·         0 - Normal Completion - the functional command completed its processing successfully
·         4 - Minor Error - processing is able to continue, but a minor error occurred, causing a warming message to be issued
·         8 - Major Error - processing is able to continue, but a more severe error occurred, causing major command specifications to be bypassed
·         12 - Logical Error - generally, inconsistent parameters are specified, causing the entire command to be bypassed
·         16 - Severe Error - an error of such severity occurred that not only can the command causing the error not be completed, the entire AMS command stream is flushed
Ø  We can make use of IF ELSE structure to commands conditionally depending upon the return code:
IF {LASTCC | MAXCC} {operator} {numeric value}
    THEN {command} |
               DO
                       {command set}
                END
[ELSE {command} |
                DO
                        {command set}
                END]
Note that the command set has to be written inside DO and END statements.
Ø  Following are the operations that can be used to perform comparison:
EQ or =
equal to
NE or ¬=
not equal to
GT or >
greater than
LT or <
less than
GE or >=
greater than or equal to
LE ro <=
less than or equal to

SET Command

The SET command may be used to set either the LASTCC value or the MAXCC value to a specific value.  Frequently the SET command is used to reset the return code(s) to a value of 0 following an expected warning level error condition.
This can be used to LISTCAT a particular dataset and then set the MAXCC accordingly depending upon whether dataset exists or not.
SET MAXCC TO 4


Tasks that can be accomplished using IDCAMS:
Ø  Creating a user catalog.
Ø  Defining space for VSAM files.
Ø  Creating GDG.
Ø  Creating KSDS,ESDS and RRDS clusters.
Ø  Creating Alternate index.
Ø  Copying datasets.
Ø  Printing datasets in Hex or dump format.

No comments:

Post a Comment