JCL

VSAM PRINT using IDCAMS with Examples

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

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

VSAM PRINT Syntax

PRINT {INFILE(ip-ddname[/password])|
    INDATASET(ip-entryname[/password])}
*********[optional-paramters] *************
  [CHARACTER|DUMP|HEX] 
  [FROMKEY(key)|FROMADDRESS(address)|
    FROMNUMBER(number)|SKIP(number)] 
  [OUTFILE(ddname)] 
  [TOKEY(key)|TOADDRESS(address)|
    TONUMBER(number)|COUNT(number)] 

ip-ddname – It points to the logical name of the input dataset as mentioned in the DD statement of the same step.
Example: //VSAMFL  DD XXXXXX.YYYYYY.KSDSFILE,DISP=SHR
In the above statement, VSAMFL indicates ddname (i.e. logical name of Dataset)

ip-entryname – It points to the input and output data’s physical names, respectively. Ex. XXXXXX.YYYYYY.KSDSFILE.

VSAM PRINT Optional parameters

ParameterDescription
CHAR | HEX | DUMPThis parameter is used to specify the format type to be printed. Default is DUMP

If CHAR is specified, it prints content in EBCDIC format.

If HEX is specified, it prints content in Hexadecimal format.

If DUMP is specified, 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)If the 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 the SKIP parameter is coded before the COUNT parameter, the count of the 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.

Use of the PRINT command to print KSDS file

//KSDSPRNT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//* SAMPLE JCL PRINT DATA FROM KSDS VSAM FILE
//*************************************************************
//PRINTKS  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*  
//DD01     DD DSN=XXXXXX.YYYYYY.KSDSFILE,DISP=SHR 
//SYSIN    DD * 
     PRINT INFILE(DD01)
/* 

OR

//SYSIN     DD *
   PRINT INDATASET(DD01)
/*

The above code snippet will print the content of file ‘XXXXXX.YYYYYY.KSDSFILE’ in DUMP format since no other format is explicitly specified. Similarly, using the same code structure, you can also print ESDS and RRDS datasets.

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

//KSDSPRNT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//            NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//* SAMPLE JCL PRINT DATA FROM ESDS VSAM FILE
//*************************************************************
//PRINTES  EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                                 
//DD01     DD DSN=XXXXXX.YYYYYY.ESDSFILE,DISP=SHR  
//SYSIN    DD *                                        
     PRINT INFILE(DD01)              -           
     CHAR                            -           
     FROMADDRESS(100) TOADDRESS(500)                  
/*

Since the CHAR parameter is explicitly specified, the above code snippet will print records between addresses 100 and 500 of file ‘XXXXXX.YYYYYY.ESDSFILE’’ in CHAR format.

Use of the PRINT command to print selective records at row positions 11 to 15 from ESDS file in HEX format

//KSDSPRNT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//* SAMPLE JCL PRINT SELECTIVE DATA FROM ESDS VSAM FILE
//*************************************************************
//PRINTES  EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                                 
//DD01     DD DSN=XXXXXX.YYYYYY.ESDSFILE,DISP=SHR  
//SYSIN    DD *                                        
     PRINT INFILE(DD01)  -           
     HEX                 -           
     SKIP(10) COUNT(5)                  
/* 

Use of the PRINT command to print using FROMKEY and TOKEY

//KSDSPRNT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//* SAMPLE JCL PRINT DATA IN CHAR USING FROMKEY AND TOKEY
//*************************************************************
//PRINTES  EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                                 
//DD01     DD DSN=XXXXXX.YYYYYY.ESDSFILE,DISP=SHR  
//SYSIN    DD *                                        
   PRINT INFILE(DD01) CHAR FROMKEY(X'F1') TOKEY(X’F2')               
/*

Use of the PRINT command to print using FROMADDRESS and TOADDRESS

//KSDSPRNT JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//* SAMPLE JCL PRINT DATA IN CHAR USING FROMKEY AND TOKEY
//*************************************************************
//PRINTES  EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                                 
//DD01     DD DSN=XXXXXX.YYYYYY.ESDSFILE,DISP=SHR  
//SYSIN    DD *                                        
   PRINT IFILE(DD01) DUMP - 
   FROMADDRESS(16220160) TOADDRESS(17694720)               
/*

Print records matching a specific condition

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  PRINT INFILE(VSAM.FILE.NAME) -
        CHAR WHERE((10,5,CH,EQ,C'MATCH'))
/*

In this example, only the records that have the string MATCH in positions, 10 to 14 are printed in character format.

Print records matching a specific condition

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  PRINT INFILE(VSAM.FILE.NAME) -
        CHAR FIELD=(2,10,20,5)
/*

In this example, the fields starting at position 2, 10, 20, and 5 characters long are printed in character format for each record in the VSAM file.

Print VSAM records with header and trailer records

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  PRINT INFILE(VSAM.FILE.NAME) -
        CHAR HEADER(1,'HEADER RECORD') -
        TRAILER(1,'TRAILER RECORD')
/*

In this example, all records in the VSAM file named VSAM.FILE.NAME are printed in character format with a header record and a trailer record. The HEADER and TRAILER parameters specify the content of the header and trailer records respectively.

Print only the first 10 records from a VSAM file

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT INFILE(VSAM.FILE.NAME) –
CHAR FIRST(10)

/*

In this example, only the first 10 records in the VSAM file named VSAM.FILE.NAME are printed in character format.

Print VSAM records using a control file

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  PRINT INFILE(VSAM.FILE.NAME) -
        CHAR -
        CONTROLFILE(CONTROL.FILE.NAME)
/*
//CTLFILE DD DSN=CONTROL.FILE.NAME,
//       DISP=SHR

In this example, all records in the VSAM file named VSAM.FILE.NAME are printed in character format using a control file named CONTROL.FILE.NAME. The CTLFILE DD statement specifies the location and access mode of the control file.

The control file is a sequential file that contains control statements to specify the output format and other options for the PRINT command. Here is an example of a control file:

OPTION HEADER ON
OPTION TRAILER ON
OPTION TRAILERLOC AFTER
OPTION BLKSIZE 32760
OPTION LRECL 80
OPTION CHAR

The OPTION statements specify the options for the PRINT command such as the output format, the presence of header and trailer records, the location of the trailer record, the block size, and the record length. The control file allows you to customize the PRINT command options without modifying the JCL or the IDCAMS control statements.

Print VSAM records with selection criteria

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  PRINT INFILE(VSAM.FILE.NAME) -
        CHAR SELECT((1,5,CH,EQ,C'ABC'))
/*

In this example, only the records in the VSAM file named VSAM.FILE.NAME that have the value ‘ABC’ in the first five characters are printed in character format.

The SELECT parameter specifies the selection criteria for the PRINT command using a format of (position,length,type,operator,value). You can use multiple SELECT parameters to specify complex selection criteria.

These are just a few examples of how to use the PRINT command with IDCAMS to print VSAM data. It’s important to consult the IDCAMS documentation and work with your mainframe system administrators to ensure that you are using the command correctly and effectively.

Summary

In summary, the IDCAMS PRINT command can be used to print VSAM records in different formats, including character, hexadecimal, and packed decimal. The command supports various options such as header and trailer records, sorting, and selection criteria. The PRINT command can be invoked in batch mode from JCL or interactively from the command line. Additionally, the PRINT command can use a control file to customize the output format and options. It’s important to refer to the IDCAMS documentation and consult with your mainframe system administrators to ensure that you are using the PRINT command correctly and effectively.

VSAM Tutorials

VSAM Define Cluster: Click Here IBM Reference: Click Here

Admin

Share
Published by
Admin

Recent Posts

Increase Transparency and Collaboration Product Backlog

A well-maintained product backlog is crucial for successful product development. It serves as a single…

2 months ago

Product Backlog – Incremental value to the customer

Incremental value to the customer refers to the gradual delivery of small, functional parts of…

2 months ago

Product Market, Customer’s Desire, Need, and Challenges

A Product Market refers to the group of potential customers who might be interested in…

2 months ago

PAL-EBM Professional Agile Leadership – EBM Certification

The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…

5 months ago

PAL I Professional Agile Leadership Certification

The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…

5 months ago

Scrum Master Certification: CSM, PSM, SSM

Choosing the right Scrum Master Certification depends on your current experience and career goals. If…

7 months ago