View previous topic :: View next topic
|
Author |
Message |
sthirumalai
New User
Joined: 14 Aug 2007 Posts: 14 Location: Chennai
|
|
|
|
Hi
I have a FB byte file of length 80 Bytes.
first 10 bytes have account number and starting from 11 to 18 we got the transaction amount.
The file is sorted on account number and transaction amount ascending.
I have to fetch first 10 transactions under each account number and I have to skip the rest of the records under the account number till the next account number is obtained.
Please note that an account number may also have less than 10 transactions. In that case I need all those records under the account number to be extracted.
Is there any way to do this using DFsort?
Thanks & Regards
Santhosh |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
sthirumalai,
Use this DFSORT/ICETOOL JCL
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
----+----1----+----2----+----3----+----4----+----5----+----6
KEY1 01
KEY1 02
KEY1 03
KEY1 04
KEY1 05
KEY1 06
KEY1 07
KEY1 08
KEY1 09
KEY1 10
KEY1 11
KEY1 12
KEY1 13
KEY1 00
KEY2 12
KEY2 10
KEY2 00
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,10,CH) FIRST(10) USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(01,10,CH,A,
11,08,ZD,A)
//* |
|
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Kolusu,
Quote: |
The file is sorted on account number and transaction amount ascending. |
Do we need to resort the file? Wouldn't below suffice the requirement?
Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,10),PUSH=(81:SEQ=8))
SORT FIELDS=COPY
OUTFIL INCLUDE=(81,8,ZD,LE,10),BUILD=(1,80)
//* |
OR
Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,10)))
SORT FIELDS=COPY
OUTFIL INCLUDE=(81,8,ZD,LE,10),BUILD=(1,80)
//* |
Thanks, |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Sqlcode1 wrote: |
Do we need to resort the file? Wouldn't below suffice the requirement? |
Hmm I assumed that the sort need to be done and then pick the first 10. Well if the data is already sorted then he can simply replace CTL1CNTL with this.
Code: |
//CTL1CNTL DD *
SORT FIELDS=COPY
//* |
Now the question arises as to why the data is sorted in a different step when everything can be done in 1 pass.
I usually prefer SELECT for such operations instead of appending the key at the end and then having to change if there is change in the LRECL or RECFM. With SELECT operator there is no change at all. |
|
Back to top |
|
|
sthirumalai
New User
Joined: 14 Aug 2007 Posts: 14 Location: Chennai
|
|
|
|
Hi Kolusu/Sqlcode,
Thanks for your help
Both the solution works 100%.
Regards
Santhosh |
|
Back to top |
|
|
|