type-pools: slis.
data: lt_cat type slis_t_fieldcat_alv with header line.
data: lt_spfli type spfli occurs 0 with header line.
data: lt_header type slis_t_listheader with header line,
wa_header like line of lt_header.
data: length type i,
length_c(10),
t_line(50).
start-of-selection.
select * into corresponding fields of table lt_spfli from spfli.
perform create_field_catlog.
perform display_data.
*&---------------------------------------------------------------------*
*& Form create_field_catlog
*&---------------------------------------------------------------------*
form create_field_catlog .
call function'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IT_SPFLI'
i_inclname = sy-repid
i_bypassing_buffer = 'X'
i_buffer_active = ''
changing
ct_fieldcat = lt_cat[].
endform. " CREATE_FIELD_CATLOG
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
form display_data .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_top_of_page = 'FRM_WRITE_HEADER'
it_fieldcat = lt_cat[]
tables
t_outtab = lt_spfli.
endform. " DISPLAY_DATA
*&---------------------------------------------------------------------*
*& Form frm_write_header
*&---------------------------------------------------------------------*
form frm_write_header .
wa_header-typ = 'H'."HEADER
wa_header-info = 'SPFLI Table Report'.
append wa_header to lt_header.
clear wa_header.
wa_header-typ = 'S'."selection
wa_header-key = 'Date:'.
concatenate
sy-datum+6(2)'.'
sy-datum+4(2)'.'
sy-datum(4) into wa_header-info.
append wa_header to lt_header.
clear wa_header.
describe table lt_spfli lines length.
length_c = length.
concatenate 'Total No. of Records Selected:'
length_c into t_line separated by space .
wa_header-typ = 'A'."active
wa_header-info = t_line.
append wa_header to lt_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = lt_header[]
i_logo = 'ENJOYSAP_LOGO'.
endform. " FRM_WRITE_HEADER
评论