I'm trying to compare two hex values as in the code at the bottom. I was expecting that the IF
statement, where I compare field A
and field WS-FLD-X
, would result in true, but it doesn't do it.
In other words, when I move 12
to WS-FLD-A
, the value in WS-FLD-X
should be stored as X'0C'
, right? This value is expected to be the same value in field A
. Comparing the two values should result in true, however this is not happening.
Why? What is the difference between the value held in field A
and the value in WS-FLD-X
?
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FF.
05 A PIC XX.
05 B PIC XXXXXX.
01 F.
05 WS-FLD PIC S9(4) COMP.
05 WS-FLD-X REDEFINES WS-FLD PIC XX.
PROCEDURE DIVISION.
DISPLAY 'Hello, world' UPON CONSOLE.
MOVE X'0C' TO A.
MOVE "SOME TEXT" TO B.
DISPLAY FF UPON CONSOLE.
MOVE 12 TO WS-FLD
DISPLAY "HEX OF 12 IS:" WS-FLD-X UPON CONSOLE.
IF WS-FLD-X = A THEN DISPLAY "SAME" UPON CONSOLE END-IF.