Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 3: Access Method Services (AMS)


IDCAMS- PRINT Command

  • IDCAMS- PRINT command is used to print the contents of VSAM or non-VSAM dataset.
  • Contents can be printed in various formats such as CHAR, HEX or DUMP. We can specify our choice of format while specifying parameters of PRINT command.
  • Up to 120 characters/digits are printed per line. If record length is more than 120 characters, then the dataset is printed in blocks of 120 characters/digits per line
  • Syntax:-

    Syntax format 1:
    PRINT - INFILE(ip-ddName) - [optional-paramters]

    Syntax format 2:

    PRINT - INDATASET(ip-datasetName) - [optional-paramters]

  • Where,
    • ip-ddName points to the logical name of the input dataset as mentioned in the DD statement of same step.
      Example: //VSAMFL  DD DEPT.VSAM.KSDSFILE,DISP=SHR
      In above statement VSAMFL indicates DDNAME (i.e. logical name of Dataset)
    • ip-datasetName points to the physical name of the input and output dataset respectively. Ex. DEPT.VSAM.KSDSFILE
    • There are multiple optional parameter can be coded under PRINT command, but we have explained the most frequently used parameters in below.
  • Optional parameters:-
    Parameter Description
    CHAR | HEX | DUMP
    • This parameter is used to specify the format type to be printed. Default is DUMP
    • When specified CHAR, it prints content in EBCDIC format
    • When specified HEX, it prints content in Hexadecimal format.
    • When specified DUMP, it prints content in both, hexadecimal as well as character format.
    FROMKEY (value-1)
    TOKEY (value-2)
    • Prints all records whose key field value is between value-1 and value-2
    • Input file must be KSDS
    FROMADDRESS (add-value-1)
    TOADDRESS (add-value-2)
    • Print all records whose address is between add-value-1 and add-value-2
    • Input file must be KSDS or ESDS
    FROMNUMBER (RRN-1)
    TONUMBER (RRN-2)
    • Print all records whose relative record number(RRN) value is between RRN-1 and RRN-2
    • Input file must be RRDS
    SKIP(n)
    • • When SKIP parameter is used, PRINT skips printing of the n number of records from the start of the file
    COUNT(n)
    • COUNT parameter is used to specify that only n number of records should be printed
    • When SKIP parameter is coded before COUNT parameter, the count of number of records to print starts right after the number of records skipped
    • i.e. if “ SKIP(5) COUNT(10) “ is coded, then only records at row position 6 to 15 will be printed

Example 1

Use of PRINT command to print KSDS file

//PRINTKS EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //DD01 DD DSN=PAYT.PAYROLL.PRCSKSDS.MSTR,DISP=SHR //SYSIN DD * PRINT INFILE(DD01) /*

Description :- Above code snippet will print content of file ‘PAYT.PAYROLL.PRCSKSDS.MSTR’ in DUMP format since no other format is explicitly specified. Similarly, using the same code structure, you can also print ESDS, RRDS datasets

Example 2

Use of PRINT command to print selective records of ESDS file in CHAR format

//PRINTES EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //DD01 DD DSN=PAYT.PAYROLL.PRCSESDS.MSTR,DISP=SHR //SYSIN DD * PRINT INFILE(DD01) - CHAR - FROMADDRESS(325) TOADDRESS(950) /*

Description :- Above code snippet will print records between address 325 and 950 of file ‘PAYT.PAYROLL.PRCSESDS.MSTR’ in CHAR format since CHAR parameter is explicitly specified.

Example 3

Use of PRINT command to print selective records at row position 6 to 15 from ESDS file in HEX format

//PRINTES EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //DD01 DD DSN=PAYT.PAYROLL.PRCSESDS.MSTR,DISP=SHR //SYSIN DD * PRINT INFILE(DD01) - HEX - SKIP(5) COUNT(10) /*






© copyright mainframebug.com
Privacy Policy