1

是否可以使用 ABAP 中的一条指令将 2 个结构与嵌套表字段合并?我尝试使用 MOVE-CORRESPONDING,但没有成功。

下面我写了一个我需要做的简化版本,我的真实结构有更多的表和一些单独的字段,但现在我只要求简化下面的代码

  TYPES: BEGIN OF ty_nested_tables,
           table1 TYPE STANDARD TABLE OF ty_table1,
           table2 TYPE STANDARD TABLE OF ty_table2,
         END OF ty_nested_tables.
  DATA: nested1 TYPE ty_nested_tables,
        nested2 TYPE ty_nested_tables,
        nested3 TYPE ty_nested_tables.
  

我知道这可以为完整的 nested3 变量分组在一个 VALUE 中,但我想简化的部分是需要指定 table1 和 table2 当它们的名称和类型与目标相同时

  nested3-table1 = VALUE #( ( LINES OF nested1-table1 )
                            ( LINES OF nested2-table1 ) ).
  nested3-table2 = VALUE #( ( LINES OF nested1-table2 )
                            ( LINES OF nested2-table2 ) ).
4

1 回答 1

0

在 Stack 上,他们不喜欢 ABAP 宏,但宏非常适合您想要执行的此类结构化任务:

DEFINE copy.
 nested3-table&2 = VALUE #( BASE nested3-table&2 ( LINES OF nested&1-table&2 ) ).
END-OF-DEFINITION.

copy: 1 1, 1 2, 2 1, 2 2.
于 2020-07-30T14:54:22.147 回答