Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

capturing selected rows from output

how to capture selcted rows from alv grid display.(oops)

Tags:
Former Member
replied

Hi urmila,

I did a check with your code. I tweaked it a bit to use standard SFLIGHT table and it is working.

Don't look at that parts where SFLIGHT is used.

DATA: v_layout TYPE lvc_s_layo,
      grid2 TYPE REF TO cl_gui_alv_grid.

DATA: it_final_raw TYPE STANDARD TABLE OF sflight.   "here an example output table

START-OF-SELECTION.
"you don't use this, it's for my usage
  SELECT * FROM sflight INTO TABLE it_final_raw.  

  CREATE OBJECT grid2
    EXPORTING
      i_parent          = cl_gui_container=>screen0.

 "here is your code
  v_layout-sel_mode = 'A'.

  CALL METHOD grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SFLIGHT'       "populate fieldcatalog instead of SFLIGHT (as you do this in your code)
      is_layout        = v_layout
    CHANGING
      it_outtab        = it_final_raw.

  CALL SCREEN '0100'.    

*----------------------------------------------------------------------*
*  MODULE STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS space.
ENDMODULE.                    "STATUS_0100 OUTPUT

*----------------------------------------------------------------------*
*  MODULE USER_COMMAND_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.

  "select your desired rows as shown in the screenshot link below the code
   "then hit back button

    WHEN 'BACK'.   

      DATA : it_rows TYPE lvc_t_roid..
      CALL METHOD grid2->get_selected_rows
        IMPORTING
          et_row_no = it_rows.
     "here you will get all marked rows in it_rows table

  ENDCASE.

ENDMODULE.                    "USER_COMMAND_0100 INPUT

http://myworld.hekko.pl/alv.JPG

Sorry for being trival but sometimes it is only way for solving an issue.

It is working fine for me so it must work for you too.

BR

Marcin

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question