‎2005 Mar 28 9:42 PM
In my program which allows to edit records and then save into a table using ALV grid, I am using CL_GUI_ALV_GRID=>MC_EVT_ENTER to trigger the DATA_CHANGED event. Also I am showing the SAVE button using the TOOLBAR event in the ALV's toolbar and not on the GUI status of the program. What I intend to achieve is as follows;
After editing or entering new data and then hitting the "CHECK" button which inturn triggers the DATA_CHANGED event in which I capture the changed/new data, then I would like to enable the SAVE button, until then it is disabled. Any ideas on how would I achieve this? Any event or method that I can invoke?
‎2005 Mar 28 10:54 PM
Code an event receiver with a method to handle the toolbar.
LOCAL CLASSES: Definition
****************************************************************
lcl_event_receiver (Definition)
*===============================================================
CLASS lcl_event_receiver DEFINITION DEFERRED.
class lcl_event_receiver: local class to
handle your own functions.
Definition:
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
PRIVATE SECTION.
ENDCLASS.
Define event receiver reference variable
data:
event_receiver TYPE REF TO lcl_event_receiver.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
DATA: ls_toolbar TYPE stb_button.
*....................................................................
E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
This class has got one attribute, MT_TOOLBAR, which
is a table of type TTB_BUTTON. One line of this table is
defined by the Structure STB_BUTTON (see data declaration above).
*
A remark to the flag E_INTERACTIVE:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'e_interactive' is set, if this event is raised due to
the call of 'set_toolbar_interactive' by the user.
You can distinguish this way if the event was raised
by yourself or by ALV
(e.g. in method 'refresh_table_display').
An application of this feature is still unknown...
append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to show booking table
CLEAR ls_toolbar.
MOVE 'CONVERT' TO ls_toolbar-function.
MOVE icon_employee TO ls_toolbar-icon.
MOVE 'Base Unit/Lbs'(111) TO ls_toolbar-quickinfo.
MOVE 'Base/Lbs'(112) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. <<<this is where you would enable the save button
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
*********************
in PBO
Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
*
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR r_grid_det.
SET HANDLER event_receiver->handle_toolbar FOR r_grid_det.
Call method 'set_toolbar_interactive' to raise event TOOLBAR.
raise event TOOLBAR:
CALL METHOD r_grid_det->set_toolbar_interactive.
Message was edited by: Tom01
‎2005 Mar 28 10:54 PM
Code an event receiver with a method to handle the toolbar.
LOCAL CLASSES: Definition
****************************************************************
lcl_event_receiver (Definition)
*===============================================================
CLASS lcl_event_receiver DEFINITION DEFERRED.
class lcl_event_receiver: local class to
handle your own functions.
Definition:
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
PRIVATE SECTION.
ENDCLASS.
Define event receiver reference variable
data:
event_receiver TYPE REF TO lcl_event_receiver.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
DATA: ls_toolbar TYPE stb_button.
*....................................................................
E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
This class has got one attribute, MT_TOOLBAR, which
is a table of type TTB_BUTTON. One line of this table is
defined by the Structure STB_BUTTON (see data declaration above).
*
A remark to the flag E_INTERACTIVE:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'e_interactive' is set, if this event is raised due to
the call of 'set_toolbar_interactive' by the user.
You can distinguish this way if the event was raised
by yourself or by ALV
(e.g. in method 'refresh_table_display').
An application of this feature is still unknown...
append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to show booking table
CLEAR ls_toolbar.
MOVE 'CONVERT' TO ls_toolbar-function.
MOVE icon_employee TO ls_toolbar-icon.
MOVE 'Base Unit/Lbs'(111) TO ls_toolbar-quickinfo.
MOVE 'Base/Lbs'(112) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled. <<<this is where you would enable the save button
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
*********************
in PBO
Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
*
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR r_grid_det.
SET HANDLER event_receiver->handle_toolbar FOR r_grid_det.
Call method 'set_toolbar_interactive' to raise event TOOLBAR.
raise event TOOLBAR:
CALL METHOD r_grid_det->set_toolbar_interactive.
Message was edited by: Tom01
‎2005 Mar 28 10:56 PM
Hi Kshitij
Calling the method <b>"set_toolbar_interactive"</b> should trigger the event <b>"toolbar"</b> where you can control states for your buttons.
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>