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

ALV OOPs: Refresh Issue

Former Member
0 Likes
1,578

Hi,

Scenario:

I have implemented the ALV display using the methods of class CL_SALV_TABLE. I have a layout parameter and depending on the layout selected the result is displayed. Also there is a Refresh button on the grid for displaying the new data set.

For this I have used the refresh method of the CL_SALV_TABLE class.


  gr_grid->refresh(  ).

Issue:

When the data is displayed for the first time, it is as per the Layout selected. When I press the refresh button, the ordering of the rows is lost. I tried to debug but I am not able to figure out where the problem lies.

Kindly suggest.

Please do let me know in case the problem is not clear.

Regards

s@k

10 REPLIES 10
Read only

Clemenss
Active Contributor
0 Likes
1,274

Hi siemens,

try to use the optional parameters

S_STABLE	TYPE LVC_S_STBL OPTIONAL
REFRESH_MODE	TYPE SALV_DE_CONSTANT  DEFAULT IF_SALV_C_REFRESH=>SOFT

Regards,

Clemens

Read only

Former Member
0 Likes
1,274

Dear Clemens,

I tried as per your suggestion still it does not work...:(

Kindly advice..

Regards

s@k

Read only

Former Member
0 Likes
1,274

Hi,

Any suggestion..

Regards

s@k

Read only

0 Likes
1,274

Can I please see your code around creating the gr_grid object and calling the display and refresh methods?

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,274

Dear Rich,

Adding to the question, I have 3 ALVs which I am displaying on the same screen(by splitting the container ). I have provided Refresh button on each of the screen and for handling the events I have created a class.


CLASS cl_handle_events DEFINITION.
  PUBLIC SECTION.
    METHODS:
      on_user_command FOR EVENT added_function OF cl_salv_events
        IMPORTING e_salv_function sender.

ENDCLASS.                    "cl_handle_events DEFINITION

The ALVs are created by calling


  TRY.
      cl_salv_table=>factory(
        EXPORTING
          r_container    = gr_container1
        IMPORTING
          r_salv_table   = gr_grid_1
        CHANGING
          t_table        = gt_table1
             ).
    CATCH cx_salv_msg INTO gr_error1.
  ENDTRY.

In the same fashion i instantiate the other 2 ALVs.

The requirement is that If the user presses the Refresh button on the First screen(split container), the other two ALVs should also be refreshed. So, on pressing the 'Refresh' button on the first screen, I do some modification to the three tables and then call the refresh() method for each instance.


  gr_grid_1->refresh(  ).
  gr_grid_2->refresh(  ).
  gr_grid_3->refresh(  ).

Kindly suggest..

Please let me know if I am anyway unclear about the question...:)

Regards

s@k

Read only

Former Member
0 Likes
1,274

Dear Rich,

I tried to debug the SAP delivered program: SALV_DEMO_TABLE_REFRESH. As my scenario was similar to this I selected the option 'Output as Grid' on the selection screen and the number of records as 5. On the result screen, I select the field 'Occupied' and sort this in Ascending order. Now I press the button 'Double Data Records and Select Rows'. (This will refresh the grid).

Now when you get the result back, the sort order is lost and the data is displayed as it was retrieved from the database table. It does not maintain the sort order which matches with my scenario.

Kindly provide your comments whether is this the desired behavior?

Regards

s@k

Read only

Clemenss
Active Contributor
0 Likes
1,274

Hi siemens,

as far as I know a REFRESH will always restore the initial table display, i.e. transport the values present in the internal table for display to the frontend. It will not change any layout set when the initial display was triggered.

If you want sorting (and other settings) preserved, you could save a default layout or extract the respective column and layout objects and restore them when refreshing.

Regards,

Clemens

Read only

Former Member
0 Likes
1,274

Dear Clemens,

Thanks for your response..:)

But the thing is that in my previous post I have explained the case how the SAP delivered demo program behaves. This also does not save the sort order..:(

For my case(when REFRESH button is pressed) I have tried to debug and found the following:

1. Method RAISE_ADDED_FUNCTION (of class CL_SALV_CONTROLLER_EVENTS) is called.

2. Method HANDLE_BEFORE_EVENT (of class CL_SALV_CONTROLLER_EVENTS) is called internally.

In this method the metadata (sort, layout etc) is fetched.

3. Method RAISE_ADDED_FUNCTION of class CL_SALV_EVENTS is called and which triggers an event which is handled in my program.

4. Method HANDLE_AFTER_EVENT (of class CL_SALV_CONTROLLER_EVENTS) is called. In this the refresh method is called with the table for refresh stability(LVC_S_STBL).

Kindly suggest..:)

Regards

s@k

Read only

Former Member
0 Likes
1,274

Hi,

Any opinion regarding this..?

Regards

s@k

Read only

Former Member
0 Likes
1,274

Dear All,

Thanks to all for the replies...:)

The approach I followed is:

Before executing the 'user command' method, i have set the 'Sort' criteria using the: get_lvc_sort and set_lvc_sort methods of the class cl_salv_controller_metadata.

The sort order is retained after the Refresh button is pressed...

Regards

s@k