Modal Commands

It is possible to include AMS commands to perform more than one function in a single execution of the IDCAMS utility.  Therefore, AMS sets a return code following the execution of each command, and also maintains a maximum return code value for each execution.  AMS commands are provided to interrogate these return codes and conditionally execute command statements based on the return code set during the execution of prior commands.
The return codes set by AMS can be interpreted as -
  • 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

IF - THEN - ELSE Structure

The statement structure used to conditionally execute commands based upon the return code values is an IF - THEN - ELSE structure:
IF {LASTCC | MAXCC} {operator} {numeric value}
    THEN {command} |
                       {command set}
[ELSE {command} |
                        {command set}
In the IF statement, the return code to be tested is specified as one of LASTCC or MAXCC, where LASTCC specifies the return code set during the execution of the command just prior to the IF structure and MAXCC specifies the largest return code value set during this execution if IDCAMS.  The {operator} is specified as one of the following comparison operators:

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

Following the THEN keyword or the optional ELSE keyword, either a single AMS command or a block of AMS commands enclosed in a DO/END pair may be coded.

Null Commands

If a THEN keyword or ELSE keyword in an IF-THEN-ELSE structure is not followed by an AMS functional command, or does not include a continuation character indicating that a functional command follows on the next line, then a null THEN or ELSE clause is assumed.

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.

REPRO Command

You can use the REPRO command of IDCAMS to copy VSAM and non-VSAM data sets, VSAM clusters, and alternate indexes. You cannot use REPRO to copy an entire partitioned data set (PDS) because REPRO does not copy the information in the directories. You can, however, use REPRO to copy individual members. The IBM IEBCOPY utility should be used to copy an entire PDS.


INFILE(ddname)                OUTFILE(ddname)
INDATASET(entryname)          OUTDATASET(entryname)
FROMKEY(key)                  TOKEY(key) 
FROMADDRESS(address)          TOADDRESS(address)
FROMNUMBER(number)            TONUMBER(number) 
SKIP(count)]                  COUNT(count)     

REPLACE may be specified to cause existing records in the output cluster to be replaced when a duplicate record is read from the input dataset.  REPLACE is applicable for KSDS and RRDS clusters.  REPLACE may also be used to merge input from subsequent REPRO operations with different input datasets to the same target dataset, where the possibility of duplicate records.  If an attempt is made to add a duplicate record and REPLACE is not specified, an error message and the input record is discarded; on the fourth occurrence of a duplicate record, the REPRO operation is terminated and the remainder of the input file is not processed.

The REUSE parameter may be specified to cause the output cluster to be reset to empty status before loading commences.  In order for the REUSE parameter to be allowable, the output cluster must have been defined with the REUSE attribute.

When Merging datasets using REPRO, observer the following rules:
When the Target is KSDS or ESDS, then source can be ESDS,KSDS or RRDS
When the Target is RRDS, then the source must be RRDS.

PRINT Command

The PRINT command is used to print the contents of both VSAM and non-VSAM datasets.
INFILE(ddname)                OUTFILE(ddname)
FROMKEY(key)                  TOKEY(key) 
FROMADDRESS(address)          TOADDRESS(address)
FROMNUMBER(number)            TONUMBER(number) 
SKIP(count)]                  COUNT(count)     
[CHAR | DUMP | HEX ] Dump specifies to print in both Hex & Char format.

Empty File Check : If file is empty, PRINT COUNT(1) ends with RC=4.

DELETE Command

DELETE (entryname,entryname...)

The ERASE parameter specifies that when the cluster is deleted, the space occupied by the cluster should be physically erased by overwriting the space with binary zeros prior to freeing the space for reuse.

The FORCE option may be specified to cause the deletion of specific objects (SPACE, USERCATALOG, GENERATIONDATAGROUP) even though they may be non-empty.

The PURGE option may be specified to delete the dataset even if the retention period has not expired.

The SCRATCH option may be specified to remove the dataset from catalog, VTOC and from volume.

VERIFY Command

If a job terminates abnormally and a VSAM dataset is not closed, the catalog entry for the dataset is flagged to indicate that the dataset may be corrupt.  Before the dataset can be opened again, the VERIFY command must be used to correctly identify the end of the dataset and reset the catalog entry.

VERIFY FILE(ddname) | DATASET(entryname)

Base cluster and AIX needs to be verified separately. The verification of base cluster does not verify its associated AIXes automatically. 


Computers TopOfBlogs Technology Blogs Mainframe interview question and answers,mainframe jobs,cobol,vsam,jcl,cics,db2,rdbms,mvs,tso,ispf,ibm,hcl,tcs,cts,wibro Blog Directory