Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sum up the key fields and get the sum in all records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sum up the key fields and get the sum in all records
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: 1452
Location: Chicago, IL

PostPosted: Tue Apr 18, 2006 2:50 pm    Post subject: Re: Sum up the key fields and get the sum in all records
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    Post subject: Re: Sum up the key fields and get the sum in all records
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 Moderator


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

PostPosted: Tue Apr 18, 2006 9:02 pm    Post subject:
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    Post subject: Re: Sum up the key fields and get the sum in all records
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 Moderator


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

PostPosted: Wed Apr 19, 2006 8:35 pm    Post subject:
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    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 Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us