Skip to Content

ALV OO and refreshing the ALV grid

Hi,

i have some problems with my ALV 00 program.

On screen 1 i have to fill in a material number.

For that material i'm getting some data and show in screen 2 in a ALV grid.

Via BACK-button i'm getting back to screen 1 and can fill in another material number.

But the 2nd (and 3rd, etc) time i fill a material, the ALV grid data from material 1 is shown. Even if the internal table I_ALV where the data is, is changed.

What should i do ?

I have initialized the customer container and the grid, but that didn't solved the problem.

regards,

Hans

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Jun 01, 2006 at 09:02 AM

    Hi Hans,

    as you said the data is changed in the internal table.so you can do one thing call the refrsh method.

    after you add the material to the itab.

    don't initialize it....

    just call this ...when ever you change the itab, after change the itab.

      CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
        EXCEPTIONS
          FINISHED = 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.

    Regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2006 at 08:59 AM

    Hi,

    Do like this.

    <b>If gr_alvgrid IS INITIAL .</b>
     Create Object gr_ccontainer.
       ...
     If sy-subrc <> 0 .
      ..exception handling.
     endif.
    
      create object gr_alvgrid .
       ..
      call method gr_alvgrid->set_table_for_first_display.
    <b>ELSE.</b>
      Call Method gr_alvgrid->refresh_table_display.
    <b>ENDIF.</b>
    

    <i>Hope This Info Helps YOU.</i>

    Regards,

    Raghav

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2006 at 08:50 AM

    Hi,

    Try clearing and refreshing the alv grid data table in screen 2.

    Check with this code. this code is working fine. If we go back and change the input, it is showing the output corresponding to the second input only.

    Have you use this method?

    <b> GR_ALVGRID->REFRESH_TABLE_DISPLAY</b>

    TYPE-POOLS : SLIS.
    
    *---------------------------------------------------------------------*
    * Tables                                                              *
    *---------------------------------------------------------------------*
    TABLES:
      VBRK,
      VBRP.
    *---------------------------------------------------------------------*
    * Parameters and select options OR SELECTION SCREEN
    *---------------------------------------------------------------------*
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS:
                S_VBELN FOR VBRK-VBELN.
    SELECTION-SCREEN END OF BLOCK B1.
    
    *---------------------------------------------------------------------*
    * Internal Tables                                                     *
    *---------------------------------------------------------------------*
    * work areas
    DATA: BEGIN OF IT_VBRP OCCURS 0,
           VBELN LIKE VBRK-VBELN,
           POSNR LIKE VBRP-POSNR,
           UEPOS LIKE VBRP-UEPOS,
           FKIMG LIKE VBRP-FKIMG,
           NETWR LIKE VBRP-NETWR,
           MEINS LIKE VBRP-MEINS.
    DATA : END OF IT_VBRP.
    
    *---------------------------------------------------------------------*
    * Variables                                                           *
    *---------------------------------------------------------------------*
    DATA : GR_ALVGRID TYPE REF TO CL_GUI_ALV_GRID,
           GC_CUSTOM_CONTROL_NAME TYPE SCRFNAME VALUE 'CC_ALV',
           GR_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           GT_FIELDCAT TYPE LVC_T_FCAT,
           GS_LAYOUT TYPE LVC_S_LAYO,
           V_FLAG VALUE 'X'.
    
    ***********************************************************************
    * Start of Program                                                    *
    ***********************************************************************
    
    *---------------------------------------------------------------------*
    *       INITIALIZATION.                                               *
    *---------------------------------------------------------------------*
    INITIALIZATION.
    *--------------*
      S_VBELN-LOW = 1.
      S_VBELN-HIGH = 1000000000.
      S_VBELN-OPTION = 'EQ'.
      S_VBELN-SIGN = 'I'.
      APPEND S_VBELN.
    *---------------------------------------------------------------------*
    *       SELECTION-SCREEN                                              *
    *---------------------------------------------------------------------*
    AT SELECTION-SCREEN.
    *---------------------*
      PERFORM VALIDATION.
    *---------------------------------------------------------------------*
    *       START-OF-SELECTION                                            *
    *---------------------------------------------------------------------*
    START-OF-SELECTION.
    *------------------*
    
      PERFORM GET_DATA.
      CALL SCREEN 0100.
    
    
    
    
    
    *---------------------------------------------------------------------*
    *       END-OF-SELECTION                                              *
    *---------------------------------------------------------------------*
    END-OF-SELECTION.
    *----------------*
    
    
    
    *---------------------------------------------------------------------*
    *       TOP-OF-PAGE                                                   *
    *---------------------------------------------------------------------*
    TOP-OF-PAGE.
    *-----------*
    
    
    
    *---------------------------------------------------------------------*
    *       END-OF-PAGE                                                   *
    *---------------------------------------------------------------------*
    END-OF-PAGE.
    *-----------*
    
    
    
    
    *---------------------------------------------------------------------*
    *       AT USER-COMMAND                                               *
    
    *&---------------------------------------------------------------------*
    *&      Form  VALIDATION
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM VALIDATION .
      SELECT SINGLE VBELN
      FROM VBRK
      INTO VBRK-VBELN
      WHERE VBELN IN S_VBELN.
    
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'no billing documents found'.
      ENDIF.
    ENDFORM.                    " VALIDATION
    *&---------------------------------------------------------------------*
    *&      Form  GET_DATA
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM GET_DATA .
      SELECT VBELN
             POSNR
             UEPOS
             FKIMG
             NETWR
             MEINS
      FROM VBRP
      INTO TABLE IT_VBRP
      WHERE VBELN IN S_VBELN.
    ENDFORM.                    " GET_DATA
    *&---------------------------------------------------------------------*
    *&      Module  DISPLAY_ALV  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE DISPLAY_ALV OUTPUT.
    
      IF V_FLAG = 'X'.
    
        PERFORM DISPLAY_ALV.
        PERFORM PREPARE_FIELD_CATALOG CHANGING GT_FIELDCAT.
        PERFORM PREPARE_LAYOUT CHANGING GS_LAYOUT.
       CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
            EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              = 'VBRP'
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
              IS_LAYOUT                     = GS_LAYOUT
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
            CHANGING
              IT_OUTTAB                     = IT_VBRP[]
              IT_FIELDCATALOG               = GT_FIELDCAT
    *      IT_SORT                       =
    *      IT_FILTER                     =
            EXCEPTIONS
              INVALID_PARAMETER_COMBINATION = 1
              PROGRAM_ERROR                 = 2
              TOO_MANY_LINES                = 3
              OTHERS                        = 4
                  .
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    
          CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
            EXPORTING
              I_READY_FOR_INPUT = 1.
    
        ELSE.
          <b>CALL METHOD GR_ALVGRID->REFRESH_TABLE_DISPLAY
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
            EXCEPTIONS
              FINISHED       = 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.</b>
        ENDIF.
        CLEAR V_FLAG.
      ENDIF.
    ENDMODULE.                 " DISPLAY_ALV  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY_ALV
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM DISPLAY_ALV .
      IF GR_ALVGRID IS INITIAL.
        CREATE OBJECT GR_ALVGRID
          EXPORTING
    *    I_SHELLSTYLE      = 0
    *    I_LIFETIME        =
            I_PARENT          = GR_CCONTAINER
    *    I_APPL_EVENTS     = space
    *    I_PARENTDBG       =
    *    I_APPLOGPARENT    =
    *    I_GRAPHICSPARENT  =
    *    I_NAME            =
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            OTHERS            = 5
            .
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV
    *&---------------------------------------------------------------------*
    *&      Form  PREPARE_FIELD_CATALOG
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      <--P_GT_FIELDCAT  text
    *----------------------------------------------------------------------*
    FORM PREPARE_FIELD_CATALOG  CHANGING P_GT_FIELDCAT TYPE LVC_T_FCAT.
    
      DATA : LS_FCAT TYPE LVC_S_FCAT,
             L_POS TYPE I.
    
      L_POS = L_POS + 1.
    
      LS_FCAT-FIELDNAME = 'VBELN'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Billing Document'.
      LS_FCAT-OUTPUTLEN = '10'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
    
      L_POS = L_POS + 1.
    
      LS_FCAT-FIELDNAME = 'POSNR'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Billing Item'.
      LS_FCAT-OUTPUTLEN = '6'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
    
      L_POS = L_POS + 1.
    
      LS_FCAT-FIELDNAME = 'UEPOS'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Higher Level Item'.
      LS_FCAT-OUTPUTLEN = '6'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
    
      L_POS = L_POS + 1.
    
      LS_FCAT-FIELDNAME = 'FKIMG'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Invoice Quantity'.
      LS_FCAT-OUTPUTLEN = '13'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
    
      L_POS = L_POS + 1.
    
      LS_FCAT-FIELDNAME = 'NETWR'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Net Value'.
      LS_FCAT-OUTPUTLEN = '15'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
    
      L_POS = L_POS + 1.
    
      LS_FCAT-FIELDNAME = 'MEINS'.
      LS_FCAT-TABNAME = 'IT_VBRP'.
      LS_FCAT-COL_POS = L_POS.
      LS_FCAT-SCRTEXT_M = 'Unit of Measure'.
      LS_FCAT-OUTPUTLEN = '3'.
      APPEND LS_FCAT TO P_GT_FIELDCAT.
      CLEAR LS_FCAT.
    
      L_POS = L_POS + 1.
    
    
    
    
    ENDFORM.                    " PREPARE_FIELD_CATALOG
    *&---------------------------------------------------------------------*
    *&      Form  PREPARE_LAYOUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      <--P_GS_LAYOUT  text
    *----------------------------------------------------------------------*
    FORM PREPARE_LAYOUT  CHANGING P_GS_LAYOUT TYPE LVC_S_LAYO.
      P_GS_LAYOUT-ZEBRA = 'X'.
      P_GS_LAYOUT-GRID_TITLE = 'INVOICE DETAILS'.
      P_GS_LAYOUT-SMALLTITLE = 'X'.
      P_GS_LAYOUT-EDIT = 'X'.
    ENDFORM.                    " PREPARE_LAYOUT
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_0100  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'CANCEL'.
    *  SET TITLEBAR 'xxx'.
    
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN 0.
        WHEN 'EXIT'.
          CALL TRANSACTION 'SE38'.
        WHEN 'CHANGE'.
          IF GR_ALVGRID->IS_READY_FOR_INPUT( ) = 0.
            CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 1.
    
          ELSE.
            CALL METHOD GR_ALVGRID->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 0.
    
          ENDIF.
      ENDCASE.

    Regards,

    Aswin

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2006 at 08:51 AM

    hi senden,

    try to refresh the internal table before populating it with new data..

    i think the display table is carrying the old data and is not getting cleared every time..

    regards

    satesh

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Satesh and Aswin,

      i tried both. Refresh the internal table with the output data on screen 2, and on screen 1 after selecting the material.

      But it didn't solve my problem.

      When i'm running the next statement with the new I_ALV_MSD data, it still showing the old data.

      call method g_grid_msd->set_table_for_first_display

      exporting

      is_layout = g_layout_msd

      it_toolbar_excluding = lt_exclude_msd

      i_bypassing_buffer = 'X'

      changing

      it_fieldcatalog = i_fieldcat_msd

      it_outtab = i_alv_msd.

      regards,

      Hans

      Message was edited by: Hans Senden

  • author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2006 at 08:53 AM

    after calling the function module to display the alv clear the internal table i_alv

    CLEAR I_ALV[].

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.