1、使用标准ALV类方法
数据定义
field-symbols : <lt_pay_data> type any table .
field-symbols : <lt_test> type any . "LIKE LINE OF it_tab .
data lr_pay_data type ref to data.
具体用法
cl_salv_bs_runtime_info=>set( exporting display = abap_false
metadata = abap_false
data = abap_true ).
submit zwm001 with selection-table lt_sel_tab exporting list to memory and return.
try.
cl_salv_bs_runtime_info=>get_data_ref( importing r_data = lr_pay_data ).
assign lr_pay_data->* to <lt_pay_data>.
catch cx_salv_bs_sc_runtime_info.
message `Unable to retrieve ALV data` type 'E'.
endtry.
cl_salv_bs_runtime_info=>clear_all( ).
cl_demo_output=>display_data( <lt_pay_data> ).
2、使用memory
submit zwm001 with selection-table lt_sel_tab exporting list to memory and return.
call function 'LIST_FROM_MEMORY'
tables
listobject = lt_list
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
call function 'LIST_TO_ASCI'
* EXPORTING
* LIST_INDEX = -1
* WITH_LINE_BREAK = ' '
tables
listasci = t_ascilist
listobject = lt_list
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
" write:/ 'Below are the lines from the submitted program.'.
" loop at t_ascilist.
" write:/ t_ascilist-line.
" endloop.
" skip 2.
endif.
endif.