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

Sum up the key fields and get the sum in all records


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

Active User


Joined: 11 Apr 2005
Posts: 106
Location: Cincinnati Ohio

PostPosted: Tue Apr 18, 2006 11:38 am
Reply with quote

I have got an input file in the format mentioned below:
Code:
Key1  - Amount 1
Key1  - Amount 2
Key1  - Amount 3
Key2  - Amount 1
Key2  - Amount 2
Key2  - Amount 3
I need an output in the format
Code:
Key1  - Amount k1
Key1  - Amount k1
Key1  - Amount k1
Key2  - Amount k2
Key2  - Amount k2
Key2  - Amount k2

where Amount k1 = Amount 1 +Amount 2 + Amount 3 for Key1
and Amount k2 = Amount 1 +Amount 2 + Amount 3 for Key2.

Can this be done using DFSORT? If yes then how?

thanks
David
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Apr 18, 2006 2:50 pm
Reply with quote

Length of KEY & AMOUNT ???

Regards,
Priyesh.
Back to top
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 106
Location: Cincinnati Ohio

PostPosted: Tue Apr 18, 2006 3:48 pm
Reply with quote

Hi Priyesh,

Here is the information that I missed

Key length 8 characters
Amounts 8 bytes packed decimal

Please let me know if I missed anything.

Thanks
David P.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Apr 18, 2006 9:02 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed the key is in positions 1-8 and the PD amount is in positions 9-16 and that your input file has RECFM=FB and LRECL=16. You can change the job appropriately for other positions and attributes if necessary.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (FB/16)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=... output file (FB/16)
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,8,CH) WITHALL WITH(1,8)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,8,CH,A)
  SUM FIELDS=(9,8,PD)
/*
Back to top
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 106
Location: Cincinnati Ohio

PostPosted: Wed Apr 19, 2006 11:59 am
Reply with quote

Thanks Frank.

I tried the JCL you posted and its working for me.

-thanks
David P.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 19, 2006 8:35 pm
Reply with quote

Glad I could help.
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Identify and write records containing... SYNCSORT 11
No new posts Filter records where condition is in ... SYNCSORT 6
Search our Forums:


Back to Top