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

Sort groups seperately based on different keys


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

New User


Joined: 25 Mar 2008
Posts: 10
Location: india

PostPosted: Tue Mar 25, 2008 6:18 pm
Reply with quote

I have a input file with a mix of records which falls into 5 major groups based on a particular field. I need to sort each group seperately based on different keys. how can i do this?

SAMPLE INPUT
B Y 100
A H 150
D G 120
B K 50
C G 120
A H 125
D Y 175
A G 125
C K 145
C Y 175


OUTPUT REQ

C G 120
C K 145
C Y 175
B K 50
B Y 100
A G 125
A H 125
A H 150
D G 120
D Y 175

The output must be grouped based on some keys. in the example its the first field. there are 4 groups and i need in the order C,B,A,D. i am using dfsort
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 6:58 pm
Reply with quote

Hi Vinod,

You can use following sort card for these specific group & order

Code:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'4')),             
        IFTHEN=(WHEN=(1,1,CH,EQ,C'C'),OVERLAY=(81:C'1')),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),OVERLAY=(81:C'2')),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),OVERLAY=(81:C'3')) 
  SORT FIELDS=(81,1,CH,A)                                 
** REMOVE 81ST BYTE                                       
  OUTREC BUILD=(1,80)   


Frank can give you more optimum solution.
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 25, 2008 9:09 pm
Reply with quote

Vinod,

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
B Y 100
A H 150
D G 120
B K  50
C G 120
A H 125
D Y 175
A G 125
C K 145
C Y 175
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Switch A and C so order for sorting is C,B,A,D.
  ALTSEQ CODE=(C3C1,C1C3)
* Specify AQ for first field so ALTSEQ table is used.
  SORT FIELDS=(1,1,AQ,A,3,1,CH,A,5,3,ZD,A)
/*
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top