PROGRAM ztestbcalv_edit_01. *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& * Purpose: * ~~~~~~~~ * This report illustrates the simplest case of using an * editable ALV Grid Control. * Background: * ~~~~~~~~~~~ * As far as the edit feature is concerned * a cell of the alv grid control can have the following states: * 1.non-editable : edit feature not set for this cell * 2.editable : edit feature set for this cell * The second state ("editable") has two substates: * 2a.editable and not ready for input:edit feature set but not active * 3b.editable and ready for input :edit feature set and active * In this example, all cells are set "editable". * You switch between "editable and not ready for input" and * "editable and ready for input" using method SET_READY_FOR_INPUT. *----------------------------------------------------------------- * To check program behavior * ~~~~~~~~~~~~~~~~~~~~~~~~~ * Switch the state using the "Display/Change" icon. Initially, * the whole grid is in state "editable and deactivated". * After switching the state you may change values and enter new * lines. No semantic checks are made in this example. *----------------------------------------------------------------- * Essential steps (search for '§') * ~~~~~~~~~~~~~~~ * 1.Set status of all cells to editable using the layout structure. * 2.Use SET_READY_FOR_INPUT to activate the edit feature initially. * (state "editable activated"). * 3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells. * 4.Use SET_READY_FOR_INPUT to switch between the substates. *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DATA: ok_code LIKE sy-ucomm, save_ok LIKE sy-ucomm, g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1', g_grid TYPE REF TO cl_gui_alv_grid, g_custom_container TYPE REF TO cl_gui_custom_container, gs_layout TYPE lvc_s_layo, g_max TYPE i VALUE 100. DATA: gt_outtab TYPE TABLE OF sflight. *---------------------------------------------------------------------* * MAIN * *---------------------------------------------------------------------* CALL SCREEN 100 STARTING AT 1 1.. *---------------------------------------------------------------------* * MODULE PBO OUTPUT * *---------------------------------------------------------------------* MODULE pbo OUTPUT. SET PF-STATUS 'MAIN100'. SET TITLEBAR 'MAIN100'. IF g_custom_container IS INITIAL. CREATE OBJECT g_custom_container EXPORTING container_name = g_container. CREATE OBJECT g_grid EXPORTING i_parent = g_custom_container. *§1.Set status of all cells to editable using the layout structure. gs_layout-edit = 'X'. gs_layout-no_rowins = 'X'. SELECT * FROM sflight INTO TABLE gt_outtab UP TO g_max ROWS. CALL METHOD g_grid->set_frontend_layout EXPORTING is_layout = gs_layout. CALL METHOD g_grid->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' is_layout = gs_layout CHANGING it_outtab = gt_outtab. *§2.Use SET_READY_FOR_INPUT to allow editing initially. * (state "editable and ready for input"). CALL METHOD g_grid->set_ready_for_input EXPORTING i_ready_for_input = 1. ENDIF. ENDMODULE. "pbo OUTPUT