|
View previous topic :: View next topic
|
| Author |
Message |
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
| Thanks Frank, Your solution worked perfectly for me. Thanks a ton again. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|