Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to a complicated sum fields operation. Please help.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Need to a complicated sum fields operation. Please help.
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Need to a complicated sum fields operation. Please
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 7 Sat Jan 21, 2017 4:02 am
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us