Hi priya...
I am sure about its may help you....please mention if you solve your answer..
REPORT ZNKS_TEST19.
*TABLES : SFLIGHT.
type-pools : slis.
data : it_tab type table of SFLIGHT,
wa_tab like line of it_tab.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
g_exit type c,
ispfli type table of spfli.
parameters :
carrid type SFLIGHT-CARRID,
connid type SFLIGHT-CONNID,
date type SFLIGHT-FLDATE,
price type SFLIGHT-PRICE.
data l_where(100) occurs 0 with header line.
start-of-selection.
perform data_retrivel.
perform build_fieldcatalog.
perform display_alv_report.
form build_fieldcatalog .
fieldcatalog-fieldname = 'CARRID'.
fieldcatalog-seltext_m = 'carrid'.
fieldcatalog-col_pos = 0.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'CONNID'.
fieldcatalog-seltext_m = 'connid'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'FLDATE'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PRICE'.
fieldcatalog-seltext_m = 'price'.
fieldcatalog-col_pos = 3.
fieldcatalog-outputlen = 20.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'CURRENCY'.
fieldcatalog-seltext_m = 'currency'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 20.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PLANETYPE'.
fieldcatalog-seltext_m = 'planetype'.
fieldcatalog-col_pos = 5.
fieldcatalog-outputlen = 20.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
form display_alv_report .
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = fieldcatalog[]
i_save = 'X'
* IS_VARIANT = G_VARIANT
tables
t_outtab = it_tab
exceptions
program_error = 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.
endif.
endform. "DISPLAY_ALV_REPORT
form data_retrivel .
if carrid is not initial.
append 'CARRID = carrid' to l_where.
endif.
if connid is not initial.
if l_where is initial.
append ' and ' to l_where.
endif.
append 'CONNID = connid' to l_where.
endif.
if date is not initial.
if l_where is initial.
append ' and ' to l_where.
endif.
append 'FLDATE = date' to l_where.
endif.
if price is not initial.
if l_where is initial.
append ' and ' to l_where.
endif.
append 'PRICE = price' to l_where.
endif.
select * from sflight into corresponding fields of table it_tab
where (l_where).
endform. " DATA_RETRIVEL
form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'Z report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
concatenate sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) into wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
endform.
// Dynamic Selection
Thanks and Regards ,
Niraj Sinha