Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sorting on text - but in non-alphabetic order

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
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    Post subject: Sorting on text - but in non-alphabetic order
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    Post subject: Reply to: Sorting on text - but in non-alphabetic order
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10352
Location: italy

PostPosted: Wed Aug 23, 2017 9:25 pm    Post subject: Reply to: Sorting on text - but in non-alphabetic order
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 User


Joined: 29 Apr 2008
Posts: 212
Location: Maryland

PostPosted: Wed Aug 23, 2017 9:38 pm    Post subject: Re: Reply to: Sorting on text - but in non-alphabetic order
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 User


Joined: 29 Apr 2008
Posts: 212
Location: Maryland

PostPosted: Wed Aug 23, 2017 9:42 pm    Post subject: Re: Reply to: Sorting on text - but in non-alphabetic order
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    Post subject: Reply to: Sorting on text - but in non-alphabetic order
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us