Page 1 of 1

Tape File Reload

PostPosted: Tue Apr 12, 2022 10:09 am
by [stranger]
We are taking the tape backup of a master file on daily basis by simply doing the MOD. At the end of the month, we will have one file with each day of the file in it i.e. Jan tape file will have 31 days data. This file contains Header and many details records. So a typical backup file would appear as follows..
HDR...
DTL...
DTL...
DTL...
HDR...
DTL...
DTL...
HDR...
DTL...
and so on.

The requirement now is to extract specific day's file from this tape backup. Lets say, we need 3rd day's file in that month, then we should extract the 3rd header and the respective detail records. How can we achieve this using JCL?

Re: Tape File Reload

PostPosted: Tue Apr 12, 2022 2:01 pm
by willy jensen
If you really are using DISP=MOD then you will only have one dataset on the tape with each day's data just appended to the previous data.
One way to go is to write to individual datasets on the the tape using the LABEL parameter.
i.e.:
//OUT DD DISP=(,CATLG),DSN=day.dataset.name,UNIT=TAPE,VOL=SER=vvvvvvv,LABEL=n
where the 'n' in LABEL increases by 1 for each day. You could also have the datasetname reflect the month and day. You really should do the latter, or else you can only use the CATLG parameter for the first day of the month.
Then you read the dataset by datasetname if the datasetname reflects month and day and is cataloged:
//IN DD DISP=OLD,DSN=day.dataset.name
or by label if the datasetname does not reflect month and day, or is not cataloged
//IN DD DISP=OLD,DSN=day.dataset.name,UNIT=TAPE,VOL=SER=vvvvvv,LABEL=n

All this is because you asked about a JCL based solution. A different method is to insert a delimiter line before or after each day, then use that delimiter to locate the actual day's data. Unles of course the data already has some recognizable start and end. But that is a program solution, not JCL.

Re: Tape File Reload

PostPosted: Tue Apr 12, 2022 5:30 pm
by [stranger]
Thank You for your quick response Willy.

Yes the dataset uses CATLG every 1st run of the month. Every month has a seperate tape file accumulated.

Re: Tape File Reload

PostPosted: Tue Apr 12, 2022 5:48 pm
by willy jensen
In that case you could perhaps use a scheme like this:
On the first day of the month use
//OUT DD DISP=(,CATLG,DELETE),UNIT=TAPE,
// DSN=TAPEDS.Y&LYR4..M&MON..D&DAY
for the rest of the month use
//OUT DD DISP=(,CATLG,DELETE),UNIT=TAPE,LABEL=&DAY,
// DSN=TAPEDS.Y&LYR4..M&MON..D&DAY,
// VOL=REF=TAPEDS.Y&LYR4..M&MON..D01

The variables &LYR4, &MON and &DAY have been available for years now.
You must of course introduce some housekeeping to uncatalog datasets after the tape is reused. Or datasets for day 2 and onwards could be uncataloged and referenced using the VOL=REF=dataset parameter as shown.

Re: Tape File Reload

PostPosted: Wed Apr 13, 2022 6:40 pm
by sergeyken
[stranger] wrote:The requirement now is to extract specific day's file from this tape backup. Lets say, we need 3rd day's file in that month, then we should extract the 3rd header and the respective detail records. How can we achieve this using JCL?

Again, and again, and again, and again:
One cannot achieve this using JCL.
The simplified example: you cannot wash your clothes using electricity; but you can use a washing machine which in turn is driven by electricity!

You can do this task in multiple ways, with only exception of JCL, and HTML :mrgreen:

1) Use SORT utility (e.g. SYNCSORT, or DFSORT)
2) Use FileAid utility
3) Use FileManager utility
4) Use a REXX script to handle your data properly
5) Use any of 100,500 programming languages you are familiar with
6) Use one of 1,000,000 of more exotic tools

Re: Tape File Reload

PostPosted: Wed Apr 13, 2022 6:51 pm
by enrico-sorichetti
One cannot achieve this using JCL.


probably the people asking here have into their DNA to call anything that is not a cobol program JCL

it is a war that we will never win

Re: Tape File Reload

PostPosted: Wed Apr 13, 2022 7:01 pm
by sergeyken
Re: SORT utility.
In order to select the group of records by its sequential number you can do it in this manner (not JCL!!!)
. . . . . .
// EXPORT SYMLIST=*
// SET DAYNUM=22
//. . . . . . . .
//SELGROUP EXEC PGM=SORT
//. . . . .
//SYSIN   DD  *,SYMBOLS=EXECSYS
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(1000:ID=5))
 SORT FIELDS=COPY
 OUTFIL INCLUDE=(1000,5,ZD,EQ,&DAYNUM),    choose the group by day number
        BUILD=(1,nnnn)            truncate to the original record size
 END
//*