ABAP: Report via GUI has 18 columns, via RFC 6 (hierarchical ALV)

纵饮孤独 提交于 2019-12-11 17:32:36

问题


I want to export the report "RM07MLBS" (tcode mb52).

If I call this report via the SAP-GUI it has 18 columns.

If I call the report with the following abap code, then it has only these column:

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

Here the abap code:

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.

How to get all columns?


回答1:


User JozsefSzikszai gave me the needed hint to solve this.

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

Feedback and hints how to improve this are welcome.



来源:https://stackoverflow.com/questions/53155582/abap-report-via-gui-has-18-columns-via-rfc-6-hierarchical-alv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!