我尝试执行以下操作:
我在文件ETTMAS18中有三个变量:
C43LECA PIC S9(09) COMP.
C43LCOME PIC S9(09) COMP.
C43CCHEC PIC X(01).
这些变量包含:
C43LECA = 000000999 (three last positions)
C43LCOME = 000000888 (five last positions)
C43CCHEC = 1
我改为一个变量:999008881
然后转到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
显示:
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)
在输出中(w-ctoaz710-coa43lcome)被截断:
9990
使用十六进制值:
9990
FFFF
9990
有人可以解释一下吗?
答案 0 :(得分:3)
你的问题在这里:
05 WS-COMERC-AUX-BIN REDEFINES WS-COMERC-AUX PIC S9(9) USAGE COMP.
所有这一切都允许您的程序使用新的数据定义。数据没有变化(除非你制作一个)。
这意味着你有“字符”数据,然后你只是说“嘿,我将把它用作二进制”。
最简单的方法是从REDEFINES中删除COMP。然后将USAGE DISPLAY
数字字段移动到二进制字段,编译器将生成翻译所需的代码。
您在文件上截断的原因是因为您将8字节字符值视为四字节二进制值。如果“查看”四字节二进制值,它将显示为截断的“字符”值。