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

Tricky sort logic required


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pgopi92

New User


Joined: 29 Oct 2014
Posts: 3
Location: india

PostPosted: Mon Jan 25, 2016 3:29 pm
Reply with quote

Hi Friends,

In want sort card which meets the below condition.

Input file:
Code:
3777345820160121123819HDR   
3777345820160121123819SHP011
3777345820160121123819SHPA21
3777345820160121123819SHP031
3777345820160121123819SHP038
3777345820160121123819SHP0AA
3777348020160121124214HDR   
3777348020160121124214SHP042
3777348020160121124214SHPA48
3777348020160121124214SHP011
3777348020160121124214SHP031


In input file many HDR records would be present followed by detail records (SHP) here my requirement would be
1) I Just want to sort detail records that to last field i.e 031 should come first rest detail records i don't care. As like below output file

output file would be like this:
Code:
3777345820160121123819HDR   
3777345820160121123819SHP031
3777345820160121123819SHPA21
3777345820160121123819SHP0AA
3777345820160121123819SHP011
3777345820160121123819SHP038
3777348020160121124214HDR   
3777348020160121124214SHP031
3777348020160121124214SHPA48
3777348020160121124214SHP011
3777348020160121124214SHP042


Appreciate you help.

Code'd and de-emphasised
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7311
Location: Inside the Matrix

PostPosted: Mon Jan 25, 2016 3:51 pm
Reply with quote

It's not tricky at all. You need a three-byte temporary extension to each record, which will contain your minor sort-key. Since you don't care about the order of the other records, you can just set this minor-sort key to the value with WHEN=INIT, and use WHEN=(logicalexpression) to test for 031 and set it to, for instance, X'000000'.

Sort on your key, followed by minor key. In OUTREC or OUTFIL return record to original size.
Back to top
View user's profile Send private message
pgopi92

New User


Joined: 29 Oct 2014
Posts: 3
Location: india

PostPosted: Mon Jan 25, 2016 5:16 pm
Reply with quote

Hi Bill,

Thanks much for your advise,

It would be more grateful if you provide the sort card.
Back to top
View user's profile Send private message
pgopi92

New User


Joined: 29 Oct 2014
Posts: 3
Location: india

PostPosted: Mon Jan 25, 2016 5:47 pm
Reply with quote

Thank much Bill,

I have done with the help of yours...

INREC IFTHEN=(WHEN=INIT,
OVERLAY=(2679:C'C')),
IFTHEN=(WHEN=(631,3,CH,EQ,C'031'),
OVERLAY=(2679:C'B')),
IFTHEN=(WHEN=(023,3,CH,EQ,C'HDR'),
OVERLAY=(2679:C'A'))
SORT FIELDS=(26,5,A,1,8,A,9,14,D,2548,6,A,2585,7,A,2679,1,A),
FORMAT=CH,EQUALS
OUTREC BUILD=(1:1,2679)

Thank you soooo much for you advise.. icon_biggrin.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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Date conversion using SORT SYNCSORT 4
No new posts Which SORT utility can improve the Pe... DFSORT/ICETOOL 16
No new posts Using sort on VB records based on off... DFSORT/ICETOOL 6
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts Copying data from prev record using SORT SYNCSORT 19
Search our Forums:

Back to Top