summing positive and negative
Posted:
Sun May 18, 2008 8:25 pm
by meharbabamusa1
I have the following file.
KEY1 +200.00 KEY2
KEY1 -500.00 KEY2
KEYA +100.00 KEYB
I need to summup the amount fields if all the other fields are same.
the output file shouldbe
KEY1 -300.00 KEY2
KEYA +100.00 KEYB
Please let me know weather it is possible or not in syncsort.
Thanks,
Mehar
Re: summing positive and negative
Posted:
Sun May 18, 2008 8:45 pm
by CICS Guy
meharbabamusa1 wrote:Please let me know weather it is possible or not in syncsort.
I think you will need to convert on INREC with SFF, SUM, and then EDIT on OUTREC.
All is available with Syncsort.
Re: summing positive and negative
Posted:
Sun May 18, 2008 11:45 pm
by dick scherrer
Hello Mehar and welcome to the forums,
The good news is that you can do what you need with Syncsort as CG said.
In order to do so, you need to provide more info.
Please use the "Code" tag above to show some "real" records (not the way you have, but show the data the exact same as the input records). Show what happens when there multiple values for the "second" key within the "first" key. Will the records actually have an embedded + or - sign or are the numbers implicitly signed? When you post the info, please mention the dsorg and lrecl for the files.
After you type your post, you can use Preview to see your post as it will appear to the forum. When you like the way your post appears, click Submit.
Re: summing positive and negative
Posted:
Tue Jun 24, 2008 8:16 pm
by meharbabamusa1
LRECL=40
RECFM=FB
MY INPUT IS
----------------
U,0R,0R,0008,USD,+0000000000134.75,AM002
U,0R,0R,0008,USD,-0000000056679.70,AM002
U,0R,0R,0010,USD,+0000000000100.75,AM002
U,0R,0R,0010,USD,-0000000010000.70,AM002
OUTPUT SHOULD BE
----------------------------------------------
U,0R,0R,0008,USD,-0000000056544.95,AM002
U,0R,0R,0010,USD,-0000000009909.85,AM002
sORRY FOR THE LATE RESPONSE ,I WAS ON VACATION