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_display in grids

Former Member
0 Likes
3,817

hello friends..

i am working on a alv grid.

when i edit the grid(delete row.add row) i want to refresh the table display and for that i have taken a REFRESH BUTTON and when i clik that i wrote in PAI : Call method refresh_table_display.

but it is not refreshing the grid. insted i have to again process to refresh it..can any one tell how to handle refreshing grids..

plz help..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,076

Hi Mahesh,

Make sure that while calling the FM which you stated , if you are dealing with only one screen, then you need to explicitly call the pbo of that screen after calling FM for refreshing the grid.

Only then will the changes take effect.

Hi Mahesh,

Make sure that while calling the FM which you stated , if you are dealing with only one screen, then you need to explicitly call the pbo of that screen after calling FM for refreshing the grid.

Only then will the changes take effect.

7 REPLIES 7
Read only

Former Member
0 Likes
3,076

plz put a debugger and check whether the control is coming into tht refresh_table_display..

If its coming means u wnt check whether the table(internal) is getting clear after the refresh stmt..

Otherwise use clear or free stmts..

It will work

reward if useful

Read only

0 Likes
3,076

hiii

debuger is comming to the refresh method and after that i am also clearing ITABS but too its not clering..

plz suggest..

Read only

Former Member
0 Likes
3,077

Hi Mahesh,

Make sure that while calling the FM which you stated , if you are dealing with only one screen, then you need to explicitly call the pbo of that screen after calling FM for refreshing the grid.

Only then will the changes take effect.

Read only

0 Likes
3,076

hii

actuly i have tabstrip control and on that i have 5 grids..i want all these grids to be refreshed when i clik REFRESH button.

plz explain wat i need to do.

mahesh

Read only

Former Member
0 Likes
3,076

Hi Mahesh,

when using the function module "REUSE_ALV_GRID_DISPLAY", you have a exporting parameter called "I_CALLBACK_USER_COMMAND". This is the name of a form in your report to handle all the buttons clicked. To create your own buttons just create a GUI-Status and provide the exporting parameter "I_CALLBACK_PF_STATUS_SET" with a form in your report that sets the status.

Inside your user_command-Form you can update all the records of your internal table. To make ALV refresh the display just provide the field st_selfield-refresh with 'X'.

EXAMPLE:

=========

FORM USER_COMMAND USING RC_UCOMM LIKE SY-UCOMM

ST_SELFIELD TYPE SLIS_SELFIELD.

case rc_ucomm.

  • check which button has been pressed

  • Refresh internal table

select... into itab...

endcase.

  • Make sure, that the updated internal table itab is displayed

st_selfield-refresh = 'X'.

ENDFORM.

FORM PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'ALV'. " EXCLUDING RT_EXTAB.

ENDFORM.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'ZPXYZ'

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

.....

Lokesh

Message was edited by:

Lokesh Aggarwal

Read only

0 Likes
3,076

hiii

thank you,

i am using a OO approch for grids.

i have refresh button and calling refresh method in PAI of the screen..

but too nt working

Read only

Former Member
0 Likes
3,076

Hi

The following method call is used to refresh the data displayed within an ALV object grid: CALL method gd_tree->REFRESH_TABLE_DISPLAY.

CALL METHOD gd_tree->set_table_for_first_display

EXPORTING

is_layout = gd_layout

CHANGING

it_fieldcatalog = gd_fieldcat

it_sort = it_sortcat

it_outtab = it_report.

CALL method gd_tree->REFRESH_TABLE_DISPLAY.

CALL METHOD cl_gui_cfw=>flush.

and see this program where it refreshes the program for every 5 sec

https://www.sdn.sap.com/irj/sdn/wiki

>********************************************************************

  • This report displays User's info (SM04) using the FM : *

  • REUSE_ALV_LIST_DISPLAY *

  • The list is auto-refreshed (refresh time : 5 seconds) *

----


TYPE-POOLS: slis. " ALV Global Types

DATA :

gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04

----


START-OF-SELECTION.

PERFORM f_read_data.

PERFORM f_display_data.

----


  • Form F_LIRE_DATA

----


FORM f_read_data.

REFRESH gt_user.

  • Get User's info

CALL FUNCTION 'THUSRINFO'

TABLES

usr_tabl = gt_user.

  • Wait in a task

PERFORM f_call_rfc_wait.

ENDFORM. " F_READ_DATA

----


  • Form F_DISPLAY_DATA

----


FORM f_display_data.

DEFINE m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DEFINE m_event_exit.

clear ls_event_exit.

ls_event_exit-ucomm = &1.

ls_event_exit-after = 'X'.

append ls_event_exit to lt_event_exit.

END-OF-DEFINITION.

DATA :

ls_layout TYPE slis_layout_alv,

lt_sort TYPE slis_t_sortinfo_alv,

ls_sort TYPE slis_sortinfo_alv,

lt_event_exit TYPE slis_t_event_exit,

ls_event_exit TYPE slis_event_exit.

  • Build Sort Table

m_sort 'ZEIT'.

  • Build Event Exit Table

m_event_exit '&NTE'. " Refresh

ls_layout-zebra = 'X'.

ls_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

is_layout = ls_layout

i_structure_name = 'UINFO'

it_sort = lt_sort

it_event_exit = lt_event_exit

TABLES

t_outtab = gt_user.

ENDFORM. " F_DISPLAY_DATA

----


  • FORM USER_COMMAND *

----


FORM user_command USING i_ucomm TYPE syucomm

is_selfield TYPE slis_selfield. "#EC CALLED

CASE i_ucomm.

WHEN '&NTE'.

PERFORM f_read_data.

is_selfield-refresh = 'X'.

SET USER-COMMAND '&OPT'. " Optimize columns width

ENDCASE.

ENDFORM. " USER_COMMAND

----


  • Form F_CALL_RFC_WAIT

----


FORM f_call_rfc_wait.

DATA lv_mssg(80). "#EC NEEDED

  • Wait in a task

CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'

PERFORMING f_task_end ON END OF TASK

EXPORTING

seconds = 5 " Refresh time

busy_waiting = space

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

ENDFORM. " F_CALL_RFC_WAIT

----


  • Form F_TASK_END

----


FORM f_task_end USING u_taskname.

DATA lv_mssg(80). "#EC NEEDED

  • Receiving task results

RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

CHECK sy-subrc EQ 0.

SET USER-COMMAND '&NTE'. " Refresh

ENDFORM. " F_TASK_END

                            • END OF PROGRAM Z_ALV_AUTO_REFRESH ********************

<b>Reward if usefull</b>