Application Development 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: 

How to refresh OOP ALV table after first display

Former Member
0 Kudos

Hi Gurus,

I have created a OOP ALV using custom control. I have a pushbutton in my screen also.

When I click the push button (Refresh Delivery Dues) for the first timeu2026u2026u2026it will refresh the ALV values with new values, but if u click 2nd / 3rd u2026time, it will not refresh ALV,

But in Debug mode, I see that values are updated and the internal tables are also modified with new valuesu2026.but it will not displayed in ALV. I also call set_table_first_display after refresh but it also not working.

i use below code when clicking the Push Button.

In PAI

Case sy-ucomm.

WHEN 'REF_ORDERS1'.

PERFORM get_sales_orders.

LOOP AT gt_zbs001_sod INTO gs_zbs001_sad.

PERFORM icon_led USING gs_zbs001_sod-werks

CHANGING gs_zbs001_sod-icon

gs_zbs001_sod-count.

gs_zbs001_sod-date = time_bdelv.

MODIFY gt_zbs001_sod FROM gs_zbs001_sod INDEX sy-tabix TRANSPORTING date.

ENDLOOP.

LOOP AT gt_zbs001_sad INTO gs_zbs001_sad.

PERFORM icon_led USING gs_zbs001_sad-werks

CHANGING gs_zbs001_sad-icon

gs_zbs001_sad-count.

gs_zbs001_sad-date = time_bdelv.

MODIFY gt_zbs001_sad FROM gs_zbs001_sad INDEX sy-tabix TRANSPORTING date. "p_es_row_no-row_id.

ENDLOOP.

CALL METHOD gr_alvgrid1->refresh_table_display

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD gr_alvgrid->refresh_table_display

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

try this in PBO of screen free the container and grid

MODULE ALV_100 OUTPUT.

*free container and object

PERFORM FREE.

*alv grid display

PERFORM DISPLAY.

ENDMODULE.

FORM FREE.

IF C_ALV IS NOT INITIAL.

CALL METHOD C_ALV->FREE

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

FREE C_ALV.

ENDIF.

ENDIF.

IF C_CONTAINER IS NOT INITIAL.

CALL METHOD C_CONTAINER->FREE

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

FREE C_CONTAINER.

ENDIF.

ENDIF.

ENDFORM.

FORM DISPLAY.

*Creating object of container.

CREATE OBJECT C_CONTAINER

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

*Creating object of alv

CREATE OBJECT C_ALV

EXPORTING

I_PARENT = C_CONTAINER.

  • Fieldcatalog.

PERFORM ALV_FIELDCAT.

CALL METHOD C_ALV->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = WA_LAYOUT

CHANGING

IT_OUTTAB = IT_OUTPUT

IT_FIELDCATALOG = IT_FIELDCAT.

ENDFORM. " DISPLAY

4 REPLIES 4

Former Member
0 Kudos

Hello,

The method u2018refresh_table_displayu2019 is enough to call the ALV grid with the updata data But please call the same in the PBO.

For instance, if the container is initial, then call the method u2013 u2018set_table_first_displayu2019 else call the method u2018refresh_table_displayu2019.

If you want to limit the number of calls on u2018refresh_table_displayu2019, then put a logic like when the related internal table changes, call this method.

My point is, just confirm that you are calling the method u2018refresh_table_displayu2019 in the PBO.

Regards,

Selva K.

Former Member
0 Kudos

hi,

try this in PBO of screen free the container and grid

MODULE ALV_100 OUTPUT.

*free container and object

PERFORM FREE.

*alv grid display

PERFORM DISPLAY.

ENDMODULE.

FORM FREE.

IF C_ALV IS NOT INITIAL.

CALL METHOD C_ALV->FREE

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

FREE C_ALV.

ENDIF.

ENDIF.

IF C_CONTAINER IS NOT INITIAL.

CALL METHOD C_CONTAINER->FREE

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

FREE C_CONTAINER.

ENDIF.

ENDIF.

ENDFORM.

FORM DISPLAY.

*Creating object of container.

CREATE OBJECT C_CONTAINER

EXPORTING

CONTAINER_NAME = 'CONTAINER'.

*Creating object of alv

CREATE OBJECT C_ALV

EXPORTING

I_PARENT = C_CONTAINER.

  • Fieldcatalog.

PERFORM ALV_FIELDCAT.

CALL METHOD C_ALV->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = WA_LAYOUT

CHANGING

IT_OUTTAB = IT_OUTPUT

IT_FIELDCATALOG = IT_FIELDCAT.

ENDFORM. " DISPLAY

Former Member
0 Kudos

Hello,

I understood that the ALV is getting refreshed when you click the push button. But my doubt is this u201Cwhy do you click many times after refreshu201D. I can see another scenario here. If you are modifying many rows of the ALV and trying to refresh, it may be not be working even though it is working in debug mode. Here it may work for a single row without any issue. So my suggestion is to use u201CWAITu201D.

WAIT UP TO 5 SECONDS. (No of seconds you can change according to you program)

Regards,

Manju

Former Member
0 Kudos

Fantastic,

           This works for me.   Thanks a lot.

Cheers.