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

SORT file agianst two fields


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Tue Mar 10, 2009 9:01 pm
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

Moderator Emeritus


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

PostPosted: Tue Mar 10, 2009 9:19 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top