IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort Sorting problem


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Wed Sep 22, 2010 9:14 am
Reply with quote

Input file (sequential 240 bytes))
------------------------------
152020100729922
252020100729000000711920 300013400PHARMACY #00918
3000005064729431105673350201007262010072620100726193208030
452020100729000000711920 300013400000000000000000001000000
252020100729000000714724 300016700PHARMACY #00910
3000005065031191109237200201007282010072820100728193194542
452020100729000000714724 300013400000000000000000001000000
252020100729000001001267 300013400PHARMACY #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
252020100729000000711920 300013400PHARMACY #00918
3000005064729431105673350201007262010072620100726193208030
452020100729000000711920 300013400000000000000000001000000
252020100729000001001267 300013400PHARMACY #00918
3000005065090521100563970201007282010072820100728193200107
3000005065090581200563970201007282010072820100728193200107
452020100729000001001267 300003997000000000000000002000000
252020100729000000714724 300016700PHARMACY #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
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Thu Sep 23, 2010 5:05 am
Reply with quote

anybody with any ideas on how to go about it ??
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Sep 23, 2010 5:29 am
Reply with quote

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
View user's profile Send private message
prahalad

New User


Joined: 14 Sep 2010
Posts: 18
Location: Pune

PostPosted: Thu Sep 23, 2010 12:38 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Sep 23, 2010 7:14 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Sep 24, 2010 5:25 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Sep 24, 2010 7:58 pm
Reply with quote

Thanks Arun icon_smile.gif

I had hopes that you might see this topic icon_wink.gif

Have a great weekend,

d
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Sep 26, 2010 2:02 am
Reply with quote

Hi Dick, You're welcome. And I wish you the same icon_smile.gif

I was away from the forums for a while. icon_sad.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
Search our Forums:

Back to Top