cl_salv_bs_runtime_info=>get_data_ref() returns no data

核能气质少年 提交于 2019-12-24 14:23:55

问题


I have this code, which works very nice for a lot of reports:

if IV_SELECTION_SET_VARIANT is INITIAL.
  SUBMIT (IV_REPORT_NAME)
     WITH SELECTION-TABLE selection_table
    AND RETURN.
ELSE.
  SUBMIT (IV_REPORT_NAME)
     WITH SELECTION-TABLE selection_table
     USING SELECTION-SET IV_SELECTION_SET_VARIANT
    AND RETURN.
endif.


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

IF lr_data_descr IS NOT BOUND.
  ev_result_json = '[]'.
  EXIT.
ENDIF.

But for AdHoc Queries the line IF lr_data_descr IS NOT BOUND. is true and ev_result_json is empty.

What could be the reason for this?

The name of the report is AQZZZMM=========ZME80FN=======.


回答1:


The method cl_salv_bs_runtime_info=>get_data_ref provides data only if in your precedent SUBMIT call an ALV grid control had been called, and the writing of the data has been requested before (internally by the submitted report, or explicitly, by calling the method cl_salv_bs_runtime_info=>set beforehand).

  • There are reports which don't call an ALV grid at all: for these, the method won't provide any result data.
  • There are reports (like ABAP queries) where the user himself can determine how to display the data - with an ALV grid control, or as ALV list, or as classical list or even in some other way. If the user chose some other display method than "ALV grid", the method cl_salv_bs_runtime_info=>get_data_ref will give you no data.
  • It may happen that a report which basically should display an ALV grid, doesn't display the grid if it did not select any result data. In these cases, the method cl_salv_bs_runtime_info=>get_data_ref will give you no data.
  • There are reports which display not one but several ALV grid controls at once, with different data. In this case, the method cl_salv_bs_runtime_info=>get_data_ref will retrieve the data from the last displayed ALV grid control (the last grid for which the method SET_TABLE_FOR_FIRST_DISPLAY has been called).


来源:https://stackoverflow.com/questions/55498463/cl-salv-bs-runtime-info-get-data-ref-returns-no-data

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