Tape File Reload



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Tape File Reload

Postby [stranger] » Tue Apr 12, 2022 10:09 am

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?
[stranger]
 
Posts: 2
Joined: Tue Apr 12, 2022 9:45 am
Has thanked: 1 time
Been thanked: 0 time

Re: Tape File Reload

Postby willy jensen » Tue Apr 12, 2022 2:01 pm

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.

These users thanked the author willy jensen for the post:
[stranger] (Tue Apr 12, 2022 5:30 pm)
willy jensen
 
Posts: 380
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 53 times

Re: Tape File Reload

Postby [stranger] » Tue Apr 12, 2022 5:30 pm

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.
[stranger]
 
Posts: 2
Joined: Tue Apr 12, 2022 9:45 am
Has thanked: 1 time
Been thanked: 0 time

Re: Tape File Reload

Postby willy jensen » Tue Apr 12, 2022 5:48 pm

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.
willy jensen
 
Posts: 380
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 53 times

Re: Tape File Reload

Postby sergeyken » Wed Apr 13, 2022 6:40 pm

[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
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times

Re: Tape File Reload

Postby enrico-sorichetti » Wed Apr 13, 2022 6:51 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2976
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 160 times

Re: Tape File Reload

Postby sergeyken » Wed Apr 13, 2022 7:01 pm

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
//*
 
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 278
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 5 times
Been thanked: 25 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post