Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SORT file agianst two fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
gomu_mm

New User


Joined: 05 Dec 2006
Posts: 19
Location: Chennai

PostPosted: Tue Mar 10, 2009 4:18 pm    Post subject: SORT file agianst two fields
Reply with quote

Hi,

I have a file. I need to sort the file based on two field.

0001SGHP
0002SGDD
0003SGDP
0004SGHD

I want the file to be sorted on column 8 to have all 'P' first and then 'D'.
Then the file should be sorted to have SGHP, SGDP, SGDD and last SGHD. Basically the file should be in order

SGHP
SGDP
SGDD
SGHD


Thanks,
Gomathi.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Mar 10, 2009 9:01 pm    Post subject:
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
0001SGHP
0002SGDD
0003SGDP
0004SGHD
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(5,4,CH,EQ,C'SGHP'),OVERLAY=(81:C'0')),
        IFTHEN=(WHEN=(5,4,CH,EQ,C'SGDP'),OVERLAY=(81:C'1')),
        IFTHEN=(WHEN=(5,4,CH,EQ,C'SGDD'),OVERLAY=(81:C'2')),
        IFTHEN=(WHEN=(5,4,CH,EQ,C'SGHD'),OVERLAY=(81:C'3'))
  SORT FIELDS=(8,1,CH,D,81,1,CH,A)
  OUTREC BUILD=(1,80)
/*


Note that you would get the same result by just sorting on the second field.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Mar 10, 2009 9:19 pm    Post subject:
Reply with quote

Hello,

Quote:
Note that you would get the same result by just sorting on the second field.
Really icon_confused.gif

I also have the nagging feeling that the "rule" is to sort the 3-byte field ascending for the D's and descending for the P's. Maybe i'm reading too much into it. . . icon_neutral.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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 5 Sat Jan 21, 2017 4:02 am
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us