I am trying to perform an arithmetic operation using two decimal fields in records to have the desired result. but somehow, its not working for me. I am not sure what mistake I am doing.
My requirement is to match two files based on two fields. if it matches, then i should perform subtraction of decimal field for first record (for e.g : 0003.0493) from file1 and decimal field (for eg : 0000.9589) to have the result 0002.0904 in output file.
Also, for the fourth record, it should display the negative value by subtracting 0001.3600 - 0001.5800. But When i executed this piece of code, i am getting S0C7 abend.
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
The DFSORT Application Programming Guide manual, in the Data format descriptions paragraph, tells you EXACTLY why you got the ABEND (emphasis added by me):
Quote:
ZD (zoned decimal, signed). Each digit of the decimal number is converted into its 8-bit EBCDIC representation. The sign indicator replaces the first four bits of the low order byte of the number.
The following are treated as positive sign indicators: F, E, C, A, 8, 6, 4, 2, 0.
The following are treated as negative sign indicators: D, B, 9, 7, 5, 3, 1.
For SUM processing, 0 through 9 for the sign or A through F for a digit results in a data exception (0C7 ABEND). For example, a ZD value such as 3.5 (X'F34BF5') results in an 0C7 because B is treated as an invalid digit. ICETOOL's DISPLAY or VERIFY operator can be used to identify ZD values with invalid digits. ICETOOL's VERIFY operator can be used to identify ZD values with invalid signs.
The first four bits of the last digit is the sign indicator. The first four bits of each other digit is ignored. Thus the EBCDIC strings '0025' and ' 25' are both treated as 25 because a leading blank (X'40') is equivalent to a 0 digit (X'F0').
Thanks, Robert. That serves the purpose. My bad, I didn't take an effort to go through the documentation. Appreciate your time and information. It really worked.
1) You can ignore characters like '.' (but handle '+', and '-') when specifying format SFF instead of ZD. You also may need to practice with correct assumed position of decimal point.
2) Syntax error: must be EDIT=(ITTTT.TTTT); and also parameter SIGNS=... is needed to mark negatives with minus
3) Case WHEN=(69,01,CH,EQ,C'2') is not handled
4) For debugging purposes you can temporary add converted field values (before subtraction) into your output: