Types 主程序中无法识别包含中的声明
我正在写一份包含许多子字段的数据结构的报告。为了避免代码混乱,我将其外包给一个Include,它直接包含在报表语句之后,然后是数据定义 现在我的问题是:当使用INCLUDE中定义的类型作为变量的数据类型时,ABAP编译器会说该类型没有定义。即使codecompletion在使用Eclipse时点击Strg+Space时显示include中的类型 包括:Types 主程序中无法识别包含中的声明,types,include,abap,Types,Include,Abap,我正在写一份包含许多子字段的数据结构的报告。为了避免代码混乱,我将其外包给一个Include,它直接包含在报表语句之后,然后是数据定义 现在我的问题是:当使用INCLUDE中定义的类型作为变量的数据类型时,ABAP编译器会说该类型没有定义。即使codecompletion在使用Eclipse时点击Strg+Space时显示include中的类型 包括: *&------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Include Z_MY_REPORT01_INCLUDE
*&---------------------------------------------------------------------*
types:
begin of first_long_datastructure,
field01 type string,
field02 type string,
....
fieldnn type string,
end of first_long_datastructure,
begin of second_long_datastructure
field01 type string,
field02 type string,
...
fieldnn type string,
end of second_long_datastructure.
报告:
*&---------------------------------------------------------------------*
*& Report Z_MY_REPORT01
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_MY_REPORT01.
include Z_MY_REPORT01_INCLUDE.
data:
lt_first_long_ds type first_long_datastructure,
lt_second_long_ds type second_long_datastructure,
lv_counter type i.
在这种情况下,“未定义”类型第一个\u long\u数据结构。当我将include文件的内容粘贴到sourcecodefile中并删除不必要的include语句时,编译器不再抱怨了。要防止这种奇怪的行为,请遵循以下准则:
- 将所有数据声明放在一个include中
- 名称包括…\u顶部
- 将报告语句放在顶部的include中
INCLUDE z..._top.
INCLUDE z..._F01.
...
REPORT Z...
* Data declarations...
顶部包含的内容如下所示:
INCLUDE z..._top.
INCLUDE z..._F01.
...
REPORT Z...
* Data declarations...
您可以尝试一次激活所有对象吗?我相信它会被激活,不会有任何错误。我觉得自己太傻了。非常感谢。不,你不笨,实际上SAP是。这是SAP的一种奇怪行为,但有一种方法可以防止它(参见我的答案)