I try doing the following:
I have three variables in a file ETTMAS18:
C43LECA PIC S9(09) COMP.
C43LCOME PIC S9(09) COMP.
C43CCHEC PIC X(01).
These variables contained:
C43LECA = 000000999 (three last positions)
C43LCOME = 000000888 (five last positions)
C43CCHEC = 1
And I changed to one variable: 999008881
Then move to W-CTOAZ710-COA43LCOME PIC S9(9) USAGE COMP.
COPY ETTMAS18:
10 C43LECA PIC S9(09) COMP.
10 C43LCOME PIC S9(09) COMP.
10 C43CCHEC PIC X(01).
05 WS-COMERC-AUX.
10 C43LECA PIC 9(3).
10 C43LCOME PIC 9(5).
10 C43CCHEC PIC 9(1).
05 WS-COMERC-AUX-BIN REDEFINES WS-COMERC-AUX PIC S9(9) USAGE COMP.
10 W-CTOAZ710-COA43LCOME PIC S9(9) USAGE COMP.
MOVE 0 TO WS-COMERC-AUX
WS-COMERC-AUX-BIN
MOVE C43LECA IN ETTMAS18 TO C43LECA IN WS-COMERC-AUX
MOVE C43LCOME IN ETTMAS18 TO C43LCOME IN WS-COMERC-AUX
MOVE C43CCHEC IN ETTMAS18 TO C43CCHEC IN WS-COMERC-AUX
MOVE WS-COMERC-AUX-BIN TO W-CTOAZ710-COA43LCOME
W-CTOAZ710-COA43LCOME-DES
IF WS-FECHA-ACT = '2015-03-10'
DISPLAY 'C43LECA IN ETTMAS18: ' C43LECA IN ETTMAS18
DISPLAY 'C43LCOME IN ETTMAS18: ' C43LCOME IN ETTMAS18
DISPLAY 'C43CCHEC IN ETTMAS18: ' C43CCHEC IN ETTMAS18
DISPLAY 'C43LECA IN WS-COMERC-AUX : '
C43LECA IN WS-COMERC-AUX
DISPLAY 'C43LCOME IN WS-COMERC-AUX : '
C43LCOME IN WS-COMERC-AUX
DISPLAY 'C43CCHEC IN WS-COMERC-AUX : '
C43CCHEC IN WS-COMERC-AUX
DISPLAY 'WS-COMERC-AUX: ' WS-COMERC-AUX
DISPLAY 'WS-COMERC-AUX-BIN: ' WS-COMERC-AUX-BIN
DISPLAY 'W-CTOAZ710-COA43LCOME: '
W-CTOAZ710-COA43LCOME
DISPLAY '******************************************'
END-IF
Displays:
C43LECA IN ETTMAS18: 000000999
C43LCOME IN ETTMAS18: 000000888
C43CCHEC IN ETTMAS18: 1
C43LECA IN WS-COMERC-AUX : 999
C43LCOME IN WS-COMERC-AUX : 00888
C43CCHEC IN WS-COMERC-AUX : 1
WS-COMERC-AUX: 999008881 This value is the correct value.
WS-COMERC-AUX-BIN: 10105806M (I don't understand)
W-CTOAZ710-COA43LCOME: 10105806M (I don't understand)
In the output (w-ctoaz710-coa43lcome) is truncated:
9990
With hexadecimal values:
9990
FFFF
9990
Could someone explain?
Your problem is here:
05 WS-COMERC-AUX-BIN REDEFINES WS-COMERC-AUX PIC S9(9) USAGE COMP.
All that does is allow your program to use a new data-definition. There is no change to the data (unless you make one).
This means you have "character" data, and then you are just saying "hey, I'm going to use this as binary".
The easiest thing for you to do is to remove the COMP from your REDEFINES. A USAGE DISPLAY
numeric field will then be MOVEd to the binary field, and the compiler will generate the code necessary for translation.
The reason you get the truncation on your file is because you have an 8-byte character value treated as a four-byte binary value. If you "look" at the four-byte binary value, it will appear to be a truncated "character" value.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments