Hi Everyone,
I am using one custom report which is creating an editable (2 columns) ALV. In this report I am not using the events data_changed OR data_changed_finished to capture the changes done on the screen and the update the internal table. But still, the data in the internal table is getting updated in the backend when seen in the debugger. I want to know why ??
Below is the source code of the report:
REPORT zdummy_p.
*********************************************************************************************************************
TABLES : sflight.
DATA: lv_fldate TYPE s_date,
custom_container TYPE REF TO cl_gui_custom_container.
SELECT-OPTIONS : s_fldate FOR lv_fldate.
* For ALV output
TYPES : BEGIN OF ty_sflight,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
fldate TYPE s_date,
price TYPE s_price,
currency TYPE s_currcode,
planetype TYPE s_planetye,
checkbox TYPE char1,
END OF ty_sflight.
DATA : gt_sflight TYPE STANDARD TABLE OF ty_sflight,
gt_fcat TYPE lvc_t_fcat,
gw_layout TYPE lvc_s_layo,
gr_alv TYPE REF TO cl_gui_alv_grid,
gt_exclude TYPE ui_functions.
FIELD-SYMBOLS : <fs_sflight> TYPE ty_sflight.
* Event handler class for ALV
CLASS lcl_alvhandler DEFINITION.
PUBLIC SECTION.
METHODS:
me_handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object,
me_handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. “”lcl_alvhandler DEFINITION
DATA : gr_alvhandler TYPE REF TO lcl_alvhandler.
START-OF-SELECTION.
* Extracting to populate ALV table
SELECT carrid
connid
fldate
price
currency
planetype
FROM sflight INTO TABLE gt_sflight
WHERE fldate IN s_fldate.
IF sy-subrc IS INITIAL.
* Populate Fieldcatalog and Exclude alv buttons which are not required
PERFORM f_field_cat.
* Calling screen 9000 to display ALV
CALL SCREEN 9000.
ENDIF.
*&———————————————————————*
*& Form F_FCAT
*&———————————————————————*
FORM f_field_cat.
DATA lv_pos TYPE i.
REFRESH :gt_fcat[],gt_exclude[].
APPEND cl_gui_alv_grid=>mc_fc_loc_delete_row TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_views TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_paste_new_row TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_copy_row TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_copy TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_cut TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_refresh TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_mb_paste TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_loc_undo TO gt_exclude.
APPEND cl_gui_alv_grid=>mc_fc_check TO gt_exclude.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘CHECKBOX’ ‘Select’.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘CARRID’ ‘Airline Code’.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘CONNID’ ‘Connection Number’.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘FLDATE’ ‘Flight date’.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘PRICE’ ‘Airfare’.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘CURRENCY’ ‘Currency ‘.
lv_pos = lv_pos + 1.
PERFORM f_fcat USING lv_pos ‘PLANETYPE’ ‘Aircraft Type’.
ENDFORM. “f_field_cat
*&———————————————————————*
*& Form F_FCAT
*&———————————————————————*
FORM f_fcat USING p_pos
p_fname
p_text.
DATA : gw_fcat TYPE lvc_s_fcat.
CLEAR gw_fcat.
gw_fcat-fieldname = p_fname.
gw_fcat-col_pos = p_pos.
gw_fcat-coltext = p_text.
IF p_fname = ‘CHECKBOX’.
gw_fcat-edit = abap_true.
gw_fcat-checkbox = abap_true.
gw_fcat-key = abap_true.
ELSEIF p_fname = ‘CARRID’ OR
p_fname = ‘CONNID’ OR
p_fname = ‘FLDATE’.
gw_fcat-key = abap_true.
ELSEIF p_fname = ‘PRICE’.
gw_fcat-edit = abap_true.
gw_fcat-datatype = ‘DECIMAL’.
ENDIF.
APPEND gw_fcat TO gt_fcat.
CLEAR : gw_fcat.
ENDFORM. “” F_FCAT
*&———————————————————————*
*& Module STATUS_9000 OUTPUT
*&———————————————————————*
* text
*———————————————————————-*
MODULE status_9000 OUTPUT.
SET PF-STATUS ‘Z9000’.
SET TITLEBAR ‘Z9000’.
PERFORM f_display.
ENDMODULE. “status_9000 OUTPUT
*&———————————————————————*
*& Form f_display
*&———————————————————————*
* text
*———————————————————————-*
FORM f_display .
IF gr_alv IS INITIAL.
CREATE OBJECT gr_alv
EXPORTING
i_parent = custom_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF gr_alv IS NOT INITIAL.
CALL METHOD gr_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
IF gr_alvhandler IS INITIAL.
CREATE OBJECT gr_alvhandler.
ENDIF.
SET HANDLER gr_alvhandler->me_handle_toolbar FOR gr_alv.
SET HANDLER gr_alvhandler->me_handle_user_command FOR gr_alv.
gw_layout-cwidth_opt = abap_true.
gw_layout-sel_mode = ‘A’.
CALL METHOD gr_alv->set_table_for_first_display
EXPORTING
i_save = ‘A’
is_layout = gw_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_sflight
it_fieldcatalog = gt_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ELSE.
CALL METHOD gr_alv->refresh_table_display.
ENDIF.
ENDFORM. “”f_display
*———————————————————————-*
* CLASS lcl_alvhandler IMPLEMENTATION
*———————————————————————-*
*
*———————————————————————-*
CLASS lcl_alvhandler IMPLEMENTATION.
METHOD me_handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
* Append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
* Append Button & Icon for your function
MOVE ‘SELALL’ TO ls_toolbar-function.
MOVE icon_select_all TO ls_toolbar-icon.
MOVE ‘Select All’ TO ls_toolbar-quickinfo.
MOVE ‘Select All’ TO ls_toolbar-text.
MOVE ‘ ‘ TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE ‘DESELALL’ TO ls_toolbar-function.
MOVE icon_deselect_all TO ls_toolbar-icon.
MOVE ‘Deselect All’ TO ls_toolbar-quickinfo.
MOVE ‘Deselect All’ TO ls_toolbar-text.
MOVE ‘ ‘ TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
ENDMETHOD. “”me_handle_toolbar
METHOD me_handle_user_command.
CASE e_ucomm.
WHEN ‘SELALL’.
DATA : i_filter_entries TYPE lvc_t_fidx, “Filtered entries,
gv_sel_valid TYPE char1,
gv_sel_tabix TYPE sy-tabix.
IF gr_alv IS NOT INITIAL.
CALL METHOD gr_alv->check_changed_data
IMPORTING
e_valid = gv_sel_valid.
ENDIF.
IF gv_sel_valid EQ ‘X’.
CALL METHOD gr_alv->get_filtered_entries
IMPORTING
et_filtered_entries = i_filter_entries.
UNASSIGN <fs_sflight>.
LOOP AT gt_sflight ASSIGNING <fs_sflight>.
gv_sel_tabix = sy-tabix.
READ TABLE i_filter_entries FROM gv_sel_tabix TRANSPORTING NO FIELDS.
IF sy-subrc IS NOT INITIAL.
<fs_sflight>-checkbox = abap_true.
ENDIF.
ENDLOOP.
* Refresh output
PERFORM f_refresh_alv.
ENDIF.
WHEN ‘DESELALL’.
UNASSIGN <fs_sflight>.
LOOP AT gt_sflight ASSIGNING <fs_sflight>.
<fs_sflight>-checkbox = abap_false.
ENDLOOP.
* Refresh output
PERFORM f_refresh_alv.
ENDCASE.
ENDMETHOD. “”me_handle_user_command
ENDCLASS. “”lcl_alvhandler IMPLEMENTATION
*&———————————————————————*
*& Form F_REFRESH_ALV
*&———————————————————————*
FORM f_refresh_alv.
DATA : lw_stable TYPE lvc_s_stbl.
CLEAR : lw_stable.
lw_stable-row = abap_true.
lw_stable-col = abap_true.
gr_alv->refresh_table_display(
EXPORTING
is_stable = lw_stable
EXCEPTIONS
finished = 1
OTHERS = 2 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. “f_refresh_alv
*&———————————————————————*
*& Module USER_COMMAND_9000 INPUT
*&———————————————————————*
MODULE user_command_9000 INPUT.
CASE sy-ucomm.
WHEN ‘BACK’ OR ‘CANCEL’ OR ‘EXIT’.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. “user_command_9000 INPUT
Screen:
Thanks in advance !!