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: 

Refresh ALV grid not working

kasithunuguntla
Participant
0 Kudos
1,088

Hi,

I want to refresh ALV grid after a CALL TRANSACTION stmt. If I change some data after call transaction and when I come back, I am still seeing old data even after using the refresh functions. But It works if I do one of the following.

1. Click explicitly on Refresh button after coming back from Call Transaction.

2. If I put a break-point after call transaction stmt and click on continue processing.

Please help me in this regard.

Regards

Kasi

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos
108

Hi,

Give a WAIT 2 seconds , command after call transaction and then call REFRESH ALV. This command would help only if you are doing some database updates.

There could also be a possibility that REFRESH ALV is not getting triggered. You will have to debug to find whether refresh alv is getting triggered after call transaction.

Best regards,

Prashant

8 REPLIES 8

former_member181962
Active Contributor
0 Kudos
108

After the call transaction did you have something like this?

rs_selefield-refresh = 'X'.

Regards,

ravi

former_member223537
Active Contributor
0 Kudos
109

Hi,

Give a WAIT 2 seconds , command after call transaction and then call REFRESH ALV. This command would help only if you are doing some database updates.

There could also be a possibility that REFRESH ALV is not getting triggered. You will have to debug to find whether refresh alv is getting triggered after call transaction.

Best regards,

Prashant

0 Kudos
108

If the WAIT statement helped you with the problem, maybe another way is to make the update local.

In the CALL TRANSACTION statement, set UPDATE 'L'.

This may work as well, and you don't have to hardcode a delay in your program.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
108

Can you post the relevant code or email it to me. Address is on my business card.

Regards,

Rich Heilman

former_member188685
Active Contributor
108

Hi,

You have to explicitly do this....just check it, it will work.

REPORT  ZTEST_ALV_CHECK     message-id zz           .

TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
      IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      L_LAYOUT type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type SLIS_T_EVENT.

DATA: BEGIN OF ITAB OCCURS 0,
      VBELN LIKE VBAK-VBELN,
      POSNR LIKE VBAP-POSNR,
      CHK(1),
     END OF ITAB.
<b>perform get_data.</b>


X_FIELDCAT-FIELDNAME = 'CHK'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
X_FIELDCAT-INPUT = 'X'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-CHECKBOX = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.


  x_events-NAME = SLIS_EV_END_OF_PAGE.
  x_events-FORM = 'END_OF_PAGE'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
  x_events-NAME = SLIS_EV_TOP_OF_PAGE.
  x_events-FORM = 'TOP_OF_PAGE'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .

  x_events-NAME = slis_ev_end_of_list.
  x_events-FORM = 'END_OF_LIST'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
<b>perform display_report.</b>

*&---------------------------------------------------------------------*
*&      Form  STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
*- Pf status
  SET PF-STATUS 'STATUS'.
ENDFORM.                 " STATUS

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                               RS_SELFIELD TYPE SLIS_SELFIELD.

  case r_ucomm.
    when 'BACK' or 'CANC' or 'EXIT'.
      leave to screen 0.
    when '&IC1'.
       if rs_selfield-fieldname = 'VBELN'.
      set parameter id 'AUN' field rs_selfield-value.
      call transaction 'VA02' and skip first screen.
<b>      RS_SELFIELD-exit = 'X'.
      perform get_data.
      perform display_report.</b>
      endif.
  endcase.
ENDFORM.                    "USER_COMMAND
*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
SELECT VBELN
       POSNR
       FROM VBAP
       UP TO 20 ROWS
       INTO TABLE ITAB.
ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
*&      Form  display_report
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_report .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM       = SY-REPID
    IS_LAYOUT                = L_LAYOUT
    I_CALLBACK_PF_STATUS_SET = 'STATUS'
    I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
    IT_FIELDCAT              = IT_FIELDCAT
    it_events                = it_events
  TABLES
    T_OUTTAB                 = ITAB
  EXCEPTIONS
    PROGRAM_ERROR            = 1
    OTHERS                   = 2.
IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.                    " display_report

Observe the Bold Code.

Regards

vijay

0 Kudos
108

thank you it works

kasithunuguntla
Participant
0 Kudos
108

I have understood that it is timing problem. I gave a wait of 2 seconds after call transacation and it works fine now. Thanks for all who have responded to my query.

0 Kudos
108

I would recommend to try the UPDATE = 'L' instead of the WAIT. You should never hardcode a delay just to wait for an update.

Regards,

Rich Heilman