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

Sorting on text - but in non-alphabetic order


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Roy Ware

New User


Joined: 19 Sep 2013
Posts: 14
Location: USA

PostPosted: Wed Aug 23, 2017 9:15 pm
Reply with quote

Got a difficult one here - and yes, I did RTFM. icon_biggrin.gif

I have a file that is sorted on numeric values:
Code:

SORT FIELDS=(077,06,PD,A,         
             001,03,CH,A,         
             006,26,CH,A,         
             165,01,CH,A,         
             166,01,CH,A)         
OMIT COND=(145,06,CH,EQ,C'Driver',
        OR,145,06,CH,EQ,C'VehUse',
        OR,145,06,CH,EQ,C'Form ')
OPTION SIZE=E70000000,EQUALS     


The problem is that the source (over which I have no control) has the text fields - column 145, length of 6 - out of "order". "Proper" file order is:
Policy
Party
Coverage
Vehicle
Location
Discount

Instead, the source file has these scattered about in no particular order.

Does SYNCSORT (the product I'm stuck with, so don't suggest anything else!) allow some sort of user macro that can let me get these in the right order? If so, how?
Back to top
View user's profile Send private message
Roy Ware

New User


Joined: 19 Sep 2013
Posts: 14
Location: USA

PostPosted: Wed Aug 23, 2017 9:23 pm
Reply with quote

Yes, I've looked at ALTSEQ and it doesn't seem to fit the bill. I wish this was DB2!
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
Location: italy

PostPosted: Wed Aug 23, 2017 9:25 pm
Reply with quote

use IFTHEN to add somewhere in Your record a numeric sequence number
something along the lines of

Code:
 INREC  IFTHEN=(WHEN=(145,8,CH,EQ,C'Policy  '),OVERLAY=(somewhere:C'01')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Party   '),OVERLAY=(somewhere:C'02')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Coverage'),OVERLAY=(somewhere:C'03')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Vehicle '),OVERLAY=(somewhere:C'04')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Location'),OVERLAY=(somewhere:C'05')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Discount'),OVERLAY=(somewhere:C'06')),


just a sketch to give You the idea
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 924
Location: Maryland

PostPosted: Wed Aug 23, 2017 9:38 pm
Reply with quote

Roy Ware wrote:
Yes, I've looked at ALTSEQ and it doesn't seem to fit the bill. I wish this was DB2!

1) ALTSEQ is related to the sequence of used characters, not words!...
2) DB2 has nothing to do with this issue, too.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 924
Location: Maryland

PostPosted: Wed Aug 23, 2017 9:42 pm
Reply with quote

enrico-sorichetti wrote:
use IFTHEN to add somewhere in Your record a numeric sequence number
something along the lines of

Code:
 INREC  IFTHEN=(WHEN=(145,8,CH,EQ,C'Policy  '),OVERLAY=(somewhere:C'01')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Party   '),OVERLAY=(somewhere:C'02')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Coverage'),OVERLAY=(somewhere:C'03')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Vehicle '),OVERLAY=(somewhere:C'04')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Location'),OVERLAY=(somewhere:C'05')),
        IFTHEN=(WHEN=(145,8,CH,EQ,C'Discount'),OVERLAY=(somewhere:C'06')),


just a sketch to give You the idea


Since we don't know if any OVERLAY is allowed within the record, it would be safer to append new value at the end:
Code:
   ...WHEN=(...),BUILD=(1,167,C'1'),...     assign '1'-'6' in proper order


Also don't forget to add this new field to SORT field list:
Code:
 SORT FIELDS=(167,1,CH,A,..............) 
Back to top
View user's profile Send private message
Roy Ware

New User


Joined: 19 Sep 2013
Posts: 14
Location: USA

PostPosted: Wed Aug 23, 2017 10:52 pm
Reply with quote

It's a 2000 byte record with nothing at the end, so I overlaid the last 2 bytes with the sequence number - worked like a charm.

I mentioned DB2 because it has a lovely statement (Case?) I used to use to order things like this.

Thanks for all the help folks!
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Creating additional seqnum/Literal wh... DFSORT/ICETOOL 4
No new posts Combining more 4 files with sorted or... DFSORT/ICETOOL 3
No new posts how to show listing in physical locat... PL/I & Assembler 2
No new posts DFSORT Output file order query DFSORT/ICETOOL 2
No new posts ICETOOL Sorting and Discarding DUPS SYNCSORT 11
Search our Forums:

Back to Top