The class CL_SALV_TABLE provides flexible way of displaying of list alv/grid alv or container grid alv.
Step1. Create the below program.
-----------------------------------------------------------------------------------------------------
CLASS lcl_salv_tab DEFINITION.
PUBLIC SECTION.
CLASS-METHODS : main IMPORTING
i_list TYPE xfeld
i_grid TYPE xfeld
i_con_grid TYPE xfeld,
fetch_records,
get_alv_instance IMPORTING
i_list TYPE xfeld
i_grid TYPE xfeld
i_con_grid TYPE xfeld,
display_alv.
PRIVATE SECTION.
CLASS-DATA : lt TYPE TABLE OF sflight,
lo_salv_tab TYPE REF TO cl_salv_table,
o_cust TYPE REF TO cl_gui_custom_container.
ENDCLASS.
CLASS lcl_salv_tab IMPLEMENTATION.
METHOD main.
fetch_records( ).
get_alv_instance( EXPORTING i_list = i_list
i_grid = i_grid
i_con_grid = i_con_grid ).
IF i_list EQ 'X' OR i_grid = 'X'.
display_alv( ).
ENDIF.
ENDMETHOD.
METHOD fetch_records.
SELECT * FROM sflight INTO TABLE lt UP TO 20 ROWS.
ENDMETHOD.
METHOD get_alv_instance.
DATA : flag.
IF i_list = 'X' OR i_grid = 'X'.
IF i_list = 'X'.
flag = 'X'.
ELSE.
flag = ' '.
ENDIF.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = flag
IMPORTING
r_salv_table = lo_salv_tab
CHANGING
t_table = lt.
CATCH cx_salv_msg .
ENDTRY.
ELSEIF i_con_grid = 'X'.
CREATE OBJECT o_cust
EXPORTING
container_name = 'CONT'.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_cust
IMPORTING
r_salv_table = lo_salv_tab
CHANGING
t_table = lt.
CATCH cx_salv_msg .
ENDTRY.
CALL SCREEN 0001.
ENDIF.
ENDMETHOD.
METHOD display_alv.
CALL METHOD lo_salv_tab->display.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS : list RADIOBUTTON GROUP g1,
grid RADIOBUTTON GROUP g1,
con_grid RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b1.
CALL METHOD lcl_salv_tab=>main EXPORTING
i_list = list
i_grid = grid
i_con_grid = con_grid.
MODULE status_0001 OUTPUT.
lcl_salv_tab=>display_alv( ).
ENDMODULE. " status_0001 OUTPUT
-----------------------------------------------------------------------------------------------------
Step2. Screen flow logic in case of alv displayed on the custom container.
Step3. Custom container element on the screen.
Step4.0 Run1 with list alv as o/p.
Step4.1
Step4.2 Run2 with grid alv as o/p.
Step4.3 O/P as alv grid.
Step4.4 Run3 with container grid alv as o/p.
Step4.5 ALV grid o/p on the screen container.
---------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment