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

Sum the values of amount


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

New User


Joined: 29 Aug 2005
Posts: 14

PostPosted: Tue Jan 20, 2009 3:37 pm
Reply with quote

Hi ,

I have requirment like this ,

I have the file like ,

emp_nr month/year Amount
000000042 03/2001 E E 001 0.000 328.32
000000042 03/2001 E E 320 0.000 103.63
000000042 03/2001 E E 370 0.000 4.56
000000042 03/2001 E E 400 0.000 -0.01

I want to sum the values for 3/2001 amount

000000042 03/2001 E E 0.000 436.5

I have different months 1/2001 to 12/2001



Please let me know How can I achieve this


Regards
Kiran
Back to top
View user's profile Send private message
km_abdullah

New User


Joined: 03 Nov 2008
Posts: 60

PostPosted: Tue Jan 20, 2009 4:25 pm
Reply with quote

Hi,

Just check if the below discussed topics helps.

ibmmainframes.com/viewtopic.php?t=29183&highlight=sumfields

ibmmainframes.com/viewtopic.php?t=9625&highlight=sumfields
Back to top
View user's profile Send private message
tanguduk
Warnings : 1

New User


Joined: 29 Aug 2005
Posts: 14

PostPosted: Tue Jan 20, 2009 6:36 pm
Reply with quote

Hi Arun,

Starting position and length are

for month/year ---starting position 12 lenth 7
and I have to add amounts whicch is at 41 positon length 7

Regards
kiran
Back to top
View user's profile Send private message
tanguduk
Warnings : 1

New User


Joined: 29 Aug 2005
Posts: 14

PostPosted: Tue Jan 20, 2009 8:33 pm
Reply with quote

I have written the below code for my req

INREC OVERLAY=(41:41,7,SFF,TO=ZD,LENGTH=7)
SORT FIELDS=(12,7,CH,A)
SUM FIELDS=(41,8,ZD)
OUTREC OVERLAY=(41:41,7,ZD,EDIT=(STTTTT.T),SIGNS=(,-))

for summing the amount for particular year say all the amounts for 1/2001,3/2001,3/2001,
and so on up to 12/2001 but I am not getting the result as expeted

Suppose I have like

000000042 03/2001 E E 001 0.000 328.32
000000042 03/2001 E E 320 0.000 103.63
000000042 03/2001 E E 370 0.000 4.56
000000042 03/2001 E E 400 0.000 -0.01


then I want as below,


000000042 03/2001 E E 0.000 436.5

Please Suggest
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 Jan 20, 2009 9:56 pm
Reply with quote

Based on what you've said and shown, I believe these DFSORT control statements will give you what you want:

Code:

  INREC OVERLAY=(41:41,7,SFF,TO=ZD,LENGTH=7)               
  SORT  FIELDS=(12,7,CH,A)                                 
  SUM FIELDS=(41,7,ZD)                                     
  OUTREC OVERLAY=(41:41,6,ZD,EDIT=(SIIIIT.T),SIGNS=(,-))   


The output I get with your input example is:

Code:

000000042  03/2001 E E 001     0.000       436.5


If you want to remove the '001' field and/or output the fields in different positions, you can use an appropriate BUILD operand instead of an OVERLAY operand to do that.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Amount of days between two dates PL/I & Assembler 8
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top