将工作区转换为内部表类型的行

时间:2019-07-08 10:09:29

标签: sql sap abap

我收到此语法错误:

  

“ WA_1”不能转换为线型“ IT_1”

我正在尝试如下显示内部表中的内容:

REPORT  ZSAM.

DATA: ITable Type ZMUAZ_STRUCTURE OCCURS 10,
      IT_1 Type ZSTRUCT1 OCCURS 10,
      IT_2 Type ZSTRUCT2 OCCURS 10,
      WA_1 like IT_1,
      WA_2 like IT_2,
      WA_3 like ITable.

WRITE: 'vbeln', 'vtweg', 'posnr', 'matnrr','vrkme'.

select vbeln audat netwr waerk vkorg vtweg from VBAK into corresponding fields of Table IT_1.

LOOP AT IT_1 INTO WA_1.

write: /  WA_1-vbeln, WA_1-audat, WA_1-netwr, WA_1-waerk, WA_1-vkorg, WA_1-vtweg.

endloop.

您知道如何解决此错误吗?

1 个答案:

答案 0 :(得分:6)

wa_1被声明为内部表(而不是工作区)。最简单的解决方案是使用LINE OF完成声明:

... wa_1 LIKE LINE OF it_1,

然而,像声明OCCURS is obsolete一样声明内部表和工作区,其现代等效项是STANDARD TABLE OF

DATA: it_1 TYPE STANDARD TABLE OF zstruct1,
      wa_1 TYPE zstruct1.