cl_salv_table=>factory(
exporting
list_display = if_salv_c_bool_sap=>true
list_display = if_salv_c_bool_sap=>true
importing
r_salv_table = salv_table
changing
t_table = IT01
).
r_salv_table = salv_table
changing
t_table = IT01
).
cl_salv_table=>factory(
exporting
list_display = if_salv_c_bool_sap=>true
exporting
list_display = if_salv_c_bool_sap=>true
importing
r_salv_table = salv_table
changing
t_table = IT02
).
r_salv_table = salv_table
changing
t_table = IT02
).
cl_salv_table=>factory(
exporting
list_display = if_salv_c_bool_sap=>true
exporting
list_display = if_salv_c_bool_sap=>true
importing
r_salv_table = salv_table
changing
t_table = IT03
).
r_salv_table = salv_table
changing
t_table = IT03
).
For that purposed, we can implement the GET REFERENCE and FIELDS SYMBOLS to solve this problem. Abap Get Reference is used to get itself reference to a data object and places this into the reference variables. Abap Fields Symbols are symbolics names for other fields. For better explanation feel free to google or click on the link given. here are the steps:
- For example for each radio button action, refer chosen internal table using Get Reference method as below. Then call the Method write_alv. (the itstate,itpk and itba is the internal table. p_kpist,p_kpipk and p_kpi_ba is the radio button. o_state, o_pk and o_ba is the object for created classes.)
data: salv_table type ref to cl_salv_table.
data: display_settings type ref to cl_salv_display_settings.
data: mdo_data type ref to data.
data: display_settings type ref to cl_salv_display_settings.
data: mdo_data type ref to data.
if p_kpist = ‘X’.
get reference of o_state->itstate into o_state->mdo_data.
call method o_state->write_alv.
elseif p_kpipk = ‘X’.
get reference of o_pk->itpk into o_pk->mdo_data.
call method o_pk->write_alv.
elseif p_kpiba = ‘X’.
get reference of o_ba->itba into o_ba->mdo_data.
call method o_ba->write_alv.
endif.
get reference of o_state->itstate into o_state->mdo_data.
call method o_state->write_alv.
elseif p_kpipk = ‘X’.
get reference of o_pk->itpk into o_pk->mdo_data.
call method o_pk->write_alv.
elseif p_kpiba = ‘X’.
get reference of o_ba->itba into o_ba->mdo_data.
call method o_ba->write_alv.
endif.
2. Declare field symbols variables as table which it can be suit on any type of internal table. use Abap Assign to link the reference variables into fields symbols.
Method WriteALV.
field-symbols: <lt_outtab> type table.
assign me->mdo_data->* to <lt_outtab>.
cl_salv_table=>factory(
exporting
list_display = if_salv_c_bool_sap=>true
exporting
list_display = if_salv_c_bool_sap=>true
importing
r_salv_table = salv_table
changing
t_table = <lt_outtab>).
r_salv_table = salv_table
changing
t_table = <lt_outtab>).
endmethod.
FINISH!, now we just need to use single ALV method to handle multiple SAP report. Good Luck!
1 comments:
testing commenting
Post a Comment