Skip to Content
author's profile photo Former Member
Former Member

ALV Grid OO u2013 Get_selected_rows u2013 I can I re-display ALV Grid with selected

I am using ALV grid OO to handle my ALV grid processing. I display a list at the user. The user selects their records and presses a button to call another dynpro to process the selected rows. I use SAP method get_selected_rows to gather all of the selected rows on the grid. The user then performs an action on the selected rows in the called dynpro. When done, return is passed back to the ALV grid display in the initial program. When the program returns back to the initial program; the rows that were selected are now de-selected. How do I keep from refreshing the ALV grid when control is passed back to the initial program? Any sample code would be of great help! As always points will be rewarded for u201Chelpfulu201D assistance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 09:45 PM

    I think u r calling the method REFRESH_TABLE_DISPLAY before returning back to ALV from the second dynpro, if it is true then pass the parameter IS_STABLE as IS_STABLE-ROW = 'X' and IS_STABLE-COL = 'X' to tis method.

    Regards,

    Joy.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      It would go like this:

            DATA: lv_stable TYPE lvc_s_stbl.
            lv_stable-row = 'X'.
            lv_stable-col = 'X'.
            my_grid->refresh_table_display(
                 EXPORTING is_stable = lv_stable
                    ).
      

      ... but I'm not sure that will help you. This seems to preserve scroll bar positions, not row selections. If you must refresh your table display then you might try using the grid's set_selected_rows method to reselect the rows in the grid screen's PBO.

  • Posted on Jun 18, 2008 at 04:32 AM

    Hello Rod

    On ECC 6.0 the selection is maintained (single or multiple row selection).

    Perhaps sample report ZUS_SDN_TWO_ALV_GRIDS_2SCR may be useful:

    *&---------------------------------------------------------------------*
    *& Report  ZUS_SDN_TWO_ALV_GRIDS_2SCR
    *&
    *&---------------------------------------------------------------------*
    *& Thread: ALV Grid OO u2013 Get_selected_rows u2013 I can I re-display ALV Grid with selected
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="924061"></a>
    *&
    *& Thread: CL_GUI_ALV_GRID-GET_SELECTED_ROWS Parameter ET_INDEX_ROWS not filled.
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="826287"></a>
    *&
    *& Thread: ALV double-click
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="900214"></a>
    *&---------------------------------------------------------------------*
    *& Screen '0100' contains no elements.
    *& ok_code -> assigned to GD_OKCODE
    *&
    *& Flow logic:
    *  PROCESS BEFORE OUTPUT.
    *    MODULE STATUS_0100.
    **
    *  PROCESS AFTER INPUT.
    *    MODULE USER_COMMAND_0100.
    *&
    *& Screen '0200': copy of screen '0100' (for the sake of simplicity)
    *&---------------------------------------------------------------------*
    
    REPORT  zus_sdn_two_alv_grids_2scr.
    
    
    
    
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syrepid,
    *
      go_docking1      TYPE REF TO cl_gui_docking_container,
      go_docking2      TYPE REF TO cl_gui_docking_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    
    
    DATA:
      gt_outtab1       TYPE STANDARD TABLE OF knb1,
      gt_outtab2       TYPE STANDARD TABLE OF knvv.
    
    
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_eventhandler DEFINITION
    *---------------------------------------------------------------------*
    *
    *---------------------------------------------------------------------*
    CLASS lcl_eventhandler DEFINITION.
    
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    
    
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    
    
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_eventhandler IMPLEMENTATION
    *---------------------------------------------------------------------*
    *
    *---------------------------------------------------------------------*
    CLASS lcl_eventhandler IMPLEMENTATION.
    
      METHOD handle_double_click.
    *   define local data
        DATA:
          lt_rows   type lvc_t_row.
    
        CHECK ( sender = go_grid1 ).
    
        append e_row to lt_rows.
    
        CALL METHOD go_grid1->set_selected_rows
          EXPORTING
            it_index_rows            = lt_rows
    *        it_row_no                =
    *        is_keep_other_selections =
            .
    
    *   Triggers PAI of the dynpro with the specified ok-code
        CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
    
    
    
      ENDMETHOD.                    "handle_double_click
    
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    
    
    
    
    START-OF-SELECTION.
    
      SELECT        * FROM  knb1 INTO TABLE gt_outtab1
             WHERE  bukrs  = '1000'.
    
    
      PERFORM init_controls.
    
    
    * Display data
      gs_layout-grid_title = 'Customers'.
      gs_layout-sel_mode   = 'D'.  " multiple row selection
      gs_layout-sel_mode   = ' '.  " single row selection
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNB1'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = gt_outtab1
        EXCEPTIONS
          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.
      ENDIF.
    
      gs_layout-grid_title = 'Customers Details (Sales Areas)'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNVV'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = gt_outtab2  " empty !!!
        EXCEPTIONS
          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.
      ENDIF.
    
    
      gd_repid = syst-repid.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking1->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          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.
      ENDIF.
    
    * Link the docking container to the target dynpro
      CALL METHOD go_docking2->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          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.
      ENDIF.
    
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro '0100' (does not contain any dynpro elements):
    *
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    **
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    
    
    
    END-OF-SELECTION.
    
    
    *&---------------------------------------------------------------------*
    *&      Form  INIT_CONTROLS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM init_controls .
    
    * Create docking container
      CREATE OBJECT go_docking1
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
    
    * Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent = go_docking1
        EXCEPTIONS
          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.
    
    
    * Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_double_click FOR go_grid1.
    
    
    * Create docking container
      CREATE OBJECT go_docking2
        EXPORTING
          parent = go_docking2
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
    * Create ALV grids
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent = go_docking2
        EXCEPTIONS
          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.
    
    ENDFORM.                    " INIT_CONTROLS
    
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_0100  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    *  SET TITLEBAR 'xxx'.
    
    
    * Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          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.
    
    
    ENDMODULE.                 " STATUS_0100  OUTPUT
    
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_0100  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
    
      TRANSLATE gd_okcode TO UPPER CASE.
    
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          CASE syst-dynnr.
            WHEN '0100'.
              SET SCREEN 0. LEAVE SCREEN.
            WHEN '0200'.
              SET SCREEN '0100'.
              LEAVE SCREEN.
          ENDCASE.
    
    *   User has pushed button "Display Details"
        WHEN 'DETAIL'.
          PERFORM entry_show_details.
          CALL SCREEN '0200'.
    
          WHEN 'DELETE'.
            perform DELETE_ENTRIES.
    
        WHEN OTHERS.
      ENDCASE.
    
      CLEAR: gd_okcode.
    
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    
    *&---------------------------------------------------------------------*
    *&      Form  ENTRY_SHOW_DETAILS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM entry_show_details .
    * define local data
      DATA:
        ls_row      TYPE lvc_s_row,
        lt_rows     type lvc_t_row,
        ls_knb1     TYPE knb1,
        lt_knb1     TYPE STANDARD TABLE OF knb1.
    
    
    
      CALL METHOD go_grid1->get_selected_rows
        IMPORTING
          et_index_rows = lt_rows
    *      et_row_no     =
          .
    
      LOOP AT lt_rows INTO ls_row.
        READ TABLE gt_outtab1 INTO ls_knb1 INDEX ls_row-index.
    
        APPEND ls_knb1 TO lt_knb1.
      ENDLOOP.
    
      IF ( lt_rows IS INITIAL ).
        REFRESH: gt_outtab2.
      ELSE.
        SELECT * FROM  knvv INTO TABLE gt_outtab2
            FOR ALL ENTRIES IN lt_knb1
               WHERE  kunnr  = lt_knb1-kunnr.
      ENDIF.
    
    
    
    ENDFORM.                    " ENTRY_SHOW_DETAILS
    *&---------------------------------------------------------------------*
    *&      Form  DELETE_ENTRIES
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    form DELETE_ENTRIES .
    * define local data
      DATA:
        ls_row      TYPE lvc_s_row,
        lt_rows     type lvc_t_row.
    
      CALL METHOD go_grid1->get_selected_rows
        IMPORTING
          et_index_rows = lt_rows
    *      et_row_no     =
          .
    
      LOOP AT lt_rows INTO ls_row.
        delete gt_outtab1 INDEX ls_row-index.
      ENDLOOP.
    
      go_grid1->refresh_table_display( ).  " Mandatory !!!
    
    
    endform.                    " DELETE_ENTRIES
    

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 04:36 AM

    Hi,

    In ALV, to refresh the table you have to call the method "refresh_table_display".

    It has the syntax very similar to creating the table.

    It has two parameters. In the first one, you can mention if you want to refresh only the data (the icons are not refreshed)

    or

    if you want to refresh only the icons around the grid (the data is not refreshed - this option is mostly not used in day to day applications).

    the synatx is :-

    call method grid (name of grid )->refresh_table_display

    exporting

    IS_STABLE = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING)

    I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).

    Reward pts. if usefull.

    Regards,

    Dhan

    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.