2013 Nov 29 2:14 PM
Hi everybody,
I have one tabstrip with 2 tabs and 2 ALV's into them. I have added a new button into the first toolbar tab, and I want the same button on the second ALV (on the second tab as well) but, when I execute the program, a dump shows up.
Here is my code:
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR o_alvgrid1.
SET HANDLER event_receiver->handle_toolbar FOR o_alvgrid1.
CALL METHOD o_alvgrid1->set_toolbar_interactive.
CALL METHOD cl_gui_control=>set_focus EXPORTING control = o_alvgrid1.
SET HANDLER event_receiver->handle_user_command FOR o_alvgrid2.
SET HANDLER event_receiver->handle_toolbar FOR o_alvgrid2.
CALL METHOD o_alvgrid2->set_toolbar_interactive. "------> When I am debugging, the program falls down here.
CALL METHOD cl_gui_control=>set_focus EXPORTING control = o_alvgrid2.
And below the class I have defined:
*---------------------------------------------------------------------*
* Clases
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: event_receiver TYPE REF TO lcl_event_receiver.
*---------------------------------------------------------------------*
* Clases (Definiciones)
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS.
*---------------------------------------------------------------------*
* Clases (Implementaciones)
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 'Traspasos' TO ls_toolbar-function.
MOVE icon_transfer TO ls_toolbar-icon.
MOVE 'Traspaso Fecha Valor'(111) TO ls_toolbar-quickinfo.
MOVE 'Traspasos'(112) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'TRASPASOS'.
CALL METHOD o_alvgrid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc ne 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
else.
perform show_booking_table tables lt_rows.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS.
Here is the dump that triggers:
Thanks in advance for your help.
2013 Dec 02 5:43 AM
The problem may be because the focus of the toolbar is trying to be set for 2 different grids at the same time.At any given point of time in the tabstrip only one screen is active,so the set focus should be of the respective ALV.
For Example : ALV1 is displayed then in the PBO set_toolbar_interactive followed by
CALL METHOD cl_gui_control=>set_focus EXPORTING control = o_alvgrid1 must be done.
Similarly if ALV2 is displayed the CALL METHOD cl_gui_control=>set_focus EXPORTING control = o_alvgrid2 must be done.
This should ideally be done based on the TAB selection.
Hope it helps.
2013 Dec 02 5:28 AM
Hi mario,
I guess the reason could be , try writing create object above the statement where the program falls down.
try create object o_alvgrid2.
Regards,
sivaganesh
2013 Dec 02 8:01 AM
Hi Sivaganesh,
The program doesn't dump anymore, but when I click the first tab, my button appears. Then I push the second tab and my button dissapears, but when I come back to the first tab, my button shows twice.
Any idea about what's going on?
2013 Dec 02 8:28 AM
hi Mario
Basically your code is triggering twice in PBO. Do one thing for each tabstrip you have a sub screen i believe. In each subscreen in PBO do a create grid stuff for corresponding grid only if o_alvgrid1 is initial same goes for other. No need to execute your code again when you comes back to first tab
Nabheet
2013 Dec 02 8:48 AM
Hi mario,
you are allowing the control to create the button twice in PBO. Restrict the control and make sure all the objects get generated only when the grid is initial as suggested .
Regards,
sivaganesh
2013 Dec 02 5:33 AM
2013 Dec 02 5:43 AM
The problem may be because the focus of the toolbar is trying to be set for 2 different grids at the same time.At any given point of time in the tabstrip only one screen is active,so the set focus should be of the respective ALV.
For Example : ALV1 is displayed then in the PBO set_toolbar_interactive followed by
CALL METHOD cl_gui_control=>set_focus EXPORTING control = o_alvgrid1 must be done.
Similarly if ALV2 is displayed the CALL METHOD cl_gui_control=>set_focus EXPORTING control = o_alvgrid2 must be done.
This should ideally be done based on the TAB selection.
Hope it helps.
2013 Dec 02 7:58 AM
Hi Byju,
Where do you suggest to put the CALL METHOD o_alvgrid1->refresh_table_display and where CALL METHOD o_alvgrid2->refresh_table_display?
The program doesn´t dump already, but, when I show the first tab (it shows me the desired button), it runs ok, but when I push the second tab, the button doesn't shows up.
Then, I push the first tab again, and my button shows up twice. I think it's a initializing problem, but I can't find where to put the right code.
Any other idea?
2013 Dec 02 8:51 AM
I would recommend using the statement "CALL METHOD o_alvgridX->set_toolbar_interactive." once during creation or the create object .The respective set focus statement should be in the PBO of the tab Screen which is being called.
Check the sample report BCALV_GRID_07
Although it is not for a tabstrip , the code contains the same functionality.It has 2 screens (100/200 ) where 2 different ALVs are called but in our case it is a tabstrip with 2 screens
in the pgm : module pbo_100 output. , we can see that
"call method grid1->set_toolbar_interactive" . is called once inside the "if custom_container1 is initial" code and the "focus" is set everytime the screen is displayed outside the 'if..endif'
Hope it Helps
2013 Dec 02 5:43 AM
Hi Mario,
Try to create all objects on main screen PBO status modul and then call method set_focus in PBO status modul of each alv grid screen in tabstrip.
2013 Dec 03 7:23 AM
Hi everybody,
Finally, I could solve this issue. All I had to do is put the object out of my displaying procedure and put it into the main, in order to call it just once.
It doesn't goes wrong anymore. Thank all of you guys!!
Mario.