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: 

Read single entry from an internal table

Former Member
0 Kudos
18,224

hi abappers,

instead of select sibgle i want to read a single value from an internal tabel.

how can i use this....

provide the syntax.

regards,

mansi

10 REPLIES 10

Former Member
0 Kudos
3,073

try using <b>read table</b>

Former Member
0 Kudos
3,073

if its only 1 record

read table i_tab into wa_tab index 1. ? not too sure on this.

or if you have condition

read table i_tab into wa_tab WITH key FIELD = SEARCH_TERM

binary serach

transporting <FIELD>

that <field> is the fields that you want to use.

Former Member
0 Kudos
3,073

Hi

Either use READ table

or

loop at itab where condition and move the value to a variable

Thanks

Shiva

0 Kudos
3,073

HI,

There are two ways using READ TABLE..

READ TABLE itab into wa_area INDEX 1.

READ TABLE itab into wa_area INDEX n.

READ TABLE itab into wa_area WITH KEY filed1 = value1. (Use key).

Regards,

Sesh

Former Member
0 Kudos
3,073

Use READ statement

READ TABLE itab INTO wa_itab WITH key <FIELD> = <value>.

OR

READ TABLE itab INTO wa_itab INDEX <num>.

Former Member
0 Kudos
3,073

Hi,

To read a single entry from a table you ahve to use READ.

READ TABLE itab WITH INDEX 1. 

READ TABLE itab WITH KEY matnr = '10000010'.

After read u have to use a sy-subrc check and proceed.

If you want to read based on some values from a table then

LOOP AT itab.
CLEAR itab2.
READ TABLE itab2 WITH KEY matnr = itab-matnr.
IF sy-subrc = 0.
...........
ENDIF.
ENDLOOP.

Hope this solves ur query, please close the thread by rewarding points.

Former Member
0 Kudos
3,073

Hi Mansi,

You can use READ TABLE for reading a single entry.

You have your data in the internal table so just read the table inside the loop using index or the key.

READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> = <fn> <result>.

READ TABLE <itab> INDEX <idx> <result>.

The system reads the line with the index <idx> from the table <itab>.

The <result> part can specify a further processing option for the line that is retrieved.

If an entry with the specified index was found, the system field SY-SUBRC is set to 0 and SY-TABIX contains the index of that line. Otherwise, SY-SUBRC is set to a value other than 0.

Regards,

Papiya.

Former Member
0 Kudos
3,073

Hi,

Select Single is use d to read a single first matching line from the database table and not from the internal table.

To read a line from the internal table you have to use the READ TABLE itab with KEY fld1 = val1 BINARY SEARCH.

Addition of binary search improves performance, but the table should be sorted on that field.

Regards

Subramanian

Former Member
0 Kudos
3,073

Hi Mansi,

use <b>READ TABLE itab into wa_area INDEX n</b>

reward point if helpful.