2015 Nov 04 11:08 AM
Dears ,
iam using cl_gui_alv_grid alv and iam ovride the standard fn code for APPEND_Row in the toolbar and handle it in the user command method
but i face problem when using HANDLE_DATA_CHANGED_finished method , it triggers when i click append button instead of the user command method and the user command works fine if i comment ' SET HANDLER: LCL_EVENT_RECEIVER=>HANDLE_DATA_CHANGED_finished FOR ALV1 '
this my code
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells.
CLASS-METHODS :
HANDLE_HOTSPOT FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO SENDER.
CLASS-METHODS : handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
CLASS-METHODS : handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object
e_interactive
sender.
ENDCLASS .
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION .
METHOD HANDLE_HOTSPOT .
* BREAK ABAP1.
ENDMETHOD.
METHOD handle_data_changed_finished.
*break ECC_ABAP1.
DATA: wa_et_good_cells LIKE LINE OF et_good_cells ,
wa_good_cells LIKE LINE OF et_good_cells .
break ecc_abap1.
READ TABLE et_good_cells INTO wa_good_cells INDEX 1.
CLEAR BSEG-DMBTR .
LOOP AT IT_MAIN ASSIGNING <FS> WHERE CHECk = 'X'.
BSEG-DMBTR = BSEG-DMBTR + <FS>-DMBTR .
ENDLOOP.
ENDMETHOD .
METHOD handle_user_command.
BREAK-POINT.
IF e_ucomm = 'APPEND_ROW'.
APPEND INITIAL LINE TO IT_MAIN .
PERFORM cell_edit .
CALL METHOD ALV1->REFRESH_TABLE_DISPLAY.
ENDIF.
ENDMETHOD . "H
METHOD handle_toolbar .
BREAK-POINT.
DATA: ls_button TYPE stb_button.
LOOP AT e_object->mt_toolbar INTO ls_button.
CASE ls_button-function.
when cl_gui_alv_grid=>MC_FC_LOC_APPEND_ROW.
ls_button-function = 'APPEND_ROW'.
MODIFY e_object->mt_toolbar FROM ls_button INDEX syst-tabix.
ENDCASE .
ENDLOOP.
ENDMETHOD.
ENDCLASS.
:-----------------------------------------------------------------------------------
in PBO
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
* SET TITLEBAR 'xxx'.
*BREAK ECC_ABAP1 .
IF custom_container1 IS INITIAL.
CREATE OBJECT custom_container1
EXPORTING
container_name = 'CC1'.
IF alv1 is INITIAL.
CREATE OBJECT alv1
EXPORTING
i_parent = custom_container1.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'ZFI_BANK_STRUCTURE2'
* I_CLIENT_NEVER_DISPLAY = 'X'
** I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME = 'IT_MAIN'
CHANGING
ct_fieldcat = FC
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3 .
LOOP AT FC ASSIGNING <FS_FC> .
IF <FS_FC>-FIELDNAME = 'CHECK'.
<FS_FC>-CHECKBOX = 'X'.
<FS_FC>-EDIT = 'X'.
ENDIF.
ENDLOOP .
GS_LAYO-EDIT_MODE = '1'.
GS_LAYO-stylefname = 'CELLSTYLES'.
*PERFORM cell_edit.
CALL METHOD alv1->set_table_for_first_display
EXPORTING
* i_structure_name = 'ZSD_AVERAGE_CHANGES'
is_layout = GS_LAYO
I_SAVE = 'A'
* IS_VARIANT = variant
CHANGING
it_outtab = IT_MAIN[]
it_fieldcatalog = FC
.
SET HANDLER : lcl_event_receiver=>handle_user_command FOR ALL INSTANCES.
SET HANDLER : lcl_event_receiver=>handle_toolbar FOR ALL INSTANCES .
CALL METHOD alv1->set_toolbar_interactive.
SET HANDLER: LCL_EVENT_RECEIVER=>HANDLE_DATA_CHANGED_finished FOR ALV1 .
* SET HANDLER : lcl_event_receiver=>HANDLE_HOTSPOT FOR ALV1.
CALL METHOD ALV1->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
ENDIF.
else.
CALL METHOD alv1->refresh_table_display.
endif.
ENDMODULE.
2015 Nov 04 12:36 PM
You shouldn't be able to "intercept" the function code in event user_command, better handle event before_user_command, there add your own code and reset function code to space with method set_user_command.
Hint: For reference see Changing Standard Functions.
Regards,
Raymond
Hi Lyam,
are you sure add button to ALV TOOLBAR. If button is at Screen Toolbar, you have to use PAI module.
2015 Nov 04 11:38 AM
Hi Lyam,
Can you try write CALL METHOD cl_gui_cfw=>set_new_ok_code('REFRESH'). instead of CALL METHOD ALV1->REFRESH_TABLE_DISPLAY in METHOD handle_user_command.
2015 Nov 04 11:45 AM
when i click append button it doesn't trigger the user command but data changed finished.
2015 Nov 04 1:04 PM
Hi Lyam,
are you sure add button to ALV TOOLBAR. If button is at Screen Toolbar, you have to use PAI module.
2015 Nov 04 12:36 PM
You shouldn't be able to "intercept" the function code in event user_command, better handle event before_user_command, there add your own code and reset function code to space with method set_user_command.
Hint: For reference see Changing Standard Functions.
Regards,
Raymond
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |