Posted: Tue Jul 19, 2005 8:19 pm Post subject: Sign Field considerations in SORT SUM - Syncsort
Sign Field considerations in SORT SUM
Hi,
1. I have a cobol Pic clause for a file as follows
A-FIELD1 PIC X(02).
A-FIELD2 PIC X(02).
A-CURR-SIGN PIC X(01).
A-CURR-AMT PIC 9(11).
B-CURR-SIGN PIC X(01).
B-CURR-AMT PIC 9(11).
C-CURR-SIGN PIC X(01).
C-CURR-AMT PIC 9(11).
D-CURR-SIGN PIC X(01).
D-CURR-AMT PIC 9(11).
If I have to sort sum on these fields, assuming A-FIELD1 and A-FIELD2, Can I do that considering A-CURR-AMT with sign field as ZD ?
Or else do I need to convert this ? If so How do I convert ?
LRECL=229 and RECFM=FB
2. Another case, I have a cobol pic clause as
A-FIELD1 PIC X(02).
A-FIELD2 PIC X(02).
A-CURR-AMT PIC -9(13).
B-CURR-AMT PIC -9(13).
C-CURR-AMT PIC -9(13).
D-CURR-AMT PIC -9(13).
I am sort summing on the amount fields, A-FIELD1 and A-FIELD2 are key fields.
When I am summing, If the file has two records 1 with +ve amount and another with -ve amount, the output record on summing is adding instead of subtracting and I am getting zeroes in the sign field. I am using ZD as the format in sum.
LRECL=152 and RECFM=FB
Example
Input
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Jul 27, 2005 7:36 am Post subject:
Quote:
If I have to sort sum on these fields, assuming A-FIELD1 and A-FIELD2, Can I do that considering A-CURR-AMT with sign field as ZD ?
Or else do I need to convert this ? If so How do I convert ?
LRECL=229 and RECFM=FB
Geetha,
You cannot use ZD for summing when the sign is seperate. you need to convert that field to a packed decimal field and then sum the values. so we convert the field and put it at the end of every record and then sum the value. Using OUTREC fields we can overlay the summed value on to the actual field.
ex:
Code:
INREC FIELDS=(1,229,
5,12,FS,PD,LENGTH=8) $CONVERT A-CURR-AMT TO PD
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=(230,8,PD)
OUTREC FIELDS=(1,4,
230,8,PD,EDIT=(STTTTTTTTTTT),SIGNS=(,,+,-),
17,213)
Quote:
2. Another case, I have a cobol pic clause as
Same as above. you need to convert and then peform the sum sort.
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