If a GDG has n generations (where n > 20). How to copy first 20 versions into a single file?
Actually my requirement is, Job A runs twice a day and is capable of processing 20 files at a time.
If input GDG has 30 generations, first run of Job A should process first 20 generations and delete the processed files. second run of Job A should process second set of 10 generations.
For example:
In the below case, Job A when it runs for the first time, it should copy G0001V00 - G0020V00 to a single file. Second run should copy G0021V00 - G0040V00 .
Can anybody please tell me how to do this as number of generations are changing dynamically and total number of generations present at some time are not known in advance?
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
Let's see if I got this.
You want to:
- Use LISTCAT to determine ALL of the existing generations.
- Sort that list by dataset name, in ascending order, limiting the output to the first 20 (or less) generations.
- Build the list of required DD statements for the subsequent job, all with DISP=(OLD,DELETE).
- Submit that job.
If the requirement seems to be crazy, sorry for this. But it was the requirement so i raised my query. Superk got exactly what i wanted. I wanted to do it in a JCL so i wanted to know how to create the DD statements dynamically for input GDG generations without using the REXX.
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Hello,
Quote:
If the requirement seems to be crazy
The "requirement" is not really a requirement. . . It is a rather poor excuse of a way to meet some requirement (as yet not posted).
Requirements come in 2 flavors - user requirements and technical requirements. This is neither - it is just what someone decided needs to be done.
If you proceed in this direction be ready to "fight fires" of missing or duplicated data periodically. What should happen when a "middle" generation is deleted between runs? What should happen when there are more than 40 generations ctaloged? And on and on. . .
Actually the job is required to process only 20 versions. This job is used for some billing purposes. we want to execute the job for 20 gens only. suppose a GDG is having 50 gens at some time then first run of this job shud pick 20 generations and delete these 20 generations, next run should also pick 20 generations and so on. suppose GDG is having 35 generations attached to it then first run should pick 20 generations and 2nd run should pick 15 generations. GDG generations won't have duplicates and as no other job will be processing these generations so no middel gen will get deleted, we want to delete only those gens whatever are processed.
Thanks
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
Hello,
Once upon a time i had a system that received this kind of info from 322 distribution and point-of-sale warehouses every day (sometimes more than one a day). Each input was cataloged as a +1 generation. Twice a day the entire gdg was read, copied, and processed and the cataloged entries deleted.
Why do you believe you need this "magic break" at 20?
First run of the job(that will process the GDG gens) will be kicked when there will be 20 gens of the GDG. so there was the need to process the 20 gens only.
And, now there is a change in the requirements. now, we have to process the 20 gens only everytime( not less than 20). so job processing the GDG gens will be kicked as long as the 20th gen is created.
We have created a jcl to process these 20 gens. please find below the jcl:
Code:
//****************************************
//* ****** LIST ALL THE VERSIONS *********
//****************************************
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD DSN=XXXXXX.GDG.LIST,
// DISP=(MOD,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(CYL,(10,10),RLSE)
//SYSIN DD *
LISTC LVL(XXXXXX.GDG.TEST) ALL
/*
//*******************************************
//* ***** EXTRACT THE FIRST 20 VERSIONS ******
//*******************************************
//STEP02 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=XXXXXX.GDG.LIST,
// DISP=SHR
//SORTOUT DD DSN=XXXXXX.GDG.REPRO,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(CYL,(10,10),RLSE),
// LRECL=80,RECFM=FB
//SYSIN DD *
SORT FIELDS=COPY,STOPAFT=20
INCLUDE COND=(6,7,CH,EQ,C'NONVSAM')
OUTFIL OUTREC=(1:C' REPRO IDS(',14:21,25,40:C') OFILE(SYSUT2)',
80:C' '),CONVERT
/*
//**************************************************************
//* *** COPY THE DATA FROM FIRST 20 VERSIONS TO A SINGLE FILE ***
//**************************************************************
//STEP03 EXEC PGM=IDCAMS
//SYSUT2 DD DSN=XXXXXX.GDG.MERGE,DISP=(MOD,CATLG),
// RECFM=FB,LRECL=80,
// UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=XXXXXX.GDG.REPRO,DISP=SHR
Before the requirement change, we had developed the jcl as given below:
Code:
//***********************************************************
//* DELETE PREVIOUS DATASET *
//***********************************************************
//IEFBR14A EXEC PGM=IEFBR14
//DEL001 DD DSN=OPERA12.TEST.FILE123,
// DISP=(MOD,DELETE,DELETE),
// SPACE=(TRK,0)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=Z
//***********************************************************
//* LIST THE MEMBERS OF GDG *
//***********************************************************
//IKJEFT01 EXEC PGM=IKJEFT01
//SYSTSPRT DD DSN=&&LIST1,
// DISP=(NEW,PASS,DELETE),
// SPACE=(TRK,(5,5),RLSE),
// DCB=(RECFM=FB,LRECL=133)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSTSIN DD *
LISTC ENT('GDG BASE NAME')
/*
//**********************************************************************
//* SORT1 - STEP WHICH WILL GET THE GDG GEN NAMES *
//**********************************************************************
//SORT1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&LIST1,
// DISP=SHR
//SORTOUT DD DSN=OPERA12.TEST12.PDS123(TEST),
// DISP=SHR
//SYSIN DD *
INCLUDE COND=(4,7,SS,EQ,C'NONVSAM')
SORT FIELDS=COPY
OUTREC BUILD=(1:17,44,73:SEQNUM,8,ZD)
/*
//**********************************************************************
//* SORT2 - STEP WHICH WILL CREATE THE SYSUT1 DYNAMICALLY IN MEMBER *
//* TEST1 *
//**********************************************************************
//SORT2 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=OPERA12.TEST12.PDS123(TEST),
// DISP=SHR
//SORTOUT DD DSN=OPERA12.TEST12.PDS123(TEST1),
// DISP=SHR
//SYSIN DD *
INREC IFTHEN=(WHEN=(73,8,ZD,EQ,+1),
BUILD=(1:C' //SYSUT1 DD DSN=',1,44,C',DISP=(OLD,DELETE)',80:X)),
IFTHEN=(WHEN=(NONE),
BUILD=(1:C' // DD DSN=',1,44,C',DISP=(OLD,DELETE)',80:X))
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,ENDREC=20,
BUILD=(1:1,17,18:18,62,SQZ=(SHIFT=LEFT),80:X)
/*
//**********************************************************************
//* SORT3 - STEP WHICH CREATES THE JCL TO MERGE THE GDG GENS *
//**********************************************************************
//SORT3 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//OPERA12J JOB (TST,1),'TEST',
// CLASS=T,
// MSGCLASS=X,
// MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//IEBGEN01 EXEC PGM=IEBGENER
// DD DSN=OPERA12.TEST12.PDS123(TEST1),
// DISP=SHR
// DD *
//SYSUT2 DD DSN=OPERA12.TEST.FILE123,
// DISP=(NEW,CATLG,DELETE),
// DCB=*.SYSUT1,
// SPACE=(CYL,(4,4),RLSE),
// AVGREC=U,VOL=(,,,59)
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTOUT DD DSN=OPERA12.TEST12.PDS123(TEST2),
// DISP=SHR
//SYSIN DD *
SORT FIELDS=COPY
OUTREC BUILD=(1:2,71,9X)
/*
//**********************************************************************
//* SUBJCL - THIS JCL IS USED FOR SUBMITTING A JCL *
//**********************************************************************
//SUBJCL EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
SUB 'OPERA12.TEST12.PDS123(TEST2)'
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//**********************************************************************
//* END OF THE JCL
//**********************************************************************
Here, we had used ENDREC, so even if the number of gens were less than 20 (before the requirement change, we may had to process less than 20 gens) , it could run the job successfully.
Thanks