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

Sum of a field - using icetool


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

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Jan 07, 2011 1:22 pm
Reply with quote

I have 2 input files.

Customer file :
col 1 - 5 : cust id
col 10 - 19 : cust name

Code:
11111    ANJU
22222    MANISH
33333    RAVI
44444    DEEPA
55555    ASHA


Transaction file : this is a file with multiple entries for the cust id
col 1 - 5 : cust id
col 10-14 : trans amount
col 20-29 : trans date

Code:
11111    00010     15/12/2010
22222    00020     01/01/2011
33333    00030     20/12/2010
04444    00040     16/12/2010
11111    00050     01/01/2011
22222    00060     21/11/2010
33333    00070     20/12/2010
44444    00010     16/12/2010
11111    00020     01/01/2011
22222    00030     21/11/2010
33333    00010     15/12/2010
44444    00020     01/01/2011
55555    00030     20/12/2010
11111    00040     16/12/2010
11111    00050     01/01/2011


In my output file i want the cust id , cust name and each trans amt of each customer with a total of the trans amount for each cust. So my output should appear as follows :

Code:
11111  ANJU  00010
11111  ANJU  00050 
11111  ANJU  00020
11111  ANJU  00040
11111  ANJU  00050

                                     TOT = 00170


22222   MANISH  00020
22222   MANISH  00060
22222   MANISH  00030

                                    TOT = 00110

"Code'd"

Likewise it should give for the other cust id's.

Can this be done using SPLICE ?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jan 11, 2011 2:08 am
Reply with quote

Ambili S,

Use the following DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//INA      DD *                                             
11111    ANJU                                               
22222    MANISH                                             
33333    RAVI                                               
44444    DEEPA                                             
55555    ASHA                                               
//INB      DD *                                             
11111    00010     15/12/2010                               
22222    00020     01/01/2011                               
33333    00030     20/12/2010                               
04444    00040     16/12/2010                               
11111    00050     01/01/2011                               
22222    00060     21/11/2010                               
33333    00070     20/12/2010                               
44444    00010     16/12/2010                               
11111    00020     01/01/2011                               
22222    00030     21/11/2010                               
33333    00010     15/12/2010                               
44444    00020     01/01/2011                               
55555    00030     20/12/2010                               
11111    00040     16/12/2010                               
11111    00050     01/01/2011                               
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  OPTION COPY                                               
  JOINKEYS F1=INA,FIELDS=(1,5,A)                           
  JOINKEYS F2=INB,FIELDS=(1,5,A)                           
  REFORMAT FIELDS=(F1:1,20,F2:10,5)                         
  OUTFIL REMOVECC,BUILD=(1,25,80:X),                       
  SECTIONS=(1,5,                                           
  TRAILER3=(//,40:'TOT = ',TOT=(21,5,ZD,M11,LENGTH=8),//)) 
//*
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Shift left VB record without x00 endi... DFSORT/ICETOOL 11
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top