2010 Dec 08 9:21 PM
Hello all,
When a workflow work item is executed, a function module is called that displays a screen. The workitem calls a function module that displays an ALV on a screen. The same ALV is displayed for 3 different workitems.
I am changing the field catalog based on certain criteria to set an individual field to be editable/non-editable. I can see that the edit field in the field catalog contains the appropriate value, but the grid does not reflect what is in the field catalog.
The first workitem displays the ALV correctly.
The second and third workitems display the ALV using fieldcat values from the first workitem. The fieldcat contains the correct values when the grid is displayed using method "set_table_for_first_display".
If I log off of SAP and log back on, the second workitem ALV displays with the correct value. But the third workitem now display with the fieldcat values from the second workitem.
If I log off of SAP and log back on, the third workitem ALV displays with the correct value.
Any thought on what I need to do to correct this problem?
This is the logic that creates and displays the ALV in the PBO of the screen of the function module.
clear: il_fieldcat, l_layout.
refresh: il_fieldcat.
free: il_fieldcat.
*
submit balvbufdel and return. " clear ALV buffer
submit bcalv_buffer_del_shared and return. " clear ALV buffer
*
* Create an instance for the event handler
create object gr_event_handler .
*
* Create an instance of the container displayed on screen 1400
create object w_custom_container_1400
exporting container_name = w_container_1400.
*
* Create an instance of the grid displayed in the container
create object w_grid_1400
exporting i_parent = w_custom_container_1400.
* Build fieldcat - edit enabled.
perform build_fieldcat_1400 changing il_fieldcat.
* >> call method w_alv->set_frontend_fieldcatalog after modifying the field ctalog <<
*
call method w_grid_1400->set_frontend_fieldcatalog
exporting
it_fieldcatalog = il_fieldcat.
*
* Disable generic ALV toolbar functions
perform exclude_tb_functions_1400 changing lt_exclude.
*
* Set layout options:
l_layout-grid_title = 'ZFXXU003'.
l_layout-zebra = 'X'.
l_layout-edit_mode = 'X'.
*
set handler gr_event_handler->handle_user_command for w_grid_1400 .
set handler gr_event_handler->handle_toolbar for w_grid_1400 .
set handler gr_event_handler->handle_menu_button for w_grid_1400 .
set handler gr_event_handler->handle_data_changed for w_grid_1400 .
*
data: w_is_variant type disvariant.
*
w_is_variant-report = sy-cprog.
w_is_variant-variant = '/DEFAULT'.
*
call method w_grid_1400->set_table_for_first_display
exporting
i_buffer_active = 'X'
i_bypassing_buffer = 'X'
is_layout = l_layout
it_toolbar_excluding = lt_exclude
i_save = 'A' " enable save option
is_variant = w_is_variant
changing
it_fieldcatalog = il_fieldcat
it_outtab = il_outtab.
*
* set editable cells to ready for input
call method w_grid_1400->set_ready_for_input
exporting
i_ready_for_input = 1.
*
* Register ENTER to raise event DATA_CHANGED.
*
call method w_grid_1400->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
create object w_event_receiver_1400.
set handler w_event_receiver_1400->handle_data_changed
for w_grid_1400.
Edited by: Bruce Tjosvold on Dec 8, 2010 4:21 PM
Edited by: Bruce Tjosvold on Dec 8, 2010 4:24 PM
Edited by: Bruce Tjosvold on Dec 8, 2010 5:04 PM
2010 Dec 08 10:36 PM
Hi Bruce,
You should avoid the creation of the ALV everytime that you need to change the fieldcatalog by calling the method "set_table_for_first_display". Instead, you should call the "refresh_table_display" method.
Regarding the code that you provide to us, it should be something like this:
if ...
* Build fieldcat - edit enabled.
perform build_fieldcat_1400 changing il_fieldcat.
call method w_grid_1400->set_table_for_first_display
exporting
i_buffer_active = 'X'
i_bypassing_buffer = 'X'
is_layout = l_layout
it_toolbar_excluding = lt_exclude
i_save = 'A' " enable save option
is_variant = w_is_variant
changing
*it_fieldcatalog = il_fieldcat* "Here you are specifying your first catalog
it_outtab = il_outtab.
else.
call method w_grid_1400->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2 .
endif.
...
...
...
If you want at this point change the catalog, you should modify the values of it_fieldcat and update it on the existing ALV
call method w_grid_1400->set_frontend_fieldcatalog
exporting
it_fieldcatalog = il_fieldcat.
*
Best regards,
Eric
2010 Dec 08 10:36 PM
Hi Bruce,
You should avoid the creation of the ALV everytime that you need to change the fieldcatalog by calling the method "set_table_for_first_display". Instead, you should call the "refresh_table_display" method.
Regarding the code that you provide to us, it should be something like this:
if ...
* Build fieldcat - edit enabled.
perform build_fieldcat_1400 changing il_fieldcat.
call method w_grid_1400->set_table_for_first_display
exporting
i_buffer_active = 'X'
i_bypassing_buffer = 'X'
is_layout = l_layout
it_toolbar_excluding = lt_exclude
i_save = 'A' " enable save option
is_variant = w_is_variant
changing
*it_fieldcatalog = il_fieldcat* "Here you are specifying your first catalog
it_outtab = il_outtab.
else.
call method w_grid_1400->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2 .
endif.
...
...
...
If you want at this point change the catalog, you should modify the values of it_fieldcat and update it on the existing ALV
call method w_grid_1400->set_frontend_fieldcatalog
exporting
it_fieldcatalog = il_fieldcat.
*
Best regards,
Eric
2010 Dec 08 11:56 PM
Eric,
Thanks for the answer. This is what i changed in the PBO:
IF w_grid_1400 IS INITIAL.
*
PERFORM create_and_init_alv_1400 CHANGING i_alv_1400
w_fieldcat_1400
w_layout_1400.
ELSE.
*
PERFORM refresh_fieldcat CHANGING i_alv_1400
w_fieldcat_1400
w_layout_1400.
*
CALL METHOD w_grid_1400->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
**
ENDIF. " w_grid_1400 IS INITIAL.
Edited by: Bruce Tjosvold on Dec 8, 2010 6:57 PM