Joined: 12 May 2006 Posts: 41 Topics: 16 Location: Mumbai
Posted: Tue May 16, 2006 1:59 am Post subject: Summing up two fields and store the res in the third field
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
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Tue May 16, 2006 2:54 am Post subject:
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,
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue May 16, 2006 10:47 am Post subject:
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:
_________________ 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
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