I am trying to SUM up 2 COMP-3 fields in my input file. The sort card I am using is as follows :
CODE :
SORT FIELDS=(8,2,CH,A)
SUM FIELDS=(214,5,PD,219,5,PD)
OUTREC FIELDS=(1,5,PD,M2,3X,10,5,PD,M2)
But I am getting a S0C7 error from the SORT
Please tell me how I can sum up the 2 consecutive fields which have the following definition :
PIC S9(7)V9(2) USAGE COMP-3.
PIC S9(7)V9(2) USAGE COMP-3.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
JayC,
Your job is failing because your input does not have valid Packed decimal fields. You can run VERIFY on the PD fields to see which records have invalid data.
Run the following to check for the invalid packed decimal fields
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
JayC,
Code:
SORT FIELDS=(8,2,CH,A)
SUM FIELDS=(214,5,PD,219,5,PD)
OUTREC FIELDS=(1,5,PD,M2,3X,10,5,PD,M2)
I'd guess the S0C7 is caused by the OUTREC statement, not the SUM statement.
You are summing on positions 214-218 and 219-223, but in your OUTREC statement you are NOT using those fields. Instead, you're using 1-5 and 10-14 which I suspect DO NOT have PD values, thus causing the S0C7.
SUM doesn't move the fields so they're still at 214 and 219. I don't know why you're using 1 and 10. If you're trying to output the summed fields, then you want this OUTREC statement:
Code:
OUTREC BUILD=(214,5,PD,M2,3X,219,5,PD,M2)
If you're trying to do something with PD fields at 1 and 10 in the input record, then why are you bothering to do the SUM on the other fields when you aren't going to output them?
Thanks alot . It works now !
Frank you were right about the OUTREC statement, my mistake.
And Skolusu thanks for the info on the VERIFY operator... Thats something new to me...