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: 

How to read a alv grid row data from standard program

Former Member
0 Kudos

Hi All,

I am working on transaction LBK1. Actually when you will open this transaction in the left hand side it will show you the data in tree. When you click on a notification node it will show the relevant data in right side. In which there is a operation tab . In this tab the data comes in alv grid. If user selects a row then I have to get that selected row value. There is also a toolbar above on the tree side. There are some buttons which execute our implementation class where I can put the code.

Can anyone please help me out? How I can read that selected row in our class/method?

Thanks in advance.

Best Regards

Ritu

2 REPLIES 2

Former Member
0 Kudos

Setting and getting selected rows (Columns) and read line contents

You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similiar methods for columns.

Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows fronm the table. In the examples below the grid table is named gi_sflight.

Data declaratrion:

DATA:

  • Internal table for indexes of selected rows

gi_index_rows TYPE lvc_t_row,

  • Information about 1 row

g_selected_row LIKE lvc_s_row.

Example 1: Reading index of selected row(s) and using it to read the grid table

CALL METHOD go_grid->get_selected_rows

IMPORTING

et_index_rows = gi_index_rows.

DESCRIBE TABLE gi_index_rows LINES l_lines.

IF l_lines = 0.

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'

EXPORTING

textline1 = 'You must choose a valid line'.

EXIT.

ENDIF.

LOOP AT gi_index_rows INTO g_selected_row.

READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.

ENDIF.

ENDLOOP.

Example 2: Set selected row(s).

DESCRIBE TABLE gi_index_rows LINES l_lines.

IF l_lines > 0.

CALL METHOD go_grid->set_selected_rows

exporting

it_index_rows = gi_index_rows.

ENDIF.

Former Member
0 Kudos

This message was moderated.