structure - 从另一个表ABAP动态获取值字段
问题描述
帮我报告 Abap。我有 2 张桌子。
- 伊塔布头
Z1 | Z2 | Z3 |
---|---|---|
一个 | 乙 | C |
- Itab 必填字段
字段名 |
---|
Z2 |
我应该创建一个只有 itab2 字段(itab 必填字段)但 itab head 的值的文件。
该文件将是:
选项卡文件
Z2 |
---|
乙 |
Itab2 告诉我 itab1 的哪个字段是创建 itab 文件的强制性字段。
解决方案
这让您了解如何使用ASSIGN
动态字段选择。
LOOP AT itab_a INTO DATA(wa_itab_a). " your data tab
LOOP AT itab_b INTO DATA(wa_itab_b). " your obligatory field list
TRANSLATE wa_itab_b-fieldname TO UPPER CASE. " important if they are not already in uppercase
ASSIGN COMPONENT wa_itab_b-fieldname OF STRUCTURE wa_itab_a TO FIELD-SYMBOL(<fs_field>).
" ... in <FS_FIELD> you will have the values of the obligatory fields
" so you can concatenate, par example, to file line
CONCATENATE wa_file-line <fs_field> INTO wa_file-line SEPARATED BY c_separator.
ENDLOOP.
" append file line here, something like this:
APPEND wa_file TO itab_file.
CLEAR wa_file.
ENDLOOP.
推荐阅读
- hyperledger-fabric - 在 ubuntu 18.04 LTS 中执行“npm install”命令时出错
- android - NotificationListenerService tickerText 对于某些应用程序是空的
- node.js - 使用异步等待从 csv 文件创建或更新行,创建多行而不是更新
- html - 使body宽度对应于div的存在
- reactjs - React 中的状态是什么?
- android - 当表达式不适用于 onCreateDrawableState 中的枚举类时 - android、kotlin
- javascript - 在快速车把中配置文件扩展名
- css - 如何在 React 中创建平滑的背景图像过渡?
- javascript - 无法将表单数据发布到 API
- c++ - 如何将此等式转换为 C++