MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Summing a Numeric field with spaces and put it across

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
karavi2000
Beginner


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Wed Dec 27, 2006 12:46 pm    Post subject: Summing a Numeric field with spaces and put it across Reply with quote

I searched in this forum to get a solution for this but I couldn't find one that matches. So here is the problem.

I have a file with following information.
Code:

ID  FID  Amount
--- ---- ---------
ID1|FID1|20             |
ID2|FID1|30             |
ID3|FID1|5000           |
ID4|FID2|40             |
ID5|FID2|10000          |


ID -> 9 CHAR ; FID -> 9 CHAR ; Amount -> 19 CHAR

Here I want to add all those Amounts for a particular FID and put it across on all rows with the FID with the total value. One more issue here is the Amount field is alphanumeric but contains numeric digits. We need to append Zeroes to the front before calculation else we get S0C7.

The final output should be
Code:

ID1|FID1|20             |5050
ID2|FID1|30             |5050
ID3|FID1|5000           |5050
ID4|FID2|40             |10040
ID5|FID2|10000          |10040

Please let me know if this can be done in SORT. Thanks.

Regards,
Ravishankar
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Dec 27, 2006 3:42 pm    Post subject: Reply with quote

karavi2000,



Try this untested DFSORT/ICETOOL job which will give you the desired results.


Code:

//STEP0100 EXEC PGM=ICETOOL                             
//DFSMSG   DD SYSOUT=*                                   
//TOOLMSG  DD SYSOUT=*                                   
//IN       DD *                                         
ID1      |FID1     |20                 |                 
ID2      |FID1     |30                 |                 
ID3      |FID1     |5000               |                 
ID4      |FID2     |40                 |                 
ID5      |FID2     |10000              |                 
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON      DD DSN=*.T1,VOL=REF=*.T1,DISP=SHR             
//         DD DSN=*.T2,VOL=REF=*.T2,DISP=SHR             
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                         
  SORT   FROM(IN)  USING(CTL1)                                   
  SPLICE FROM(CON) TO(OUT)     -                                 
      ON(11,09,CH) WITH(01,40) WITHALL USING(CTL2)               
//CTL1CNTL DD *                                                 
  SORT FIELDS=(11,09,CH,A)                                       
  OUTREC FIELDS=(01,40,19X)                                     
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,                           
  SECTIONS=(11,09,TRAILER3=(01,40,TOT=(21,19,UFF,M10,LENGTH=19)))
  OUTFIL FNAMES=T2                                               
//CTL2CNTL DD *                                                 
  OUTFIL FNAMES=OUT,                                             
  OUTREC=(01,40,41,19,JFY=(SHIFT=LEFT))                         
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Dec 27, 2006 4:47 pm    Post subject: Reply with quote

Kolusu's DFSORT/ICETOOL job works fine. Note, however, that you'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's JFY function. If you don't have April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
karavi2000
Beginner


Joined: 17 Aug 2003
Posts: 51
Topics: 26
Location: Chennai

PostPosted: Thu Dec 28, 2006 11:43 am    Post subject: Reply with quote

Kolusu,
Your solution worked great except for the fact that I couldn't use the JFY parameter. But I believe I can live without that and can handle it in the program. Thanks a lot for the solution. It helped me learn some new parameters. Thanks again.

Frank,
I donno if System programmers can work on an update based on my mail. Still I am planning to throw the stone. Letz hope it hits the target. Thanks for the information.

Regards,
Ravishankar
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group