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?
Tape File Reload
-
- Posts: 2
- Joined: Tue Apr 12, 2022 9:45 am
- Skillset: JCL, COBOL
- Referer: Google Search
-
- Posts: 474
- Joined: Thu Mar 10, 2016 5:03 pm
- Skillset: assembler rexx zOS ispf racf smf
- Referer: saw it in the experts foprum thought I could help here
Re: Tape File Reload
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.
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.
-
- Posts: 2
- Joined: Tue Apr 12, 2022 9:45 am
- Skillset: JCL, COBOL
- Referer: Google Search
Re: Tape File Reload
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.
Yes the dataset uses CATLG every 1st run of the month. Every month has a seperate tape file accumulated.
-
- Posts: 474
- Joined: Thu Mar 10, 2016 5:03 pm
- Skillset: assembler rexx zOS ispf racf smf
- Referer: saw it in the experts foprum thought I could help here
Re: Tape File Reload
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.
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.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Tape File Reload
[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

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.
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: Tape File Reload
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
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
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Tape File Reload
Re: SORT utility.
In order to select the group of records by its sequential number you can do it in this manner (not JCL!!!)
In order to select the group of records by its sequential number you can do it in this manner (not JCL!!!)
Code: Select all
. . . . . .
// 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.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
How to add new TAPE=359L into OAM,RMM.
by curious_man » Thu Nov 04, 2021 8:02 pm » in All other IBM Tools - 1
- 2094
-
by curious_man
View the latest post
Mon Nov 08, 2021 8:15 pm
-
-
- 1
- 5324
-
by Robert Sample
View the latest post
Tue Oct 04, 2022 7:36 pm
-
-
EZIOE004 Logical I/O error on file occurred reading VB file
by savitha_y » Mon Feb 15, 2021 7:54 pm » in CA-Easytrieve - 3
- 4958
-
by savitha_y
View the latest post
Wed Feb 17, 2021 5:02 am
-
-
-
File Handling 3 input files and 1 output file by using EZT
by pavan426 » Thu Sep 09, 2021 12:17 am » in CA-Easytrieve - 0
- 4418
-
by pavan426
View the latest post
Thu Sep 09, 2021 12:17 am
-
-
-
Need to check whether file is ESDS file or not by using REXX
by Devrana » Sat Oct 05, 2024 2:28 pm » in CLIST & REXX - 6
- 3140
-
by sergeyken
View the latest post
Tue Oct 08, 2024 5:25 pm
-