Joined: 20 Jun 2003 Posts: 112 Topics: 48 Location: Bangalore
Posted: Wed May 05, 2004 5:21 am Post subject: insert using DFSORT/ICETOOL
Hi All,
I have a particular requirement that has to be met using DFSORT/ICETOOL.
The requirement is as below.
My Input File is as below
===========================
A1 AAA 4030
A1 CCC 2030
A1 DDD 5060
A1 GGG 6010
===========================
My output should be like below
===========================
A1 AAA 4030
A1 BBB 0000
A1 CCC 2030
A1 DDD 5060
A1 EEE 0000
A1 FFF 0000
A1 GGG 6010
===========================
ie my input file has records having a 3 byte values which can be only one of (AAA, BBB, CCC, DDD, EEE, FFF, GGG)
And if in my input file iam not having say 'BBB' i shud insert a record with 'BBB' and with counts 0000 (4 bytes)
In the above example we inserted the records with BBB, EEE and FFF.
In the above example 'A1' is the account number which is same for each record. We can have many other account numbers also like A2, A3 etc..but in each case we need to have all the 6 type of record sets ie. if a particular type of record (AAA, BBB, CCC, DDD, EEE, FFF, GGG) is not present for an account number we need to insert a new record for that account number with that missing type and with count as zeroes.
We can do this through COBOL also but our requirement is for DFSORT/ICETOOL or some utilities.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed May 05, 2004 7:25 am Post subject:
Deepesh,
Are you always going to have 7 occurances for each key ? i.e A1 has (AAA thru GGG) will you always have the 7 values or will it be less than that?
If it is always a constant then we override the lrecl and fetch all the rows in a single line. This is a trick messing with the block sizes which some people do not like.
On the other hand if you have DFSORT , the splice operator can be used to get the desired results.
Also there are some dirty ways to get the desired results using sort itself but it has got a lot of limitations.
Let me know if the occurances are constant then I will show you a job which will get the desired results. I also need the lrecl/recfm of input and output datasets.
Joined: 20 Jun 2003 Posts: 112 Topics: 48 Location: Bangalore
Posted: Wed May 05, 2004 8:25 am Post subject:
Hi Kolusu,
Yes there will be always 7 occurances.
The LRECL of the input file is 31. The last 9 bytes are the counts. For eg. the input file will be
670010000300032GGGPYSA000..........
670010000300032GGGPYSR000000000
670010000300032GGGPY0100............
890010000300032GGGPY03000000000
890010000300032GGGPY04000.........
890010000300032HHHPY05000..........
890010000300032BBBRTSA00...........----> Note the last 9 digits are packed if they are not zeros.
The last 9 bytes are either zeroes or packed numbers
The first 15 bytes are account numbers.
The output shud have only the 15 byte account number followed by all the 9 bytes counts as shown below
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed May 05, 2004 10:33 am Post subject:
Deepesh,
Here is a tricky way of getting the desired results. we first create a dataset with the key and the 9 byte count field , so that the total lrecl (15 + 9 = 24 bytes). I am also hardcoding the blksize on the sortout so that I can override the lrecl in the next step. I have coded blksize=26880.
Now we take the above created file and over ride the LRECL on the sortin statement with 1344.(24 * 56 = 1344)
By doing so we are reading 56 records as a single record. once we have the record as one record all we have to do remove the key value. for that we use the OUTREC.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed May 05, 2004 12:11 pm Post subject:
Deepesh,
Well, I was thinking you could use the SPLICE operator of DFSORT's ICETOOL with WITHEACH, but you'd need 56 WITH fields and the limit is 50. Also, you'd have to reformat each of the 56 records to get the WITH fields in the right position, which seems kind of impractical. Personally, I'd do this with an E35 exit that had the appropriate logic based on your specific knowledge of what you need to do. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum