09-21-2011 10:40 PM
Hey there,
I have an ALV grid displaying purchase order information. When you double-click, it takes you to the transaction ME22N. I have enhanced ME22N's screen to include a checkbox on the screen that is tied to a custom field in the EKKO table. I have verified that the EKKO field is getting updated correctly whenever the checkbox is changed, however my ALV grid will not refresh to display the changes made. I have been putting the code directly after the CALL TRANSACTION ME22N line in the user event block. I have also tried putting it in the ALV screen's PDO module. I have gotten the internal table that I use to create the ALV grid to reflect the changes, but the actual grid display is still showing the old information. I have tried using REFRESH_TABLE_DISPLAY and I am having no luck. The ALV display does refresh if I back out to the selection screen and execute the report again. Am I forgetting to do something to the container? Do I need to free the grid first (which I have tried)? I know there are similar threads on SDN pertaining to this issue, but none of the ones I have found so far have solved my problem. I am creating the ALV using the object-oriented method. Any help would be greatly appreciated.
Here is my code for setting the ALV container.
FORM alv_set_container.
Create ALV object if it does not already exist
IF cl_custom_container IS INITIAL.
CREATE OBJECT cl_custom_container
EXPORTING
container_name = 'ALV_CONTAINER'.
CREATE OBJECT cl_alv_grid
EXPORTING
i_parent = cl_custom_container.
Build the ALV field catalog
PERFORM alv_build_field_cat TABLES it_alv_field_cat.
Build the ALV sort tables
PERFORM alv_build_sort TABLES it_alv_sort.
Set the ALV layout
PERFORM alv_set_layout USING wa_alv_layout.
Set the ALV variant
PERFORM alv_set_variant USING wa_alv_variant.
Set the ALV save setting
PERFORM alv_set_save USING w_save.
Load data into the grid and display them
CALL METHOD cl_alv_grid->set_table_for_first_display
EXPORTING
is_layout = wa_alv_layout
is_variant = wa_alv_variant
i_save = w_save
CHANGING
it_outtab = it_ekko
it_fieldcatalog = it_alv_field_cat
it_sort = it_alv_sort.
Create events for this object
CREATE OBJECT cl_event.
SET HANDLER cl_event->double_click FOR cl_alv_grid.
SET HANDLER cl_event->handle_top_of_list FOR cl_alv_grid.
SET HANDLER cl_event->handle_top_of_page FOR cl_alv_grid.
ELSE.
Table has already been created so refresh it
PERFORM get_data.
CALL METHOD cl_alv_grid->refresh_table_display.
ENDIF.
ENDFORM. " alv_set_container
09-22-2011 3:59 AM
Hi John,
In this line of your code,
ELSE.
* Table has already been created so refresh it
PERFORM get_data.
CALL METHOD cl_alv_grid->refresh_table_display.
ENDIF.
Please add the following lines:
PERFORM get_data. "this is you present code. insert here beforerefreshing the ALV display
DATA: lwa_ref TYPE lvc_s_stbl..
IF cl_alv_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = cl_alv_grid.
IF sy-subrc EQ 0.
* do nothing
ENDIF.
ENDIF.
IF NOT cl_alv_grid IS INITIAL.
CALL METHOD cl_alv_grid->refresh_table_display
EXPORTING
is_stable = lwa_ref
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc = 0 .
"do nothing
ENDIF.
ENDIF.
Edited by: levis 501 on Sep 22, 2011 5:00 AM
09-22-2011 3:59 AM
Hi John,
In this line of your code,
ELSE.
* Table has already been created so refresh it
PERFORM get_data.
CALL METHOD cl_alv_grid->refresh_table_display.
ENDIF.
Please add the following lines:
PERFORM get_data. "this is you present code. insert here beforerefreshing the ALV display
DATA: lwa_ref TYPE lvc_s_stbl..
IF cl_alv_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = cl_alv_grid.
IF sy-subrc EQ 0.
* do nothing
ENDIF.
ENDIF.
IF NOT cl_alv_grid IS INITIAL.
CALL METHOD cl_alv_grid->refresh_table_display
EXPORTING
is_stable = lwa_ref
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc = 0 .
"do nothing
ENDIF.
ENDIF.
Edited by: levis 501 on Sep 22, 2011 5:00 AM
09-22-2011 3:00 PM
Thanks for the quick response. I inserted your code after the
PERFORM get_data
line, but it did not solve my problem. Any other ideas why this isn't working for me?
09-22-2011 3:24 PM
Are you calling transaction ME22n within the event 'double_click'.
If so, after the call transaction, try a leave to screen...... statement. This will recall the screen again. I suspect after you double click the screen is not being refresh.
09-22-2011 4:26 PM
Levis,
Thanks for the help. I added your code and at first it didn't work. Then, I thought I would clear and refresh the internal tables (I have two) used in the get_data subroutine. This seemed to work, and it was refreshing immediately upon returning to the screen. Then I exited the program and restarted it completely and now in order for me to get the alv grid to refresh properly I need to click the refresh button I created on the ALV screen. I guess this is a performance related issue that I should begin in another thread. Thanks for your help!
Martin, thanks for the suggestion.
09-23-2011 3:49 AM