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

Sort file based on this 5 byte field


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

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Wed Aug 18, 2010 3:58 am
Reply with quote

Hi All,

I have the following problem. I have records in a seq. file as given below.

1A23457658904532123 A2009
1B2345765890453 b2011
1N234576589045321237343734 A2009

1A23457645454532123 A2010
1B2345754243463 A2010
1N23457608095345234 b2011

I want to sort the file in such a way that the records come out like this:
All A2009 together, All A2010 togerther and so on..

1A23457658904532123 A2009
1N234576589045321237343734 A2009
1A23457645454532123 A2010
1B2345754243463 A2010
1B2345765890453 b2011
1N23457608095345234 b2011

The Issue here is that for record 1A, A2009 (5 byte field) starts at position 22, but for records 1N, it starts at position 29. This 5 byte field always occur at position 22 for records 1A and at position 29 for record 1N and so on. The field contians lots of different values. I want to sort the file based on this 5 byte field but it occurs at different positions for different records (1A,1N,1B ..so on)

Please help me on this.
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: Wed Aug 18, 2010 5:09 am
Reply with quote

You can use the DFSORT technique below to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes. You can add as many IFTHEN clauses as you need to handle the different record types.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1A23457658904532123  A2009
1B2345765890453  B2011
1N234576589045321237343734  A2009
1A23457645454532123  A2010
1B2345754243463  A2010
1N23457608095345234         B2011
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
   INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'1A'),OVERLAY=(81:22,5)),
         IFTHEN=(WHEN=(1,2,CH,EQ,C'1B'),OVERLAY=(81:18,5)),
         IFTHEN=(WHEN=(1,2,CH,EQ,C'1N'),OVERLAY=(81:29,5))
   OPTION EQUALS
   SORT FIELDS=(81,5,CH,A)
   OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Wed Aug 18, 2010 5:56 am
Reply with quote

Thanks a lot Frank,

I'll Try this tommorrow and get back to you... by the way my input file is of lrecl=240 and recfm=fb
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: Wed Aug 18, 2010 6:06 am
Reply with quote

Quote:
by the way my input file is of lrecl=240 and recfm=fb


Then the adjusted DFSORT job would be:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/240)
//SORTOUT DD DSN=...  output file (FB/240)
//SYSIN DD *
   INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'1A'),OVERLAY=(241:22,5)),
         IFTHEN=(WHEN=(1,2,CH,EQ,C'1B'),OVERLAY=(241:18,5)),
         IFTHEN=(WHEN=(1,2,CH,EQ,C'1N'),OVERLAY=(241:29,5))
   OPTION EQUALS
   SORT FIELDS=(241,5,CH,A)
   OUTREC BUILD=(1,240)
/*
Back to top
View user's profile Send private message
baljinders

New User


Joined: 21 Aug 2006
Posts: 72

PostPosted: Mon Aug 23, 2010 3:15 am
Reply with quote

Thanks Frank, Your solution worked perfectly for me. Thanks a ton again.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top