本文介绍了通过 GUI 调用的分层 ALV 报告有 18 列,但通过 RFC 只有 6 列.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想导出报告 RM07MLBS
(tcode mb52).如果我通过 SAP-GUI 调用这个报告,它有 18 列,如果我用下面的代码调用它,它只返回 maktx, werks, matkl, matnr, name1, mtart
列:>
I want to export the report RM07MLBS
(tcode mb52). If I call this report via the SAP-GUI it has 18 columns, and if I call it with the following code, it returns only maktx, werks, matkl, matnr, name1, mtart
columns:
cl_salv_bs_runtime_info=>set(
EXPORTING
display = abap_false
metadata = abap_false
data = abap_true
).
SUBMIT (IV_REPORT_NAME)
WITH SELECTION-TABLE selection_table
AND RETURN.
DATA: lo_data TYPE REF TO data.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lo_data ).
IF lo_data IS NOT BOUND.
ev_result_json = '[]'.
EXIT.
ENDIF.
field-SYMBOLS <lv_data> type any table.
ASSIGN lo_data->* TO <lv_data>.
ev_result_json = /ui2/cl_json=>serialize( data = <lv_data> pretty_name = /ui2/cl_json=>pretty_mode-low_case ).
cl_salv_bs_runtime_info=>clear_all( ).
如何获取所有列?
推荐答案
用户 JozsefSzikszai 给了我解决此问题所需的提示.
User JozsefSzikszai gave me the needed hint to solve this.
这样我就可以从分层 ALV 中读取所有列
This way I can read all columns from hierarchical ALV
SUBMIT (IV_REPORT_NAME)
WITH SELECTION-TABLE selection_table
AND RETURN.
FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.
FIELD-SYMBOLS <lt_data_line> TYPE ANY TABLE.
DATA lr_data TYPE REF TO data.
DATA lr_data_line TYPE REF TO data.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data_descr = DATA(lr_data_descr)
r_data_line_descr = DATA(lr_data_line_descr) ).
CREATE DATA lr_data TYPE HANDLE lr_data_descr.
CREATE DATA lr_data_line TYPE HANDLE lr_data_line_descr.
ASSIGN lr_data->* TO <lt_data>.
ASSIGN lr_data_line->* TO <lt_data_line>.
cl_salv_bs_runtime_info=>get_data(
IMPORTING
t_data = <lt_data>
t_data_line = <lt_data_line>
).
IF <lt_data> IS INITIAL.
ev_result_json = '[]'.
EXIT.
ENDIF.
ev_result_json = /ui2/cl_json=>serialize( data = <lt_data_line> pretty_name = /ui2/cl_json=>pretty_mode-low_case ).
cl_salv_bs_runtime_info=>clear_all( ).
ENDFUNCTION.
欢迎反馈和提示如何改进这一点.
Feedback and hints how to improve this are welcome.
这篇关于通过 GUI 调用的分层 ALV 报告有 18 列,但通过 RFC 只有 6 列.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!