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 pass select-options in key while using Read Statement.

Former Member
0 Kudos

Hi SAP gurus,

I was using a select stmt. with were clause of Select-options it was working fine,

now my scenerio is changed i need to read an internal table

with key of select-options....

how to read internal table with key S_MATNR (Select-options).

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You cannot use READ TABLE but LOOP AT ITAB will work


data: t_mara type TABLE OF mara,
      e_mara type mara.
SELECT-OPTIONS: s_matnr for mara-matnr.

LOOP at t_mara INTO e_mara WHERE matnr in s_matnr.
ENDLOOP.

4 REPLIES 4

Former Member
0 Kudos

reading a internal will always return single record. but in select options is itself works as a table. so you need to read the table for each value of select options by putting a loop.

Regards,

Azad.

Former Member
0 Kudos

You cannot use READ TABLE but LOOP AT ITAB will work


data: t_mara type TABLE OF mara,
      e_mara type mara.
SELECT-OPTIONS: s_matnr for mara-matnr.

LOOP at t_mara INTO e_mara WHERE matnr in s_matnr.
ENDLOOP.

Former Member
0 Kudos

Hi,

We can certainly do this.

We need to loop the internal table with select-options condition.

Example :

LOOP AT ITAB WHERE FIELD =  S_FIELD.
.............
ENDLOOP.

This should solve your problem.

Plz reward if useful.

Thanks,

Dhanashri.

former_member182485
Active Contributor
0 Kudos

Loop at the select option and read the table for each value of select option.

There is no other way out, we can't not use select-options as key for read statment.

Regards

Bikas