IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to copy first n generations into a single file?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Mon May 17, 2010 3:05 pm
Reply with quote

Hi,

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 .

AAA.BBB.CCC.G0001V00
AAA.BBB.CCC.G0002V00
.
.
.
AAA.BBB.CCC.G00020V00
.
.
AAA.BBB.CCC.G0030V00

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?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon May 17, 2010 3:48 pm
Reply with quote

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.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon May 17, 2010 3:53 pm
Reply with quote

OK, let's take a stroll down "crazy requirements lane".

Why not just process the whole GDG base in one hit. Why the requirement for 20 gens.
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Mon May 17, 2010 4:04 pm
Reply with quote

Hi,

Quote:


Why not just process the whole GDG base in one hit. Why the requirement for 20 gens?



This is our project requirement. during the first run of the job in a day, we have to process first 20 gens, if existing.

@ Superk,

Yeah exactly i want the same thing what you have mentioned.

Thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 17, 2010 4:37 pm
Reply with quote

same reason that the sysout from step 1 has to come from step 1.

standards, rule, regulations.
come on now! everybody get in step, just to get in step!!

It must be comforting for creators of inflexible standards to know that
no one will ever question anything.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon May 17, 2010 4:51 pm
Reply with quote

Hey Dick, Maybe we should say it's a project requirement to receive 20 euros per post that we make.

Anyway, going back to Kevins' solution, using IGGCSIRX returns the generations in order,so removes the need to sort them.

In fact, it can all be done within the same REXX exec, the generation part and the copy part.
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Mon May 17, 2010 5:13 pm
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon May 17, 2010 8:27 pm
Reply with quote

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. . .
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Tue May 18, 2010 9:50 am
Reply with quote

Hi Dick,

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
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 18, 2010 2:23 pm
Reply with quote

GaganGang,

The question still remains: Why is the job required to only process 20 gens?

why can't it process 21, or 121? What is so magical about 20?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 18, 2010 7:29 pm
Reply with quote

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?
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Wed May 19, 2010 9:23 am
Reply with quote

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


Thanks
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Wed May 19, 2010 11:25 am
Reply with quote

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
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top