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 

Sum of 2 fields on every record to create a 3rd field

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


Joined: 15 Jun 2005
Posts: 12
Topics: 7

PostPosted: Tue Jan 24, 2006 6:56 am    Post subject: Sum of 2 fields on every record to create a 3rd field Reply with quote

Hi,

I have a file with 2 fields A1, A2. i want to create a file with 3 fileds where 3rd field will be sum of first two fields. This has to be done thru jcl using any utility. It will be so helpful for me thru sort utility
eg,
I/P
Code:

A1  A2 
3    2
2    5


O/P
Code:

A1 A2 A3
3  2  5
2  5  7

Thanks
bobi
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 24, 2006 8:16 am    Post subject: Reply with quote

bobi,

You can use Horizontal math function(add,sub,mul,div) to get the desired results.
Try this
Code:

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *
----+----1----+----2-                           
3 2                                         
2 5                                         
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                             
  SORT FIELDS=COPY                           
  OUTREC FIELDS=(1,4,                       
                 1,1,ZD,ADD,3,1,ZD,EDIT=(TT))
/*                                           


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
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