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: 

ALV Problem-Urgent!!!

Former Member
0 Kudos
155

Hi,

I have an ALV gird display(using objects).I am getting the output in ALV.Now,I have a button (CHANGE)in the toolbar which is created by me,first the user will select the rows( or multiple rows) from ALV and then click on the CHANGE button(which is created by me),now how to I read the data selected by the user.?

I used the following code :

CASE e_ucomm.

WHEN 'CHANGE'.

CALL METHOD grid1-><b>get_selected_rows</b>

IMPORTING et_index_rows = lt_rows.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = g_repid

txt2 = sy-subrc

txt1 = 'Error in Flush'(500).

ELSE.

CALL SCREEN 9001 STARTING AT 05 05

ENDING AT 40 12.

ENDIF.

ENDCASE.

............................................................

lt_rows gives me the index of the row that has been selected.But now how do I read the data corresponding to that index.

The data I am displaying in the ALV grid is stored in an Internal Table LT_DISPLAY.

Please help..its urgent.

Thanks.

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos
123

You can use the READ statement

Like:



CASE e_ucomm.
WHEN 'CHANGE'.
CALL METHOD grid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.

READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX IT_ROWS.  " < get values

CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ELSE.
CALL SCREEN 9001 STARTING AT 05 05
ENDING AT 40 12.
ENDIF.
ENDCASE.

Regards,

Naimesh Patel

11 REPLIES 11

naimesh_patel
Active Contributor
0 Kudos
124

You can use the READ statement

Like:



CASE e_ucomm.
WHEN 'CHANGE'.
CALL METHOD grid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.

READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX IT_ROWS.  " < get values

CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ELSE.
CALL SCREEN 9001 STARTING AT 05 05
ENDING AT 40 12.
ENDIF.
ENDCASE.

Regards,

Naimesh Patel

0 Kudos
123

Hi,

thanks for that, even i thought that read would work.but it is giving me an error saying " LT_ROWS cannot be a table ,a reference ,a string or contain any of these objects".

what to do ?

0 Kudos
123

Try like this

READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX LT_ROWS-ROW_ID.

Pavan

0 Kudos
123

You need to use the INDEX field of the structure IT_ROWS.

DATA: WA_ROWS TYPE LVC_S_ROW.

READ TABLE IT_ROWS INTO WA_ROWS.

READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX <b>WA_ROWS-INDEX</b>.

Sorry, It's my mistaks.

Regards,

Naimesh Patel

0 Kudos
123

Whats the value in LT_ROWS.

If it has a numeric value it should.

Shreekant

0 Kudos
123

Hi,

This is the code :

DATA: t_display TYPE TABLE OF zstatchng ,

lt_display LIKE LINE OF t_display .

DATA: lt_rows TYPE lvc_t_row.

<b>READ TABLE t_display INTO lt_display INDEX lt_rows-index.</b>

when I try this, it gives me an error saying LT_ROWS is a table without header line so it has no component like INDEX.

What's the problem....when I debug and see , I get two fields for LT_ROWS one is ROWTYPE and one is index. if I select the first row, Rowtype is blank and Index is one....but the read is failing...dont know why..!!!!

0 Kudos
123

Try like this:

DATA: WA_ROWS TYPE LVC_S_ROW.

READ TABLE IT_ROWS INTO WA_ROWS.

READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX WA_ROWS-INDEX.

Regards,

Naimesh Patel

0 Kudos
123

Hi,

it asks for an Index in the statement READ TABLE IT_ROWS INTO WA_ROWS.

0 Kudos
123

Oh ok,

Corrected:

DATA: WA_ROWS TYPE LVC_S_ROW.
READ TABLE IT_ROWS INTO WA_ROWS INDEX 1.  " << I assume you will only select one record.
READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX WA_ROWS-INDEX.

if you want multiple records than,

LOOP AT IT_ROWS INTO WA_ROWS.
 READ TABLE LT_DISPLAY INTO WA_DISPLAY INDEX WA_ROWS-INDEX.
ENDLOOP.

Regards,

Naimesh Patel

0 Kudos
123

Hi ,

Now its working fine.Thanks a lot for your help...Awarded points to you.

Thanks Again.

Regards,

Deepti.

Former Member
0 Kudos
123

A simple Read statement Should work.

Eg,

Read Table lt_display index lt_rows.

It ilt_diaplay dosent have a header line,

A simple Read statement Should work.

Eg,

Read Table lt_display into wa_diaplay index lt_rows.

Hope it helps.

Shreekant