*Display Report
*Declare lt_leave**************************** IF lt_leave IS NOT INITIAL. "Data table
DATA:lit_layout TYPE REF TO cl_salv_layout,
lv_key TYPE salv_s_layout_key,
lo_functions TYPE REF TO cl_salv_functions_list,
lo_columns TYPE REF TO cl_salv_columns_table,
lit_table TYPE REF TO cl_salv_table,
lo_column TYPE REF TO cl_salv_column_table.
* Get the event object
DATA: lo_events TYPE REF TO cl_salv_events_table.
* Instantiate the event handler object
* DATA: lo_event_handler TYPE REF TO lcl_event_handler.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lit_table
CHANGING
t_table = lt_leave )."data table
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
* activate ALV generic Functions
lo_functions = lit_table->get_functions( ).
lo_functions->set_all( abap_true ).
**Allow the user to manage layouts of the ALV grid
lit_layout = lit_table->get_layout( ).
lv_key-report = sy-repid.
lit_layout->set_key( lv_key ).
lit_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
lo_columns = lit_table->get_columns( ).
lo_columns->set_optimize( abap_true ).
* lo_columns->set_key_fixation( ).
*Check box click event
lo_events = lit_table->get_event( ).
*Change the properties of the Columns
* TRY.
* lo_column ?= lo_columns->get_column( columnname = 'STOBJID' ).
* lo_column->set_visible( value = if_salv_c_bool_sap=>false ).
* CATCH cx_salv_not_found . "#EC NO_HANDLER
* ENDTRY.
* CREATE OBJECT lo_event_handler.
*Change column name
* TRY.
* lo_column ?= lo_columns->get_column( 'SCHECK' ).
* lo_column->set_long_text( text-010 ). " Check box Select
* lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
* lo_column->set_output_length( 3 ).
* lo_column->set_key( ).
* lo_column->set_key_presence_required( ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
** event handler
* SET HANDLER lo_event_handler->on_link_click FOR lo_events.
* SET HANDLER lo_event_handler->on_user_cmd FOR lo_events.
*display the table
lit_table->display( ).
*Declare lt_leave**************************** IF lt_leave IS NOT INITIAL. "Data table
DATA:lit_layout TYPE REF TO cl_salv_layout,
lv_key TYPE salv_s_layout_key,
lo_functions TYPE REF TO cl_salv_functions_list,
lo_columns TYPE REF TO cl_salv_columns_table,
lit_table TYPE REF TO cl_salv_table,
lo_column TYPE REF TO cl_salv_column_table.
* Get the event object
DATA: lo_events TYPE REF TO cl_salv_events_table.
* Instantiate the event handler object
* DATA: lo_event_handler TYPE REF TO lcl_event_handler.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lit_table
CHANGING
t_table = lt_leave )."data table
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
* activate ALV generic Functions
lo_functions = lit_table->get_functions( ).
lo_functions->set_all( abap_true ).
**Allow the user to manage layouts of the ALV grid
lit_layout = lit_table->get_layout( ).
lv_key-report = sy-repid.
lit_layout->set_key( lv_key ).
lit_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
lo_columns = lit_table->get_columns( ).
lo_columns->set_optimize( abap_true ).
* lo_columns->set_key_fixation( ).
*Check box click event
lo_events = lit_table->get_event( ).
*Change the properties of the Columns
* TRY.
* lo_column ?= lo_columns->get_column( columnname = 'STOBJID' ).
* lo_column->set_visible( value = if_salv_c_bool_sap=>false ).
* CATCH cx_salv_not_found . "#EC NO_HANDLER
* ENDTRY.
* CREATE OBJECT lo_event_handler.
*Change column name
* TRY.
* lo_column ?= lo_columns->get_column( 'SCHECK' ).
* lo_column->set_long_text( text-010 ). " Check box Select
* lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
* lo_column->set_output_length( 3 ).
* lo_column->set_key( ).
* lo_column->set_key_presence_required( ).
* CATCH cx_salv_not_found. "#EC NO_HANDLER
* ENDTRY.
** event handler
* SET HANDLER lo_event_handler->on_link_click FOR lo_events.
* SET HANDLER lo_event_handler->on_user_cmd FOR lo_events.
*display the table
lit_table->display( ).
No comments:
Post a Comment