|
View previous topic :: View next topic
|
| Author |
Message |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
Hi,
I have a requirement to split a file based on the record counts.
This is a VB file (222 LRECL) with multiple header and trailer records.
I will have to split this file into two files - one with each group of records having more than 30,000 detail records and other file with each group of records less than equal to 30,000 detail records.
Each group has identical HDR/TRL (start pos-1) records.
For example,
XXXHDR
AAAAA
BBBBB
XXXTRL
XXXHDR
CCCCC
DDDDD
XXXTRL
XXXHDR
EEEEEE
XXXTRL
I did try using IF THEN and GROUP, but i am not sure of how to count the records within each header/trailer and write to a file based on this.
Please post your suggestions. Appreciate your support!! |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1424 Location: Bamberg, Germany
|
|
|
|
| Post what you have tried please. Use Code tags when doing so. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8X,5)),
IFTHEN=((WHEN=GROUP,BEGIN=(13,5,CH,EQ,C'XXXHD'),
IFTHEN=(WHEN=(13,3,CH,EQ,C'XXX'),
END=(13,4,CH,EQ,C'XXXT'),PUSH=(5:ID=8))
OUTFIL FNAMES=OUT1,INCLUDE=(5,8,ZD,LE,30000),BUILD=(1,4,13)
OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,4,13)
END |
Coded for you - this time. Next time do it yourself. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Coded for you - this time. Next time do it yourself. I am not sure if someone posted this message. This wasn't part of my response. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Quote: |
| I am not sure if someone posted this message. This wasn't part of my response. |
No it was not part of your response - you had been asked to explicitly use the code tags to present your data but you did not.The message indicates to others that you ignored a request. The code tags are there for a reason - use them. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1424 Location: Bamberg, Germany
|
|
|
|
@prynks91: Use the Code button above the input box when you start a code section and hit that again when finished to post code. Before you push the Submit button use preview to check what's about to be posted. Works like a charm.
If I have understood the request correctly you want to separate the data by distinguishing how many detail records are found. The split data however shall be with XXXHDR and XXXTRL records.
You may try the following sample (F1 and F2 must be identical):
| Code: |
//WHATEVER EXEC PGM=SORT,PARM='MSG=AP'
//SYSOUT DD SYSOUT=*
//F1 DD *
XXXHDR
AAAAA
BBBBB
XXXTRL
XXXHDR
CCCCC
DDDDD
XXXTRL
XXXHDR
EEEEEE
XXXTRL
/*
//F2 DD *
XXXHDR
AAAAA
BBBBB
XXXTRL
XXXHDR
CCCCC
DDDDD
XXXTRL
XXXHDR
EEEEEE
XXXTRL
/*
//LESS DD SYSOUT=*
//MORE DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=F1,FIELDS=(10,10,A),TYPE=F
JOINKEYS F2=F2,FIELDS=(10,10,A),TYPE=F
REFORMAT FIELDS=(F2:1,9,F1:20,4)
SORT FIELDS=(COPY)
OUTFIL FNAMES=(LESS),
INCLUDE=(10,4,PD,LT,+2),
BUILD=(1,9)
OUTFIL FNAMES=(MORE),
SAVE,BUILD=(1,9)
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:+0,PD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'XXXHDR'),
END=(1,6,CH,EQ,C'XXXTRL'),PUSH=(10:ID=10)),
IFTHEN=(WHEN=(1,3,CH,NE,C'XXX'),OVERLAY=(20:+1,PD,LENGTH=4))
SUM FIELDS=(20,4,PD)
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'XXXHDR'),
END=(1,6,CH,EQ,C'XXXTRL'),PUSH=(10:ID=10))
END
/* |
DD:LESS - Less than two data records
| Code: |
XXXHDR
EEEEEE
XXXTRL |
DD:MORE - Greater or equal two data records
| Code: |
XXXHDR
AAAAA
BBBBB
XXXTRL
XXXHDR
CCCCC
DDDDD
XXXTRL |
|
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
Thanks for the response Jeorg!
The input file is a single file in VB format (LRECL is 222)and having multiple HDR/TRL with detail records within each of them. I would need to count the detail records and write them with Header/Trailers in 2 output files.
Output file- 1 ---> with detail records less than equal to 30,000
Output file- 2 ---> with detail records more than 30,000 |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1424 Location: Bamberg, Germany
|
|
|
|
| The sample has the functionality you are looking for. If the logic is understood you can modify the snippet for your VB;222 dataset as input for DD:F1 and DD:F2 and adjust the fields/positions and HDR/TRL strings etc. accordingly. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Thank you so much Joerg!! |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| My input file is a single file and i cannot use the Join keys function. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3108 Location: NYC,USA
|
|
|
|
| Please write a program if this is difficult to understand. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| If you care to look closely you will see that Joerg's solution is using one dataset - it is being joined to itself. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Sure, Thank you! |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
Tried the below code after converting the file to FB format.
Having issues with incompatible LRECL in OUT1/OUT2
| Code: |
//SYSIN DD *
JOINKEYS F1=F1,FIELDS=(10,10,A),TYPE=F
JOINKEYS F2=F2,FIELDS=(10,10,A),TYPE=F
REFORMAT FIELDS=(F2:1,9,F1:20,4)
SORT FIELDS=(COPY)
OUTFIL FNAMES=(OUT1),
INCLUDE=(10,4,PD,LT,+2),
BUILD=(1,9)
OUTFIL FNAMES=(OUT2),
SAVE,BUILD=(1,9)
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:+0,PD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10)),
IFTHEN=(WHEN=(1,3,CH,NE,C'820'),OVERLAY=(20:+1,PD,LENGTH=4))
SUM FIELDS=(20,4,PD)
END
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10))
END
|
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3108 Location: NYC,USA
|
|
|
|
This topic should be locked .. it is simple to fix the issue reported above as well as just providing the sysin won’t help is to get you any help.
You must post back complete JCL and sysouts details. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//F1 DD DISP=SHR,DSN=XXXX.TST.G5615V
//F2 DD DISP=SHR,DSN=XXXX.TST.G5615V
//OUT1 DD DSN=XXX.TST.FILE1,
// DISP=(,CATLG,CATLG),
// DCB=(LRECL=218,RECFM=FB,BLKSIZE=0),
// SPACE=(TRK,(800,800),RLSE)
//OUT2 DD DSN=XXX.TST.FILE2,
// DISP=(,CATLG,CATLG),
// DCB=(LRECL=218,RECFM=FB,BLKSIZE=0),
// SPACE=(TRK,(800,800),RLSE)
//SYSIN DD *
JOINKEYS F1=F1,FIELDS=(10,10,A),TYPE=F
JOINKEYS F2=F2,FIELDS=(10,10,A),TYPE=F
REFORMAT FIELDS=(F2:1,9,F1:20,4)
SORT FIELDS=(COPY)
OUTFIL FNAMES=(OUT1),
INCLUDE=(10,4,PD,LT,+2),
BUILD=(1,9)
OUTFIL FNAMES=(OUT2),
SAVE,BUILD=(1,9)
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:+0,PD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10)),
IFTHEN=(WHEN=(1,3,CH,NE,C'820'),OVERLAY=(20:+1,PD,LENGTH=4))
SUM FIELDS=(20,4,PD)
END
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10))
END
|
Sysout is listed below
| Code: |
-JOINKEYS REFORMAT RECORD LENGTH= 13, TYPE = F
-OUT1 : RECFM=FB ; LRECL= 218; BLKSIZE= 32700
-OUT2 : RECFM=FB ; LRECL= 218; BLKSIZE= 32700
-OUT1 : DSNAME=XXX.TST.FILE1
-OUT2 : DSNAME=XXX.TST.FILE2
-OUT1 HAS INCOMPATIBLE LRECL
-OUT2 HAS INCOMPATIBLE LRECL
|
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3108 Location: NYC,USA
|
|
|
|
| Don't give any LRECL in DCB. Let syncsort allocates that and rerun after that. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
Thank you Rohit! the issue with LRECL got resolved.
But the output is not as expected. I am trying to get detail records less than equal to 25 into first output file. All the records are getting written into the second file instead.
Below is the code from SYSIN
| Code: |
JOINKEYS F1=F1,FIELDS=(10,10,A),TYPE=F
JOINKEYS F2=F2,FIELDS=(10,10,A),TYPE=F
REFORMAT FIELDS=(F2:1,218,F1:1,218)
SORT FIELDS=(COPY)
OUTFIL FNAMES=(OUT1),
INCLUDE=(10,4,PD,LT,+0025),
BUILD=(1,9)
OUTFIL FNAMES=(OUT2),
SAVE,BUILD=(1,9)
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:+0,PD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10)),
IFTHEN=(WHEN=(1,5,CH,NE,C'820HD',OR,1,4,CH,NE,C'820T'),
OVERLAY=(20:+1,PD,LENGTH=4))
SUM FIELDS=(20,4,PD)
END
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10))
END
|
|
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
Just tried with the below code and I am getting the desired results. The only issue i have here is the output is not with the complete LRECL(218). It is written with LRECL of 9 bytes.
| Code: |
JOINKEYS F1=F1,FIELDS=(10,10,A),TYPE=F
JOINKEYS F2=F2,FIELDS=(10,10,A),TYPE=F
REFORMAT FIELDS=(F2:1,9,F1:20,4)
SORT FIELDS=(COPY)
OUTFIL FNAMES=(OUT1),
INCLUDE=(10,4,PD,LT,+0100),
BUILD=(1,9)
OUTFIL FNAMES=(OUT2),
SAVE,BUILD=(1,9)
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:+0,PD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10)),
IFTHEN=(WHEN=(1,5,CH,NE,C'820HD',OR,1,4,CH,NE,C'820T'),
OVERLAY=(20:+1,PD,LENGTH=4))
SUM FIELDS=(20,4,PD)
END
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'820HD'),
END=(1,4,CH,EQ,C'820T'),PUSH=(10:ID=10))
END
|
Having issues with BUILD when i change it from 9 to 218. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3108 Location: NYC,USA
|
|
|
|
If you want LRECL 218 then change your BUILD to
for both OUTFILEs. |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Thanks Rohit! But I would need the 209 bytes data from the input record itself |
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
| Thanks Rohit! But i would like to retain the 209 bytes data from Input. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1424 Location: Bamberg, Germany
|
|
|
|
| Code: |
//DATASPLT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//F1 DD DISP=OLD,DSN=&SYSUID..VB222
//F2 DD DISP=OLD,DSN=&SYSUID..VB222
//LESS DD DISP=OLD,DSN=&SYSUID..VB222.LESS
//MORE DD DISP=OLD,DSN=&SYSUID..VB222.MORE
//SYSIN DD *
JOINKEYS F1=F1,FIELDS=(223,10,A),TYPE=V
JOINKEYS F2=F2,FIELDS=(223,10,A),TYPE=V
REFORMAT FIELDS=(F2:5,218,F1:233,4)
SORT FIELDS=(COPY)
OUTFIL FNAMES=(LESS),
INCLUDE=(219,4,PD,LE,+30000),
REMOVECC,FTOV,BUILD=(1,218)
OUTFIL FNAMES=(MORE),
SAVE,REMOVECC,FTOV,BUILD=(1,218)
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(233:+0,PD,LENGTH=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(5,5,CH,EQ,C'820HD'),
END=(5,4,CH,EQ,C'820T'),PUSH=(223:ID=10)),
IFTHEN=(WHEN=(5,3,CH,NE,C'820'),OVERLAY=(233:+1,PD,LENGTH=4))
SUM FIELDS=(233,4,PD)
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,5,CH,EQ,C'820HD'),
END=(5,4,CH,EQ,C'820T'),PUSH=(223:ID=10))
END
/* |
|
|
| Back to top |
|
 |
prynks91
New User
Joined: 20 Feb 2020 Posts: 14 Location: USA
|
|
|
|
Thank you Jeorge. This worked fine!
Thank you all for the suggestions!! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|