Posted: Thu Dec 09, 2021 11:27 am Post subject: Merge Data from 3 files into a Single file
Hi Team,
I have one query related to DFSORT/ICETOOL.
We have three input files.
File 1. Having date
File 2. Having header, detail records and trailer. Trailer is having two counts of 5 bytes each. First starting from position 2 and second from 7th.
File 3. Having header, detail records and trailer. Trailer is having two counts of 5 bytes each. First starting from position 2 and second from 7th.
I want to have one output file where I will have date(10bytes) from first file, followed by sum of counts present in the trailer(5 bytes) of second file and sum of counts(5 bytes) present in the trailer of third file.
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
Posted: Thu Dec 09, 2021 1:16 pm Post subject:
Srishti Rawat,
Please use meaningful topics (don't use the language/forum name/PGM name for the topic). Use a descriptive Title to explain your problem.
I edited the title for you now.
Coming to your requirement, it can be done quite easily. Please answer the following questions.
1. What is the LRECL and RECFM of the all the 3 input files and desired output file?
2. How do you identify the trailer record? '9' in position 1?
3. Is there a chance the summation of the 5 byte counts may exceed ? what do you in that case? _________________ Kolusu
www.linkedin.com/in/kolusu
1. What is the LRECL and RECFM of the all the 3 input files and desired output file?
SR: LRECL: 200 RECFM: FB for 2nd and 3rd input files and LRECL:80, RECFM: FB for First input file and output file.
2. How do you identify the trailer record? '9' in position 1?
SR: Yes thats right.
3. Is there a chance the summation of the 5 byte counts may exceed ? what do you in that case?
SR: As per the requirement, output file layout is:
DATE 10 BYTES CHAR
FIRST COUNT 05 BYTES NUM
SECOND COUNT 05 BYTES NUM
FILLER SPACES 60 BYTES CHAR
So we are assuming that we will never encounter the scenario of counts exceeding 5 bytes.
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
Posted: Fri Dec 10, 2021 5:42 pm Post subject:
Srishti Rawat,
I guess I misunderstood your requirement incorrectly. I was under the impression that you wanted a vertical summation of 2 records, but from the looks of it you needed a horizontal summation.
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DISP=SHR,DSN=Your.Input.fb.200.file2
// DD DISP=SHR,DSN=Your.Input.fb.200.file3
/*
//INB DD DISP=SHR,DSN=your.input.fb80.date.file1
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(11,1,A)
JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F2:1,10,F1:1,10,F2:11,60)
/*
//JNF1CNTL DD *
** Only include the trailer records from file-2 and file-3
INCLUDE COND=(1,1,CH,EQ,C'9')
** Since we are only expecting 2 trailer records we stop after
** 2 RECORDS. File-2 trailer record will record number 1 and
** file-3 record will be record number 2
OPTION STOPAFT=2
** Now build the record initially with zero counts
INREC IFTHEN=(WHEN=INIT,
BUILD=(01:5C'0', $ Init-count-1 with zeros
06:5C'0', $ Init-count-2 with zeros
11:C'A', $ Matching key
12:SEQNUM,1,ZD, $ sequence each record
13:02,05, $ original count-1
18:07,05)), $ original count-2
** add counts for the file-2 trailer record
IFTHEN=(WHEN=(12,1,ZD,EQ,1), $ If Record-number = 1
OVERLAY=(01:13,05,ZD,ADD, $ Count-1 from file-2
18,05,ZD,M11, Count-2 from file-2
LENGTH=5)), = 5 BYTE TOTAL
** add counts for the file-3 trailer record
IFTHEN=(WHEN=(12,1,ZD,EQ,2), $ If Record-number = 2
OVERLAY=(06:13,05,ZD,ADD, $ Count-1 from file-3
18,05,ZD,M11, Count-2 from file-3
LENGTH=5)) = 5 BYTE TOTAL
** Now sum the counts so the counts are on one line
SUM FIELDS=(01,05,ZD, $ Sum count-1
06,05,ZD) $ Sum count-2
/*
//JNF2CNTL DD *
** Since date is on the first record we stop after reading 1 rec
OPTION STOPAFT=1
** Build the record
INREC BUILD=(01:1,10, $ Date
81:C'A') $ Matching key
/*
To explain how the code works JNF1CNTL will process the data as follows
After the first WHEN=INIT the record will look like this
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum