*---------------------------------------------------------------------* * CLASS lcl_handle_events DEFINITION * *---------------------------------------------------------------------* CLASS lcl_handle_events DEFINITION. PUBLIC SECTION. METHODS: on_after_refresh FOR EVENT after_refresh OF cl_gui_alv_grid IMPORTING sender, on_user_command FOR EVENT added_function OF cl_salv_events_table IMPORTING e_salv_function. ENDCLASS. *---------------------------------------------------------------------* * CLASS lcl_handle_events IMPLEMENTATION * *---------------------------------------------------------------------* CLASS lcl_handle_events IMPLEMENTATION. METHOD on_after_refresh. DATA: ls_layout TYPE lvc_s_layo, lt_fcat TYPE lvc_t_fcat. FIELD-SYMBOLS:LIKE LINE OF lt_fcat. TRY. SET HANDLER on_after_refresh FOR ALL INSTANCES ACTIVATION space. sender->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = lt_fcat ). sender->register_edit_event( i_event_id = cl_gui_alv_grid=>mc_evt_modified ). LOOP AT lt_fcat ASSIGNING . IF -fieldname EQ 'ZINCSTOCKPREC' OR -fieldname EQ 'ZINCSTOCKSUCC'. -edit = abap_true. ENDIF. ENDLOOP. sender->set_frontend_fieldcatalog( lt_fcat ). * ls_layout-edit = abap_true. "Edit ALL * sender->set_frontend_layout( ls_layout ). sender->set_ready_for_input( 1 ). CATCH cx_salv_error. ENDTRY. ENDMETHOD. ENDCLASS. *----------------------------------------------------------------------* * FORM OUTPUT_ALV * *----------------------------------------------------------------------* FORM output_alv. DATA: lo_content TYPE REF TO cl_salv_form_element. TRY. CASE 'X'. WHEN rb_issr. cl_salv_table=>factory( IMPORTING r_salv_table = go_alv CHANGING t_table = gt_terri[] ). ENDCASE. CATCH cx_salv_msg. ENDTRY. IF go_alv IS BOUND. CREATE OBJECT go_events. CASE 'X'. WHEN rb_cdc OR rb_issr. go_alv->set_screen_status( pfstatus = 'STANDARD_STOCK' report = sy-cprog set_functions = go_alv->c_functions_all ). IF rb_cdc = 'X'. PERFORM set_settings. ELSE. PERFORM build_header CHANGING lo_content. go_alv->set_top_of_list( lo_content ). SET HANDLER go_events->on_after_refresh FOR ALL INSTANCES ACTIVATION 'X'. ENDIF. ENDCASE. SET HANDLER go_events->on_user_command FOR go_alv->get_event( ). go_alv->get_columns( )->set_optimize( 'X' ). go_alv->display( ). ENDIF. ENDFORM.
mercoledì 1 settembre 2021
SALV table editabile
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento