Today one of my colleague asked if I could help her to put together a JCL to copy all the members in a PDS to a PS file, and she wanted to maintain the order alphabetically. Some of the utilities that will immediately come to your mind will be IEBGENER, IEBPTPCH, IDCAMS, IEHMOVE ,IEBCOPY etc. But none of these had a straightforward way to do it. The google search revealed that there is no blog in the internet which explains the steps properly. So I decided to write this blog to achieve this in few simple steps.

You can use some simple IBM utilities and Sort to achieve this. Here are the steps!

Step1:

Get the full member list of the PDS you are interested in.

//LISTNAME EXEC PGM=IEHLIST
//SYSPRINT DD DISP=(NEW,CATLG),DSN=YOUR.STEP1.OUTPUT,
// SPACE=(CYL,(150,150),RLSE),
// DCB=(LRECL=133,RECFM=FB,BLKSIZE=0)
//DD1 DD DSN=YOURPDS.NAME,DISP=OLD
//SYSIN DD *
LISTPDS DSNAME=YOURPDS.NAME,VOL=SYSDA=SMXXXX

Note: Specify the volume name of the PDS in the place of SMXXXX.

Step2:

Execute Sort and create the control card for member list to be used with IEBPTPCH.

//MEMLIST EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=YOUR.STEP1.OUTPUT
//SORTOUT DD DISP=(NEW,CATLG),DSN=YOUR.STEP2.OUTPUT,
// SPACE=(CYL,(150,150),RLSE),
// DCB=(*.SORTIN)
//SORTWK01 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE)
//SORTWK02 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE)
//SORTWK03 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE)
//SYSIN DD *
SORT FIELDS=COPY,SKIPREC=5
OMIT COND=(12,1,CH,EQ,C’ ‘)
OUTREC FIELDS=(1:2X,3:C’MEMBER NAME=’,15:12,7,59X)

Note: Input is previous steps output (YOUR.STEP1.OUTPUT) and output is the interim member list card which will be used in the later steps.

Output for this step will be something like this:

MEMBER NAME=member1
MEMBER NAME=member2
MEMBER NAME=member3
MEMBER NAME=member4

Step3:

Simple sort step to create another piece of the IEBPTPCH control card

//CTLCARD EXEC PGM=SORT
//SORTIN DD *
PUNCH TYPORG=PO,MAXNAME=4
//SORTOUT DD DSN=YOUR.STEP3.OUTPUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE)
//SORTDIAG DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY

Note: The MAXNAME parameter should contain the exact number of members identified in the previous step.

Step4:

Create the final SYSIN control card required for IEBPTPCH.

Concatenate the output of step3 and step2 to get the final control card.

//FINALC EXEC PGM=SORT
//SORTIN DD DSN=YOUR.STEP3.OUTPUT,DISP=SHR
// DD DSN=YOUR.STEP2.OUTPUT,DISP=SHR
//SORTOUT DD DSN=YOUR.STEP4.OUTPUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE)
//SORTDIAG DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY

Step5:

Execute IEBPTPCH to create an unformatted sequential file using the final control card from step4 in SYSIN.

//IEBPTPCH EXEC PGM=IEBPTPCH
//SYSUT1 DD DSN=YOURPDS.NAME,DISP=SHR
//SYSUT2 DD DISP=(NEW,PASS),DSN=&&TEMP,
// SPACE=(CYL,(150,150),RLSE),
// DCB=(LRECL=81,RECFM=FB,BLKSIZE=0)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=YOUR.STEP4.OUTPUT,DISP=SHR

Use the pass file in the final step , You are almost there, just one more step!!

Step6:

Execute SORT to OMIT “MEMBER NAME” record and use Outrec to format the final output file.

//SORTIT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD DISP=(OLD,DELETE),DSN=&&TEMP
//SORTOUT DD DISP=(NEW,CATLG),DSN=YOUR.STEP6.FINAL.OUTPUT,
// SPACE=(CYL,(150,150),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=(2,12,CH,EQ,C’MEMBER NAME ‘)
OUTREC FIELDS=(2,80)

I hope this blog becomes a one stop place for folks who are looking to copy all/selected members from PDS to a sequential dataset which is properly formatted . I hope you found it useful.

Leave a Reply

Your email address will not be published. Required fields are marked *