View previous topic :: View next topic
|
Author |
Message |
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
Hi,
My input file (LRECL=80, RECFM=FB) has several records among which I want to pick records with MAX value present in it.
Input:
Code: |
RECORDA01840
RECORDA01842
RECORDA01846
HOSANNA00001
HOSANNA00005
HOSANNA00006
HOSANNA00008
|
Expected Output:
Code: |
RECORDA01846
HOSANNA00008
|
How to achieve it? Please help.
Thanks. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Do you need the output as in the same order of input file?? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Please try and let us know the results.
Code: |
//TOOLIN DD *
SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(8,5,ZD,D) |
|
|
Back to top |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
wow.....thanks. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Gnana Sekaran Nallathambi,
This control card wont work properly
for input like this
Code: |
RECORDA01840
RECORDA01842
RECORDA01846
HOSANNA90001
HOSANNA00005
HOSANNA00006
HOSANNA90008
|
|
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Okay, Prem.
If ramsri confirms that is also a possible case and the desired output, please post SORT cards for the same. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hi Ramsri,
This should help you if you need to retain the order
Code: |
//OUTPUT DD DSN=&C2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUTPUT2 DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(INPUT) TO(OUTPUT) ON(1,7,CH) FIRST USING(CTL1)
COPY FROM(OUTPUT) TO(OUTPUT2) USING(CTL2)
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(1,7,CH,A,8,5,ZD,D)
//CTL2CNTL DD *
SORT FIELDS=(81,8,ZD,A)
OUTREC FIELDS=(1:1,80)
|
Hi Gnana,
You need to make use of feven 1,7 in your CTL1 so that the key doesnt get split into different sets and also the below code doesnt have the same order of input
Code: |
//TOOLIN DD *
SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(1,7,CH,A,8,5,ZD,D) |
|
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi Gnana,
Your solution is nice. But I think this
Quote: |
//TOOLIN DD *
SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(8,5,ZD,D) |
needs to be changed to
Code: |
//TOOLIN DD *
SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(1,7,CH,A,8,5,CH,D)
/* |
Edited :S did not see previous post. contention |
|
Back to top |
|
|
ramsri
Active User
Joined: 18 Oct 2008 Posts: 380 Location: India
|
|
|
|
thanks for all the responses. |
|
Back to top |
|
|
|