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 based on this 5 byte field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sort file based on this 5 byte field
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 Moderator


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

PostPosted: Wed Aug 18, 2010 5:09 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Aug 18, 2010 6:06 am    Post subject:
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    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am


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