gpt4 book ai didi

cobol - INITIALIZE 在 PIC X 和 PIC S9 COMP 变量上给出垃圾值

转载 作者:行者123 更新时间:2023-12-01 07:33:20 25 4
gpt4 key购买 nike

初始化以下变量时:

01  BATCH-REC.
03 BATCH-VERSION PIC X(2).
03 BATCH-FIELDS PIC X(682).
03 BATCH-REC-01 REDEFINES BATCH-FIELDS.
05 B01-OH-DTL-REC.
07 B01-PE-ID PIC X(12).
07 B01-PMT-DISC-TERMS PIC S9(4) COMP.
07 B01-PMT-DISC-AMT PIC S9(18) COMP.

使用命令
INITIALIZE BATCH-REC.

变量 B01-PMT-DISC-TERMS被初始化为值 +08224 和 B01-PMT-DISC-AMT初始化为 +314885530818453536。
原因可能是什么?初始化后将空格移动到这些变量是个好主意吗?我不想更改那个 BATCH-REC 代码来为它们添加默认值。

最佳答案

INITIALIZE语句不会初始化重新定义的字段。如果要初始化重新定义的字段,则必须以某种方式标识它们。例如,

INITIALIZE BATCH-VERSION BATCH-REC-01

这会将基本字段初始化为 SPACESZEROS取决于他们的 PICTURE . BATCH-FIELDS不会被初始化。

在这种情况下,以下第 3 项适用。来自 INITIALIZE 的 2002 标准:

5) The receiving-operand in each implicit MOVE or SET statement is determined by applying the following steps in order:

a) First, the following data items are excluded as receiving-operands:

  1. Any identifiers that are not valid receiving operands of a MOVE statement, except data items of category data-pointer, object-reference, or program-pointer.
  2. If the FILLER phrase is not specified, elementary data items with an explicit or implicit FILLER clause.
  3. Any elementary data item subordinate to identifier-1 whose data description entry contains a REDEFINES or RENAMES clause or is subordinate to a data item whose data description entry contains a REDEFINES clause. However, identifier-1 may itself have a REDEFINES clause or be subordinate to a data item with a REDEFINES clause.

关于cobol - INITIALIZE 在 PIC X 和 PIC S9 COMP 变量上给出垃圾值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55129015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com