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 refresh display

Former Member
0 Likes
3,307

Hi experts,

I put a refresh button onto the the ALV list. If it is pressed, I need to refresh the displaying of data.

I found an Object Oriented solution but I need a fm to solve this problem and so far I did not found which fm could I use.

Hi experts,

I put a refresh button onto the the ALV list. If it is pressed, I need to refresh the displaying of data.

I found an Object Oriented solution but I need a fm to solve this problem and so far I did not found which fm could I use.

12 REPLIES 12
Read only

Former Member
0 Likes
2,254

Hi,

Just submit the same program again with the same selection screen parameters and return. Means program will be executed again and data will be refreshed.

Ganga

Read only

Former Member
0 Likes
2,254

Use Submit - call the same program with the same selection parameters - u ll get a refreshed output.

Read only

Former Member
0 Likes
2,254

HI,

On the User Command for the refresh Button click,

CHeck the sample code below:



*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is EXECUTE then process the selected records
    WHEN 'EXECUTE'.       "Here you can give func code of your refresh button

* refresh it_process when user processes selected records
      REFRESH it_process.

* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

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

*----------------------------------------------------------------------*
* sort the internal table by flag descending so that the selected
* records are appended at the beginning of internal table
*----------------------------------------------------------------------*
      SORT it_final BY flag DESCENDING.

*----------------------------------------------------------------------*
* move the selected records from final internal table into another
* internal table so that they can be processed
*----------------------------------------------------------------------*
      LOOP AT it_final INTO wa_final WHERE flag = 'X'.
        wa_process-aufnr = wa_final-aufnr.
        wa_process-ktext = wa_final-ktext.
        wa_process-qmnum = wa_final-qmnum.
        APPEND wa_process TO it_process.
      ENDLOOP.

* refresh the ALV Grid output from internal table
      l_selfield-refresh = c_check.

* now all the selected records by the user at run-time are appended into
* into a new internal table which can now be used to processed as per the
* user requirements
      DATA : line_count1 TYPE i.

      DESCRIBE TABLE it_process
      LINES line_count1.
      IF line_count1 GE 1.
        PERFORM user_action.
      ELSE.
        MESSAGE e002.
      ENDIF.

    WHEN 'SEL_ALL'.
* to select all the records displayed in ALV Grid
      LOOP AT it_final INTO wa_final.
        wa_final-flag = 'X'.
        MODIFY it_final FROM wa_final.
      ENDLOOP.
* refresh the ALV Grid output from internal table
      l_selfield-refresh = c_check.

    WHEN 'DESEL_ALL'.
* to deselect all the records displayed in ALV Grid
      LOOP AT it_final INTO wa_final.
        wa_final-flag = ' '.
        MODIFY it_final FROM wa_final.
      ENDLOOP.
* refresh the ALV Grid output from internal table
      l_selfield-refresh = c_check.

  ENDCASE.

ENDFORM.                    "USER_COMMAND

Hope it helps

Regards

Mansi

Read only

0 Likes
2,254

Mansi I cannot read this code, sorry. It just copied without any formatting. I doesn't help at all, since I cannot read it.

Read only

0 Likes
2,254

Why don't you submit the same program again with the same selection screen parameters and return?

Regards,

Ganga

Read only

0 Likes
2,254

I think selfield-refresh = 'X' is the most easiest way. I've already have the selection, all I need to do is just call the perform again.

Thanks anyway, submit program could be an option as well.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,254

Hi,

Refer this code in the user command of the ALV in the below wiki by me:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bch...

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
2,254

Hi ,

Just Use the below FM with CL_GUI_ALV_GRID object .

CALL METHOD G_ALVGRID->REFRESH_TABLE_DISPLAY .

regards,

Amit

Read only

Former Member
0 Likes
2,254

Hi,

When the USER_COMMAND is Triggered,

WHEN 'REFRESH'.

p_selfield-refresh = 'X'.

use the above scenario you will get it 100% correct.

Thanks & Regards,

Prasad.

Read only

0 Likes
2,254

selfield-refresh = 'X'.

I think maybe it could help. I have to perform the data selection before I set refresh to 'X'.

Like this one:

....

perform f_data_selection.

selfield-refresh = 'X'.

Edited by: mrwhite on Feb 22, 2010 11:33 AM

Read only

0 Likes
2,254

Hi Prasad,

Really you solution helped me..Thanks a lot.....

Its a 100% solution for refreshing an ALV o/P Grid...

Read only

Former Member
0 Likes
2,254

Thanks