Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CL_SALV_TABLE dynamic refresh

Former Member
0 Likes
2,859

Hi community.

I am doing a ALV report using SALV model.

Initially is static, but when clicking a toolbar button, a heavy process is executed by each record, and I would like to show the result of the process for each record by refreshing the ALV.

I thought it was as easy as

go_alv->refresh( refresh_mode = if_salv_c_refresh=>full ). 

but not...

Let me show you the code.

CLASS lcl_handle_events IMPLEMENTATION.
   METHOD on_user_command.
     PERFORM f_on_user_command USING e_salv_function.
   ENDMETHOD.                    "on_user_commmand
 ENDCLASS.                    "lcl_handle_events IMPLEMENTATION 
TYPES: BEGIN OF ty_alv.
         INCLUDE STRUCTURE zbcgrc_actions.
TYPES:   icon_action TYPE icon_d,
          icon     TYPE icon_d,
       END OF ty_alv.
DATA:  gt_alv TYPE TABLE OF ty_alv,
       gs_alv TYPE ty_alv.
 DATA: go_alv TYPE REF TO cl_salv_table,
       go_events TYPE REF TO lcl_handle_events.

FORM f_display_alv .
   TRY.
       cl_salv_table=>factory(
       IMPORTING
         r_salv_table = go_alv
       CHANGING
         t_table      = gt_alv ).
     CATCH cx_salv_msg.                                 "#EC NO_HANDLER
   ENDTRY.
   PERFORM f_set_columns_alv.
   PERFORM f_set_events_alv.
   go_alv->display( ).
 ENDFORM.                    " F_DISPLAY_ALV

FORM f_set_columns_alv.
   DATA: lo_cols TYPE REF TO cl_salv_columns_table,
         lo_col  TYPE REF TO cl_salv_column_table.
   lo_cols = go_alv->get_columns( ).
   TRY.
       lo_col ?= lo_cols->get_column( 'ICON' ).
       lo_col->set_icon( if_salv_c_bool_sap=>true ).
     CATCH cx_salv_not_found.                           "#EC NO_HANDLER
   ENDTRY.
   TRY.
       lo_col ?= lo_cols->get_column( 'ICON_ACTION' ).
       lo_col->set_icon( if_salv_c_bool_sap=>true ).
     CATCH cx_salv_not_found.                           "#EC NO_HANDLER
   ENDTRY.
 ENDFORM.                    "f_set_columns
FORM f_set_events_alv .
   DATA: lo_events TYPE REF TO cl_salv_events_table.
   lo_events = go_alv->get_event( ).
   CREATE OBJECT go_events.
   SET HANDLER go_events->on_user_command FOR lo_events.
 ENDFORM.                    " F_SET_EVENTS_ALV_ROLE
FORM f_on_user_command  USING    p_function.
   CASE p_function.
     WHEN '&EXEC'.
       PERFORM f_execute.
   ENDCASE.
 ENDFORM.                    " F_ON_USER_COMMAND
 FORM f_execute .
      FIELD-SYMBOLS: <gs_alv> TYPE ty_alv.
   LOOP AT gt_alv ASSIGNING <gs_alv>.
        PERFORM f_proccess_action CHANGING <gs_alv>.
"in this process <gs_alv>-icon is modified.
     IF go_alv IS BOUND. 
"it should refresh alv with the icon_modified... but not...
       go_alv->refresh( refresh_mode = if_salv_c_refresh=>full ).
     ENDIF.
   ENDLOOP.
 ENDFORM.                    " F_EXECUTE 

Do I miss something?

Thank you all

7 REPLIES 7
Read only

raghug
Active Contributor
0 Likes
1,722

From the code that you attached, I can't quite tell... Just make sure that your go_alv->display( ) is re-executed before the screen is displayed every time in the PBO

Read only

Former Member
0 Likes
1,722

There is no PBO nor dynpro. The unique "user-commad" it is the click on a button at user toolbar, that is handled by the event...

Read only

raghug
Active Contributor
0 Likes
1,722

Then try adding it to your f_execute at the end, outside the loop

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,722

What a pity PERFORM had not been forbidden in ABAP OO... 😄

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,722

Set a break-point at

IF go_alv IS BOUND.

Also consider moving the refresh out of the LOOP.

Regards,
Raymond

Read only

0 Likes
1,722

The first thing I did was to set up a break-point there. and Yes, it enters, and I learned about the parameter refresh_mode when I see it inside the cl_salv_table class. :D.

I have to re-think, re-build the logic of the program.

Read only

Former Member
0 Likes
1,722

Yes, I know...Although I have developed for a long time in normal ABAP, I am starting to develop in ABAP OO... give me some time 😛