Skip to Content
0

CL_SALV_TABLE dynamic refresh

Dec 14, 2016 at 05:10 PM

251

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded

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

0
Former Member
Sandra Rossi

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 :P

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Raghu Govindarajan Dec 14, 2016 at 07:52 PM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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...

0

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

0
Raymond Giuseppi
Dec 15, 2016 at 06:52 AM
0

Set a break-point at

IF go_alv IS BOUND.

Also consider moving the refresh out of the LOOP.

Regards,
Raymond

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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.

0