gpt4 book ai didi

abap - 将字段符号作为更改参数传递会导致短转储。为什么?

转载 作者:行者123 更新时间:2023-12-04 19:46:06 26 4
gpt4 key购买 nike

为什么 SAP 试图变得比它必须的更聪明,并在以下情况下生成短转储?

REPORT zzy.

CLASS lcl_main DEFINITION FINAL CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS:
main.
PRIVATE SECTION.
TYPES:
BEGIN OF t_my_type,
hierlevel TYPE i,
groupname TYPE ktext,
result TYPE p LENGTH 9 DECIMALS 2,
END OF t_my_type,
tt_my_type TYPE HASHED TABLE OF t_my_type WITH UNIQUE KEY hierlevel groupname.
CLASS-METHODS:
change
CHANGING
cs_my_type TYPE t_my_type.
ENDCLASS.

CLASS lcl_main IMPLEMENTATION.
METHOD main.
DATA:
lt_my_table TYPE tt_my_type.

INSERT VALUE #( hierlevel = 0 groupname = 'MY_GROUP' result = '0.0' ) INTO TABLE lt_my_table
ASSIGNING FIELD-SYMBOL(<fs_my_type>).

change(
CHANGING
cs_my_type = <fs_my_type>
).
ENDMETHOD.

METHOD change.
ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
lcl_main=>main( ).

方法中没有任何变化 change然而在我看到的短转储的描述中

Field <FS_MY_TYPE>-HIERLEVEL was to assigned a new value but this field is at least partly protected against changes.

看起来 SAP 试图变得比它应该的更聪明。如果我真的尝试更改其中一个关键字段,我会理解是否生成了短转储。为什么要这样设计?

最佳答案

我刚刚发现短转储中有进一步的描述

The following are protected against changes:
- Access using field symbols if the field assigned using ASSIGN is partly or completely protected (for example key components of internal table of the type SORTED or HASHED TABLE).

对我来说有点奇怪,但看起来像是一个设计决定。也许仅检查实际 protected 字段在技术上很难。

关于abap - 将字段符号作为更改参数传递会导致短转储。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36813425/

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