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 up two fields and store the res in the third field

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


Joined: 12 May 2006
Posts: 41
Topics: 16
Location: Mumbai

PostPosted: Tue May 16, 2006 1:59 am    Post subject: Summing up two fields and store the res in the third field Reply with quote

Hi,

Is there a way in DF Sort to sum up two fileds and store the result in the third field...? I want this process to be repeated for each record of the input file. If this was already posted before pl dont mind to provide me the link.
_________________
Thanks,
-Srini
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue May 16, 2006 2:54 am    Post subject: Reply with quote

Srini,

Yes, you can do. But, please give us a sample input and sample output file with complete information like LRECL & RECFM - so that we can provide you the required solution,

Thanks,
Phantom
Back to top
View user's profile Send private message
Jaya
Beginner


Joined: 02 Sep 2005
Posts: 77
Topics: 10
Location: Cincinnati

PostPosted: Tue May 16, 2006 3:19 am    Post subject: Reply with quote

Srini_igsi,

Please check this link for adding 2 fields in every record and placing the result in the third field.

http://mvsforums.com/helpboards/viewtopic.php?t=5726&highlight=sum+two+fields

Thanks,
Jaya.
_________________
"Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein
Back to top
View user's profile Send private message
srini_igsi
Beginner


Joined: 12 May 2006
Posts: 41
Topics: 16
Location: Mumbai

PostPosted: Tue May 16, 2006 3:40 am    Post subject: Reply with quote

Hi Phantom,

Thx for ur quick reply. Here is the sample data.

Lets say that A,B and C are the 2nd,3rd and 4th fields in the record resp.
A PIC 9(2)V9(2)
B PIC 9(2)V9(2)
C PIC 9(5)V9(4)

I just want the sum of A nd B into C. I want this process repeated for each of the rec in the Input file. how can i do this using DF Sort.

Help me out.
_________________
Thanks,
-Srini
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue May 16, 2006 4:02 am    Post subject: Reply with quote

Srini,

You need to look for Horizontal Math functions (ADD / SUB / MUL / DIV). Jaya has already provided you the required solution.

Here is another example.
http://www.mvsforums.com/helpboards/viewtopic.php?t=5584&highlight=outrec+add

Thanks,
Phantom
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Tue May 16, 2006 10:47 am    Post subject: Reply with quote

Quote:
Lets say that A,B and C are the 2nd,3rd and 4th fields in the record resp.
A PIC 9(2)V9(2)
B PIC 9(2)V9(2)
C PIC 9(5)V9(4)


You didn't describe the 1st field, so let's say it's 10 bytes. Then A starts in position 11, is a 4-byte ZD field and has 2 implied decimal places. B starts in position 15, ia a 4-byte ZD field and has 2 implied decimal places. C starts in position 19, is a 9-byte ZD field and has 4 implied decimal places. Since you're adding two values with 2 implied decimal places and you want a result with 4 implied decimal places, you're essentially adding '00' at the end of the result field to account for the extra two decimal places. For example, if A is 1020 (10.20) and B is 1512 (15.12), C would be 0000253200 (00025.3200).

You could use the following DFSORT job to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(19:(11,4,ZD,ADD,15,4,ZD),MUL,+100,TO=ZD,LENGTH=9)
/*

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