Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
tanguduk
Warnings : 1

New User

Joined: 29 Aug 2005
Posts: 14

 Posted: Tue Jan 20, 2009 3:37 pm    Post subject: Sum the values of amount 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

km_abdullah

New User

Joined: 03 Nov 2008
Posts: 60

 Posted: Tue Jan 20, 2009 4:25 pm    Post subject: Hi, Just check if the below discussed topics helps. http://ibmmainframes.com/viewtopic.php?t=29183&highlight=sumfields http://ibmmainframes.com/viewtopic.php?t=9625&highlight=sumfields
tanguduk
Warnings : 1

New User

Joined: 29 Aug 2005
Posts: 14

 Posted: Tue Jan 20, 2009 6:36 pm    Post subject: Reply to: Sum the values of amount 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
tanguduk
Warnings : 1

New User

Joined: 29 Aug 2005
Posts: 14

 Posted: Tue Jan 20, 2009 8:33 pm    Post subject: Reply to: Sum the values of amount 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
Frank Yaeger

DFSORT Moderator

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

Posted: Tue Jan 20, 2009 9:56 pm    Post subject:

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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics LOW VALUES as a KEY juares castro DB2 10 Sat Apr 07, 2018 1:06 am Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am how to add the amount for duplicate r... SRUTHI DRAVIDAMANI COBOL Programming 6 Wed Feb 21, 2018 7:21 pm attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us