|
View previous topic :: View next topic
|
| Author |
Message |
bijoybabu83
New User
Joined: 15 Jan 2007 Posts: 36 Location: Kerala
|
|
|
|
Hi,
I need to do a peculiar type of summing using sort.
I have a file.
| Code: |
<------------Length 60 bytes----------------------------><---20ytes--><2>
75026 BLJ 303 EMPIRE BCBS ITS PPO PCPM 03
75026 BLJ 303 EMPIRE BCBS C01 10
75026 BLJ 303 EMPIRE BCBS ITS PPO PCPM 04
75026 BLJ 303 EMPIRE BCBS C02 21 |
The key is 60 bytes field
Then there is a 20 byte filed.
The last two bytes of the file is Contract count.
I need to add the contract counts(last two bytes) of the records which matches from 1 -60 (matching keys). There can be only 2 repeating keys(duplicates for every key). The condition is such that If there is a duplicate, then if second repeating key record has 'C01 ' in the 20 byte record, then add the last 2 bytes of these records. The record retained should have the value of the first repeating key in the 20 bytes field.
for the data shown above the output should be like :-
| Code: |
75026 BLJ 303 EMPIRE BCBS ITS PPO PCPM 13
75026 BLJ 303 EMPIRE BCBS ITS PPO PCPM 04
75026 BLJ 303 EMPIRE BCBS C02 21 |
Can I implement this using SORT. Please help. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
bijoybabu83,
The first 4 records all have the same key in the first 60 bytes. How do you distinguish the keys?
Are the records already sorted on the first 60 bytes? And every 2 records is considered as a set of keys? Do you have orphan keys ( only 1 record present) |
|
| Back to top |
|
 |
bijoybabu83
New User
Joined: 15 Jan 2007 Posts: 36 Location: Kerala
|
|
|
|
Hi Skolusu,
1. Regarding the data given, it seems to be wrong. There can only be 2 duplicates. So please consider the last two records to have 304 in postion of 303.
2. All the records are sorted on the first 60 bytes.
3. There can be orphan keys.
For example consider the input data can look like :-
| Code: |
<------------Length 60 bytes----------------------------><---20ytes--><2>
75026 BLJ 303 EMPIRE BCBS ITS PPO PCPM 03
75026 BLJ 303 EMPIRE BCBS C01 10
75026 BLJ 304 EMPIRE BCBS ITS PPO PCPM 04
75026 BLJ 304 EMPIRE BCBS C02 21
75026 BLJ 305 EMPIRE BCBS ITS PPO PCPM 06
75026 BLJ 306 EMPIRE BCBS C02 29 |
The output should be
| Code: |
<------------Length 60 bytes----------------------------><---20ytes--><2>
75026 BLJ 303 EMPIRE BCBS ITS PPO PCPM 13
75026 BLJ 304 EMPIRE BCBS ITS PPO PCPM 04
75026 BLJ 304 EMPIRE BCBS C02 21
75026 BLJ 305 EMPIRE BCBS ITS PPO PCPM 06
75026 BLJ 306 EMPIRE BCBS C01 29 |
I think it is clear now. Please help. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
bijoybabu83,
Use the following DFSORT Control cards. Remember that your summing field is only 2 bytes and if the total is greater than 99 you would still get duplicate records
| Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,1,ZD,RESTART=(1,60))),
IFTHEN=(WHEN=(83,1,ZD,EQ,2,AND,61,3,CH,EQ,C'C01'),OVERLAY=(83:C'1'))
SORT FIELDS=(1,60,CH,A,83,1,CH,A),EQUALS
SUM FIELDS=(81,2,ZD)
OUTREC BUILD=(1,82)
/* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|