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

Refresh table in ALV

Former Member
0 Likes
1,525

Hi experts,

I am facing a problem in refreshing the internal table in ALV. I am displaying records of internal table with checkbox. user can select one or more records and then presses delete button. I have written code in User command form to delete the selected records.

In the internal table it has deleted the selected records. but when alv is displayed again it is displaying old internal table records( all records).

Sample code in user command subroutine.

loop at itab where checkbox = 'X'.

delete itab index sy-tabix.

endloop.

Let know what needs to be done. points will be awarded for helpful answers.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,388

If you are using the function module ALV, you need to set the REFRESH flag in the USER_COMMAND routine. HEre is an example.



* Call ABAP List Viewer (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = repid
            i_callback_user_command = 'HANDLE_USER_COMMAND'
            it_fieldcat             = ifc
       tables
            t_outtab                = itab.

endform.

***********************************************************************
*       FORM handle_User_Command                                      *
***********************************************************************
form handle_user_command using r_ucomm     like sy-ucomm
                               rs_selfield type slis_selfield.

  case r_ucomm.
    when '&IC1'.

*  DO Something
        rs_selfield-refresh = 'X'.

  endcase.

endform.

Regards,

RIch Heilman

Hi experts,

I am facing a problem in refreshing the internal table in ALV. I am displaying records of internal table with checkbox. user can select one or more records and then presses delete button. I have written code in User command form to delete the selected records.

In the internal table it has deleted the selected records. but when alv is displayed again it is displaying old internal table records( all records).

Sample code in user command subroutine.

loop at itab where checkbox = 'X'.

delete itab index sy-tabix.

endloop.

Let know what needs to be done. points will be awarded for helpful answers.

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,388

Hello

At the end of the USER_COMMAND routine set <b>REFRESH = 'X'.</b>

Regards

Uwe

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,389

If you are using the function module ALV, you need to set the REFRESH flag in the USER_COMMAND routine. HEre is an example.



* Call ABAP List Viewer (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = repid
            i_callback_user_command = 'HANDLE_USER_COMMAND'
            it_fieldcat             = ifc
       tables
            t_outtab                = itab.

endform.

***********************************************************************
*       FORM handle_User_Command                                      *
***********************************************************************
form handle_user_command using r_ucomm     like sy-ucomm
                               rs_selfield type slis_selfield.

  case r_ucomm.
    when '&IC1'.

*  DO Something
        rs_selfield-refresh = 'X'.

  endcase.

endform.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
1,388

Hi,

In ALV, to refresh the table you have to call the method "refresh_table_display".

It has the syntax very similar to creating the table.

It has two parameters. In the first one, you can mention if you want to refresh only the data (the icons are not refreshed)

or

if you want to refresh only the icons around the grid (the data is not refreshed - this option is mostly not used in day to day applications).

the synatx is :-

call method grid (name of grid )->refresh_table_display

exporting

IS_STABLE = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING)

I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,388

My problem is solved. thanks for your help