IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to a complicated sum fields operation. Please help.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bijoybabu83

New User


Joined: 15 Jan 2007
Posts: 36
Location: Kerala

PostPosted: Wed Mar 31, 2010 6:58 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Mar 31, 2010 9:34 pm
Reply with quote

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
View user's profile Send private message
bijoybabu83

New User


Joined: 15 Jan 2007
Posts: 36
Location: Kerala

PostPosted: Thu Apr 01, 2010 2:52 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Apr 01, 2010 9:39 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
No new posts Data for newly added fields not displ... IMS DB/DC 6
This topic is locked: you cannot edit posts or make replies. SUM FIELDS=NONE in reverse - Get dupl... DFSORT/ICETOOL 9
Search our Forums:

Back to Top