IF (WH-CENTRE-CODE = 14 AND FN-TNZ-TOT-AMT-14 NOT = WA-TOTAL-AMT) OR
(WH-CENTRE-CODE NOT EQUAL 14 AND FN-TNZ-TOT-AMT NOT = WA-TOTAL-AMT) << [color=red][b]why this condition failed[/b][/color]
MOVE 'FN-TNZ-TOT-AMT NOT = WA-TOTAL-AMT' TO WS-IMSE-REASON-1
IF WH-CENTRE-CODE = 14
DISPLAY 'FN-TNZ-TOT-AMT = ' FN-TNZ-TOT-AMT-14 [color=red][b]<< how come this value is printed in the sysout[/b][/color] ELSE
DISPLAY 'FN-TNZ-TOT-AMT = ' FN-TNZ-TOT-AMT
DISPLAY 'WA-TOTAL-AMT = ' WA-TOTAL-AMT
FN-TNZ-TOT-AMT = 00004476673 404
WA-TOTAL-AMT = 000000004476673
FUNCTION STATUS CODE AT 210400-CHECK-TRAILER-RECORD
REAS-1->FN-TNZ-TOT-AMT NOT = WA-TOTAL-AMT
CEE3250C The system or user abend U 778 R=00000000 was issued
02 WH-CENTRE-CODE 999 DISP 001
03 FN-TNZ-TOT-AMT S9(11) CMP3 +00004476673
03 WA-TOTAL-AMT S9(15) CMP3 +000000004476673
03 FN-TNZ-TOT-AMT-14 S9(15) CMP3 *** Invalid data for this data type *** Hex 00004476673C 040
Joined: 06 Jun 2008 Posts: 8165 Location: East Dubuque, Illinois, USA
The root cause of the problem is you've got non-numeric data in a numeric field. Probably you're using FN-TNZ-TOT-AMT-14 without ensuring it has all digits defined.
Your two questions in BBcode are contradictory. If the second part of the first IF test were being taken, the DISPLAY would be the ELSE part. If WH-CENTRE-CODE has value 14, then the two values in the first IF statement are not equal. You need to figure out where the FN-TNZ-TOT-AMT-14 is getting the invalid data from.
I would classify the WORKING-STORAGE statements as bad coding practice, myself. If you're going to REDEFINE numeric fields, especially COMP-3 numeric fields, you should put the fillers on the FRONT of the variable so the sign is always in the last 4 bits of the variable, no matter which variable you are using. If you had done that, this problem probably would not have occurred.