View previous topic :: View next topic
Author
Message
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Hi All,
I have a file with a record identifier in each record @ 10th position.
Record identifiers are
Code:
01-Header
99-Trailer
10-Start of record
Data records are grouped until the availability of "10" or "99" in the next record
Original file needs to be split based on another identifier in Record type-10 -"A" -Addition, "U"-Updates, "D" - Deletes
After the split, each file should have a Trailer record similar to the one in original file along with the count of "10" type records
I am able to split the file into 3 different files but unable to get the count in the trailer record. Can anyone help.
Below is the code that I have written for split the files.
Code:
Input File: DCB=(LRECL=80,RECFM=FB)
//TOOLIN DD *
COPY FROM(IN) TO(TEMP) USING(CTL1)
COPY FROM(TEMP) TO(UPD,DEL) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),
PUSH=(81:16,1,
82:ID=8)),
IFTHEN=(WHEN=(10,2,CH,EQ,L(C'01',C'99')),
BUILD=(01:1,80,
81:1C'0',
82:8C'0'))
OUTREC IFTHEN=(WHEN=INIT,BUILD=(1:82,8,X,
10:81,1,X,
12:1,80))
SORT FIELDS=COPY
/*
//CTL2CNTL DD *
OUTFIL FNAMES=UPD,
INCLUDE=(10,1,CH,EQ,L(C'A',C'U',C'0')),
BUILD=(12,80)
OUTFIL FNAMES=DEL,
INCLUDE=(10,1,CH,EQ,L(C'D',C'0')),
BUILD=(12,80)
SORT FIELDS=COPY
/*
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
What's the starting position of first identifier:
Code:
01-Header
10-Start of record
99-Trailer
What's the starting position of another identifier:
Code:
"A" -Addition, "U"-Updates, "D" - Deletes
Can you post some sample input data and expected output?
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
First identifier is 2bytes starting at 10th position
Second identifier s 1byte starting at 16th position
Sample data
Code:
Header 01
DetailRec10DATAU
Detailrec20data
Detailrec30data
Detailrec40data
Detailrec10dataA
Detailrec20data
Detailrec30data
Detailrec10dataD
Detailrec20data
Detailrec30data
Detailrec40data
Detailrec50data
Detailrec10dataA
Detailrec20data
Detailrec30data
Trailer 99
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
I am able to get the output files, but without the trailer record + count of "10" type records
Expected Output Update file
Code:
Header 01
DetailRec10DATAU
Detailrec20data
Detailrec30data
Detailrec40data
Trailer 99 00001
Expected output Add file
Code:
Header 01
Detailrec10dataA
Detailrec20data
Detailrec30data
Detailrec10dataA
Detailrec20data
Detailrec30data
Trailer 99 00002
Expected output Delete file
Code:
Header 01
Detailrec10dataD
Detailrec20data
Detailrec30data
Detailrec40data
Detailrec50data
Trailer 99 00001
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Can someone help please with the approach or solution?
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
try something on the below lines.
Code:
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HEADER 01
DETAILREC10DATAU
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
DETAILREC10DATAD
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
DETAILREC50DATA
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
TRAILER 99
//F1 DD SYSOUT=*
//F2 DD SYSOUT=*
//F3 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(10,02,CH,EQ,L(C'10',C'01',C'99')),
PUSH=(81:16,1))
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(82:C'00000')),
IFTHEN=(WHEN=(16,1,CH,EQ,L(C'A',C'D',C'U')),
OVERLAY=(82:C'00001'))
OUTFIL INCLUDE=(81,1,CH,EQ,C'A'),FNAMES=F1,BUILD=(1,80),
REMOVECC,HEADER1=(1:'HEADER 01'),
TRAILER1=(1:'TRAILER 99',
15:TOT=(82,5,ZD,EDIT=(TTTTT)))
OUTFIL INCLUDE=(81,1,CH,EQ,C'U'),FNAMES=F2,BUILD=(1,80),
REMOVECC,HEADER1=(1:'HEADER 01'),
TRAILER1=(1:'TRAILER 99',
15:TOT=(82,5,ZD,EDIT=(TTTTT)))
OUTFIL INCLUDE=(81,1,CH,EQ,C'D'),FNAMES=F3,BUILD=(1,80),
REMOVECC,HEADER1=(1:'HEADER 01'),
TRAILER1=(1:'TRAILER 99',
15:TOT=(82,5,ZD,EDIT=(TTTTT)))
Output
F1
Code:
HEADER 01
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
TRAILER 99 00002
F2
Code:
HEADER 01
DETAILREC10DATAU
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
TRAILER 99 00001
F3
Code:
HEADER 01
DETAILREC10DATAD
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
DETAILREC50DATA
TRAILER 99 00001
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Thanks, mistah kurtz
The solution you have posted is working fine. TA.
Is there any way I can preserve the header and use it in all the output files. My header is around 150 in length, which I cannot format using HEADER1.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Yes, use AND in the INCLUDE=s.
You'll need to make sure it doesn't get included in the count, so set the count value to zero and locate the count at the end of the header or data record, whichever is longer. The count need only be one digit.
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
There should be some way, but I will have to think about that. Meanwhile you can write your header/trailer in more than one line like this:
Code:
HEADER1=(1:'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
50:'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
100:'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Thanks, Bill, mistah kurtz
I have OVERLAYed the header record using IFTHEN in INREC, and then INCLUDed in the 3 OUTFILs. This works fine.
Back to top
JAYACHANDRAN THAMPY New User Joined: 06 Jun 2006Posts: 8
If you are having Syncsort V1.4.2 , then you can use IFTRAIL parameter in OUTFIL statement to get the desired results. JCL listed below
Code:
//STEP010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HEADER 01
DETAILREC10DATAU
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
DETAILREC10DATAD
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
DETAILREC50DATA
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
TRAILER 99
//ADD DD SYSOUT=*
//UPD DD SYSOUT=*
//DEL DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),
PUSH=(151:16,1)),
IFTHEN=(WHEN=(10,2,CH,EQ,C'10'),OVERLAY=(152:C'0001')),
IFTHEN=(WHEN=NONE,OVERLAY=(152:C'0000'))
OUTFIL FNAMES=ADD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
TRLUPD=(16:TOT=(152,4,ZD,M11,LENGTH=4))),
INCLUDE=(151,1,CH,EQ,C'A'),BUILD=(1,150)
OUTFIL FNAMES=UPD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
TRLUPD=(16:TOT=(152,4,ZD,M11,LENGTH=4))),
INCLUDE=(151,1,CH,EQ,C'U'),BUILD=(1,150)
OUTFIL FNAMES=DEL,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
TRLUPD=(16:TOT=(152,4,ZD,M11,LENGTH=4))),
INCLUDE=(151,1,CH,EQ,C'D'),BUILD=(1,150)
//*
ADD Output
Code:
HEADER 01
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
DETAILREC10DATAA
DETAILREC20DATA
DETAILREC30DATA
TRAILER 99 0002
UPD Output
Code:
HEADER 01
DETAILREC10DATAU
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
TRAILER 99 0001
DEL output
Code:
HEADER 01
DETAILREC10DATAD
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
DETAILREC50DATA
TRAILER 99 0001
Code'd
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Thanks,
I was looking for the same and searched a couple of remaining post. Got IFTRAIL, tried and tested, working fine.
Where can I get the IFTRAIL documentation/manual?
We are using 1.4.2, but the manual available is still for 1.2
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Someone in your site is responsible for contact with SyncSort. Arrange that they gain access to the current manuals for everyone, or that they allow you to contact SyncSort support to do it yourself.
Sometimes new SyncSort features do not appear in the documentation for a while. Sometimes a long while.
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Hi Again,
Everything till this point was fine. I could get the manual but it has no documentation of IFTRAIL.
I have rearranged the startpos and length based on my requirement.
My I/P file is a VB of 18448. And hence I shifted any Overlays in the beginning by making a 10 byte space at the starting of each record.
Now, with this change, my header and trailer start with '0000' in the final output. Can this be avoided/handled?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
If you BUILD on OUTFIL to only include the data you want, that's the usual way for a variable-length record.
This says "make a new record, with 1,4 from the current record, and then position 15 to the end of the record, from the current record. Then make this new record the current record, replacing the previous current record".
Often when SyncSort play catch-up it is not included in the documentation. Perhaps we should start our own list...
Back to top
mistah kurtz Active User Joined: 28 Jan 2012Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
At our site, we have Syncsort 1.4.1 and I think it does not support IFTRAIL.
Code:
SYNCSORT FOR Z/OS 1.4.1.0R U.S. PATENTS: 4210961, 5117495 (C) 2010 SYNCSORT INC.
z/OS 2.1.0
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 2A807, MODEL 2827 503
SYSIN :
OPTION COPY
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),
PUSH=(81:16,1)),
IFTHEN=(WHEN=(10,2,CH,EQ,C'10'),OVERLAY=(82:C'0001')),
IFTHEN=(WHEN=NONE,OVERLAY=(82:C'0000'))
OUTFIL FNAMES=ADD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
*
TRLUPD=(16:TOT=(82,4,ZD,M11,LENGTH=4))),
INCLUDE=(81,1,CH,EQ,C'A'),BUILD=(1,80)
OUTFIL FNAMES=UPD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
*
TRLUPD=(16:TOT=(82,4,ZD,M11,LENGTH=4))),
INCLUDE=(81,1,CH,EQ,C'U'),BUILD=(1,80)
OUTFIL FNAMES=DEL,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
*
TRLUPD=(16:TOT=(82,4,ZD,M11,LENGTH=4))),
INCLUDE=(81,1,CH,EQ,C'D'),BUILD=(1,80)
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER268A OUTFIL STATEMENT : SYNTAX ERROR
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Completely agree with you, Bill.
I had done the same as you have suggested, but this is only applicable for details records; Header and Trailer are not getting impacted as we have used IFTRAIL, & HD=YES. H/T start with 0 (used in PUSH) followed by 4 more zeros.
I want to OVERLAY the records in the beginning because -
1) Want to maintain the length from the input record,
2) I could have used VLTRIM=X'40' but most of my input records end with x'40', and hence VLTRIM will not be helpful
Code:
000000 HEADER 01
DETAILREC10DATAU
DETAILREC20DATA
DETAILREC30DATA
DETAILREC40DATA
000000 TRAILER 99 0001
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
You need to give OUTFIL the formatted trailers that you want to see, and then change the count with the TRLUPD. So do a conditional BUILD, for the trailer only, in INREC (or OUTREC if that is what you are using).
Back to top
TS70363 New User Joined: 07 Apr 2010Posts: 94 Location: Bangalore, India
Thanks, Bill
Worked fine.
Back to top
Please enable JavaScript!