0

I know my problem has been asked hundred times. But I still cannot find any suitable solution for me

  1. I have a dropdown, every time I change data in dropdown it will load new data based on dropdown data
  2. From step one, I refresh editable ALV
  3. Any change in editable ALV willbe saved (another action for saving)

My problem if, After I save, I can't refresh my ALV.

But it's not problem if I haven't pressed save button

NOTE : in SAP forum, they told me to move refresh function to PBO, I tried this but still failed.

Attached Code is Step 1 is "when SET_P" in this code

PBO

    MODULE pbo_1000 OUTPUT.
       IF flag = 0.
         SET PF-STATUS '1000'.
         SET TITLEBAR  '1000'.
         PERFORM create_toolbar.
         PERFORM create_catalog.
         PERFORM select_data.
     
         CREATE OBJECT ob_custom
           EXPORTING
             container_name = 'CCTRL'.
         CREATE OBJECT ob_grid
           EXPORTING
             i_parent      = ob_custom
             i_appl_events = 'X'.
     
         PERFORM create_dropbox.
         CALL METHOD ob_grid->set_table_for_first_display
           EXPORTING
             i_structure_name     = 'TYPE'
             it_toolbar_excluding = lt_toolbar
             is_layout            = lyt
           CHANGING
             it_fieldcatalog      = fld[]
             it_outtab            = itab[].
     
         CALL METHOD ob_grid->set_ready_for_input
           EXPORTING
             i_ready_for_input = 1.
         CALL METHOD ob_grid->register_edit_event
           EXPORTING
             i_event_id = cl_gui_alv_grid=>mc_evt_enter.
       ENDIF.
    ENDMODULE.   

PAI

    MODULE user_command_1000 INPUT .
       DATA: v_perio(6) TYPE c.

       CASE sy-ucomm.
         WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
           LEAVE TO SCREEN 0.
         WHEN 'SAVE'.
           PERFORM save_data.
           PERFORM send_email.
     
         WHEN 'SET_S'.
           flag = 1.
           PERFORM set_status.
           CALL METHOD ob_grid->refresh_table_display
             EXPORTING
               is_stable = stbl.
    
         WHEN 'SET_P'.
           flag = 1.
           PERFORM select_data.
           CALL METHOD ob_grid->refresh_table_display
             EXPORTING
               is_stable      = stbl.
       ENDCASE.
    ENDMODULE. 
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
yukou
  • 305
  • 3
  • 6
  • 17

3 Answers3

1

I guess you will need the CHECK_CHANGED_DATA method called as first thing in the PAI, which would fire up the events DATA_CHANGED and DATA_CHANGED_FINISHED.

But most important thing is, that it will synchronize the OLE object with the instance backend and then when you are calling the REFRESH_TABLE_DISPLAY it would refresh your ALV properly. I don't have any example at the moment, but I can maybe try next week when I have access to system.

By the way in PBO you don't need to have the variable flag you can use check if the ALV object has been already initialized or not and according to this you can create/refresh alv. Something like this:

if alvGridRef is NOT bound .
  data(container) = new cl_gui_custom_container( ) .
  data(alvGridRef) = new cl_gui_alv_grid( ) .
else .
  alvGridRef->refresh_table_display( ) .
endif .
Petr Šourek
  • 199
  • 6
0

I've done something similar in an application that needed to be refreshed when saved because some calculations had to change in the screen. I set part of the following code in the command form for the 'REUSE_ALV_GRID_DISPLAY' function module.

form user_command using r_ucomm     like sy-ucomm
                        rs_selfield type slis_selfield.
  data: ref_grid type ref to cl_gui_alv_grid, l_valid type c.

  if ref_grid is initial.
    call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      importing
        e_grid = ref_grid.
  endif.

  if not ref_grid is initial.
    call method ref_grid->check_changed_data
      importing
        e_valid = l_valid.
  endif.
  rs_selfield-refresh = 'X'.

  ...

  if not ref_grid is initial.
    call method ref_grid->refresh_table_display( ) .
  endif.

endform.

Hope it helps

Nelson Miranda
  • 5,484
  • 5
  • 33
  • 54
0

You might achieve this by manually triggering PBO. You stated that the Editing is saved, so you can just display the ALV in PBO again:

CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
           EXPORTING
             functioncode           = 'REFRESH'
           EXCEPTIONS
             function_not_supported = 1 
             OTHERS                 = 2.

After this action, sy-ucomm in PBO has the value REFRESH.