ABAP:通过GUI生成的报告共有18列,通过RFC 6(分层ALV)

时间:2018-11-05 13:42:15

标签: abap

我要导出报告“ RM07MLBS”(tcode mb52)。

如果我通过SAP-GUI调用此报告,则它有18列。

如果我使用以下abap代码调用报告,则该报告仅包含以下列:

  • maktx,werks,matkl,matnr,name1,mtart

这里是abap代码:

FUNCTION /FOO/GET_REPORT_DATA .

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( ).

ENDFUNCTION.

如何获取所有列?

1 个答案:

答案 0 :(得分:1)

用户JozsefSzikszai给了我解决该问题的必要提示。

这样,我可以从分层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.
DATA          lr_data_descr          TYPE REF TO cl_abap_datadescr.
DATA          lr_data_line_descr    TYPE REF TO cl_abap_datadescr.

cl_salv_bs_runtime_info=>get_data_ref(
     IMPORTING r_data_descr      = lr_data_descr
                          r_data_line_descr = 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.

欢迎反馈并提示如何进行改进。