Application Development and Automation 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: 
Read only

Get values from a grid

Former Member
0 Likes
565

Hi experts,

I'm using a grid type cl_gui_alv_grid, and the situation is: the user will select the lines on the grid that he wants to process.

The first column of the grid is the key of the table that i will modify.

My difficulty is on get the value of the first cell of the selected lines.

Someone could help me?

Best regards,

Gustavo

Hi experts,

I'm using a grid type cl_gui_alv_grid, and the situation is: the user will select the lines on the grid that he wants to process.

The first column of the grid is the key of the table that i will modify.

My difficulty is on get the value of the first cell of the selected lines.

Someone could help me?

Best regards,

Gustavo

2 REPLIES 2
Read only

Former Member
0 Likes
526

data:      LAYOUT  TYPE LVC_S_LAYO,

LAYOUT-SEL_MODE = 'D'. /* or 'A'.

  CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY

      EXPORTING

           IS_LAYOUT              = LAYOUT

      CHANGING

           IT_OUTTAB       = GT_OUT[]

           IT_FIELDCATALOG = GT_FIELDCAT[].

This provides you the selection box in the ALV output,

Use the method GET_SELECTED_ROWS to process the rows. Write this code in the PAI.

WHEN 'PUSH'

DATA: INDEX_ROWS TYPE LVC_T_ROW,

      INDEX LIKE LINE OF INDEX_ROWS.

  CLEAR INDEX_ROWS.  REFRESH INDEX_ROWS.

  CALL METHOD ALV_GRID->GET_SELECTED_ROWS

           IMPORTING

                 ET_INDEX_ROWS = INDEX_ROWS.

      LOOP AT INDEX_ROWS INTO INDEX.

* Use the index to read the specific line of ALV which is selected and do the required action

        READ TABLE GT_OUT INTO WA_OUT INDEX INDEX-INDEX .

        IF SY-SUBRC = 0.

                        /*  do your work with WA_out-keyfield

                      MODIFY GT_OUT INDEX INDEX-INDEX FROM WA_OUT.

        ENDIF.

      ENDLOOP.

Read only

0 Likes
526

Hello Susmitha, it worked fine here. Thanks a lot.