06-23-2010 12:19 PM
Hi,
i have the standard ALV Grid "toolbar" and if i click to the Button "&LOCAL©_ROW" than i want try to make a Refresh to my ALV Table in the Event "afteruser_command"_!!!!
Here is the implementation of my Event *"afteruser_command":*_
METHOD on_after_user_command.
........DATA: ls_stable TYPE lvc_s_stbl.
.....CASE e_ucomm.
.....WHEN '&LOCAL©_ROW'.
........MESSAGE 'LOCAL_COPY_ROW' TYPE 'S' DISPLAY LIKE 'E'.
........ls_stable-row = 'X'.
........ls_stable-col = 'X'.
........CALL METHOD gr_grid_d0100->refresh_table_display
..............EXPORTING
.......................is_stable = ls_stable
..............EXCEPTIONS
.......................finished = 1
.......................OTHERS = 2.
......ENDCASE.
ENDMETHOD.
But it doesnt work.
Is there another function code for the Copy Button????
Thanks
Ersin
07-07-2010 2:35 PM
Hello Ersin,
the events "after_user_command", "before_user_command" and "user_command" will not be fired when selecting this command!
In my opinion, there is no solution, to fire these events, using this alv-function!
But there is a trick:
1. Register on the event "toolbar" with an own method:
...
toolbar_own for event toolbar of cl_gui_alv_grid
importing e_object
e_interactive,
...
In this method change the function code of "&LOCAL©_ROW", but don´t change the row of the entry, because the button should appear on the same place in the toolbar:
...
field-symbols: <ls_toolbar> type stb_button.
read table e_object->mt_toolbar with key function = '&LOCAL©_ROW'
assigning <ls_toolbar>.
if sy-subrc = 0.
<ls_toolbar>-function = 'COPYROW_OWN'.
endif.
...
2. Register on the event "user_command" ( I think, that´s clear 😞
...
user_cmd_own for event user_command
of cl_gui_alv_grid
importing e_ucomm,
...
( don´t forget the set handler-commands for both events:
set handler po_alv_own->user_cmd_own for po_alv_own.
set handler po_alv_own->toolbar_own for po_alv_own. )
3. Now you can react in the method "user_command" on your own function code:
...
case e_ucomm.
when 'COPYROW_OWN'.
perform copy_row using me
changing gt_bis_cf_out.
...
Sample code for copying the current line:
FORM COPY_ROW using po_alv_own type ref to gcl_alv_own
changing pt_table_alv type gt_table_alv_t.
data: l_index type i,
ls_table_alv type gs_table_alvt_t.
call method po_alv_own->get_current_cell
importing
e_row = l_index.
* e_value =
* e_col =
* es_row_id =
* es_col_id =
* es_row_no =
"read the current line:
read table pt_table_alv index l_index
into ls_table_alv_out.
"some changes for the new row:
clear: ls_table_alv-style,
ls_table_alv-tabix.
"insert the new line:
add 1 to l_index.
insert ls_table_alv into pt_table_alv index l_index.
po_alv_own->refresh( ).
ENDFORM. " COPY_ROW
In this manner the events "after_user_command", "before_user_command" are fired, too!
For information: My problem was, that the ALV-function copied the style-information too, so in the new line, some fields are not editable. At least his field must be cleared!
Best regard
Thomas Scheuermann
06-23-2010 12:40 PM
Hi,
have u checked in debug wat e_ucomm u r getting ? the ucomm which u get is ' %_GC 209 18' check with this ...
06-24-2010 9:20 AM
Hi,
i can´t check the e_ucomm in the debug Modus, because if i click to this local Button than the Events "User_command" and "After_user_command" dont be called.
Which Event can be triggered from the Local function codes (e.g. ' &LOCAL&APPEND ')????
If i overwrite the function code with the toolbar Event to 'LOCAPPEND', than i can trigger the e_ucomm in the "User_command" and "after_user_command".
What is the reason, that local function codes can´t be triggered from Events????
07-07-2010 2:35 PM
Hello Ersin,
the events "after_user_command", "before_user_command" and "user_command" will not be fired when selecting this command!
In my opinion, there is no solution, to fire these events, using this alv-function!
But there is a trick:
1. Register on the event "toolbar" with an own method:
...
toolbar_own for event toolbar of cl_gui_alv_grid
importing e_object
e_interactive,
...
In this method change the function code of "&LOCAL©_ROW", but don´t change the row of the entry, because the button should appear on the same place in the toolbar:
...
field-symbols: <ls_toolbar> type stb_button.
read table e_object->mt_toolbar with key function = '&LOCAL©_ROW'
assigning <ls_toolbar>.
if sy-subrc = 0.
<ls_toolbar>-function = 'COPYROW_OWN'.
endif.
...
2. Register on the event "user_command" ( I think, that´s clear 😞
...
user_cmd_own for event user_command
of cl_gui_alv_grid
importing e_ucomm,
...
( don´t forget the set handler-commands for both events:
set handler po_alv_own->user_cmd_own for po_alv_own.
set handler po_alv_own->toolbar_own for po_alv_own. )
3. Now you can react in the method "user_command" on your own function code:
...
case e_ucomm.
when 'COPYROW_OWN'.
perform copy_row using me
changing gt_bis_cf_out.
...
Sample code for copying the current line:
FORM COPY_ROW using po_alv_own type ref to gcl_alv_own
changing pt_table_alv type gt_table_alv_t.
data: l_index type i,
ls_table_alv type gs_table_alvt_t.
call method po_alv_own->get_current_cell
importing
e_row = l_index.
* e_value =
* e_col =
* es_row_id =
* es_col_id =
* es_row_no =
"read the current line:
read table pt_table_alv index l_index
into ls_table_alv_out.
"some changes for the new row:
clear: ls_table_alv-style,
ls_table_alv-tabix.
"insert the new line:
add 1 to l_index.
insert ls_table_alv into pt_table_alv index l_index.
po_alv_own->refresh( ).
ENDFORM. " COPY_ROW
In this manner the events "after_user_command", "before_user_command" are fired, too!
For information: My problem was, that the ALV-function copied the style-information too, so in the new line, some fields are not editable. At least his field must be cleared!
Best regard
Thomas Scheuermann