types - INCLUDE 中的声明在主程序中不被识别
问题描述
我正在编写一份报告,其中包含许多具有许多子字段的数据结构。为了避免弄乱我的代码,我将它外包给了一个 Include,它直接包含在 REPORT 语句之后,然后是 DATA 定义。
现在我的问题:当使用 INCLUDE 中定义的类型作为我的变量的数据类型时,ABAP 编译器说该类型没有定义。即使代码完成向我显示了使用 Eclipse 时点击 Strg+Space 时包含的类型。
包括:
*&---------------------------------------------------------------------*
*& 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.
在这种情况下,类型first_long_datastructure “未定义”。当我将包含文件的内容粘贴到我的源代码文件中并删除不必要的包含语句时,编译器不再抱怨了。
解决方案
为了防止这种奇怪的行为,请遵循以下准则:
- 将所有数据声明放入一个包含中。
- 将其命名为 ..._TOP
- 将 REPORT 语句放入 TOP 包含中。
所以主程序将如下所示:
INCLUDE z..._top.
INCLUDE z..._F01.
...
TOP 包含将如下所示:
REPORT Z...
* Data declarations...
推荐阅读
- d3.js - D3 力有向图 - 如何过滤节点和关联链接?
- react-native - 在 React-Native 上实现 Google Cloud Speech-to-Text
- javascript - React Set State From CountDown Child
- ios - 无法在 tabBarControllerVC 上以编程方式设置选项卡栏项目文本
- javascript - Vuejs 上的动态表单输入
- javascript - 如何在角度6中动态添加输入字段
- java - 无法启动服务 jboss.undertow.deployment.default-server.default-host
- azure-devops - 使用 Azure DevOps REST Api 如何通过其内部版本号获取构建,除非列出所有构建?
- python - 如何在 Windows 资源管理器中输入文本字段?
- reactjs - React 不会导入我的模块“找不到模块:无法解析”