View previous topic :: View next topic
Author
Message
baljinders New User Joined: 21 Aug 2006Posts: 72
Input file (sequential 240 bytes))
------------------------------
152020100729922
2 52020100729000000711920 300013400 PHARMACY #00918
3000005064729431105673350201007262010072620100726193208030
452020100729000000711920 300013400000000000000000001000000
2 52020100729000000714724 300016700 PHARMACY #00910
3000005065031191109237200201007282010072820100728193194542
452020100729000000714724 300013400000000000000000001000000
2 52020100729000001001267 300013400 PHARMACY #00918
3000005065090521100563970201007282010072820100728193200107
3000005065090581200563970201007282010072820100728193200107
452020100729000001001267 300003997000000000000000002000000
55202010072992200008200000003960000014484880000000000
1 is the header record and 5 is the trailer.
We receive an input file with records as shown.
Byte 1 is the record type
Byte 26 to 34 is vendor number
Byte 47 to 49 is id
I want to sort the file in such a way that I get the below result. A batch starts when a new 2 is encountered. A batch is a combination of 2,3,4 record types. So in the example there are total 3 batches. I want to sort the file on vendor number and id such that the whole batch gets reorganized. i.e like in the input file, the 3rd batch start at record 8 but after sorting it starts from record 5.
152020100729922
2 52020100729000000711920 300013400 PHARMACY #00918
3000005064729431105673350201007262010072620100726193208030
452020100729000000711920 300013400000000000000000001000000
2 52020100729000001001267 300013400 PHARMACY #00918
3000005065090521100563970201007282010072820100728193200107
3000005065090581200563970201007282010072820100728193200107
452020100729000001001267 300003997000000000000000002000000
2 52020100729000000714724 300016700 PHARMACY #00910
3000005065031191109237200201007282010072820100728193194542
452020100729000000714724 300013400000000000000000001000000
55202010072992200008200000003960000014484880000000000
Is there any way for achieving this using syncsort? GROUP and PUSH functions are not recognized by the syncsort version we have.
Back to top
baljinders New User Joined: 21 Aug 2006Posts: 72
anybody with any ideas on how to go about it ??
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Then i believe you have 2 "things to do":
One - start whatever action is needed to get the current release of Syncsort installed/available.
Two - implement this using your programming language. It will be rather straightforward to build a sortkey to append to each record and then sort the file by this key. Then use the re-arranged file as needed.
Back to top
prahalad New User Joined: 14 Sep 2010Posts: 18 Location: Pune
You can do it using sort. Please use the following code for this.
Code:
INREC IFTHEN=(WHEN=INIT,BUILD=(1,240,C'000000000000')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,ZD,EQ,2),PUSH=(241:26,9,47,3)),
IFTHEN=(WHEN=(1,1,ZD,EQ,1),BUILD=(1,240,C'000000000000')),
IFTHEN=(WHEN=(1,1,ZD,EQ,5),BUILD=(1,240,C'999999999999'))
OPTION EQUALS
SORT FIELDS=(241,12,CH,A)
OUTFIL BUILD=(1,240)
Hope this will work.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Which part of "GROUP and PUSH functions are not recognized by the syncsort version we have " was not clear?.
When posting a "solution" care must be taken that the solution can be used by the person who made the request. . .
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
baljinders,
Since you dont have the latest Syncsort release, the below SYNCTOOL job might be of help.
Code:
//STEP1 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=Input file ---->FB/LRECL=240
//T1 DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA
//OUT DD DSN=Output file ---->FB/LRECL=240
//TOOLIN DD *
SPLICE FROM(IN) TO(T1) ON(241,8,CH) WITHALL WITH(1,240) KEEPNODUPS -
KEEPBASE USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(241:SEQNUM,8,ZD,257:12C'0')),
IFTHEN=(WHEN=(1,1,ZD,EQ,2),
OVERLAY=(241:SEQNUM,8,ZD,257:26,9,47,3)),
IFTHEN=(WHEN=(1,1,ZD,EQ,5),
OVERLAY=(257:12C'9')),
IFTHEN=(WHEN=NONE,
OVERLAY=(249:SEQNUM,8,ZD,241:249,8,ZD,SUB,241,8,ZD,M11,LENGTH=8))
//CTL2CNTL DD *
SORT FIELDS=(257,12,CH,A)
OUTFIL BUILD=(1,240)
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Thanks Arun
I had hopes that you might see this topic
Have a great weekend,
d
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi Dick, You're welcome. And I wish you the same
I was away from the forums for a while.
Back to top
Please enable JavaScript!