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

Read statment issue

Former Member
0 Likes
748

Hi ,

My itab internal table is having 10 reocrds of kotabnr = '001' the below code i have written

will go for all 10 record or only one record.

if read will get only one record, means how best i can write the code to get 10 records from intrnal table without LOOP

-


READ TABLE Itab WITH KEY kotabnr = '001' TRANSPORTING NO FIELDS.

IF sy-subrc EQ 0.

Select

KBSTAT

KNUMH

from A912 into table i_a912 where knumh = ls_headr_item-knumh.

Endif.

Regards,

Sri

6 REPLIES 6
Read only

Former Member
0 Likes
707

Read table command reads only one record ,that means it will go only one time,if you need multiple times then use loop and endloop.

Thank you

Seshu

Read only

Former Member
0 Likes
707

Hi,

So whats the purpose of that READ statement, why you don't want to go for LOOP. If possible try to use For All Entries Statement in Select query, that will increase performance.

Regards

Karthik D

Read only

0 Likes
707

Karthik,

The loop is not allowed since the data volume is huge.The Read stmt is used to identfiy the data base table dynamically (which table we need to select more than on DB table i neeed to do select based on the interies-field in itab).

So only iam searching for new options which will give better performance...

Regards,

Sri

Read only

0 Likes
707

Hi,

Please use 'FOR ALL ENTRIES' in your select statement..... Read will always return only one instance...

Read only

Former Member
0 Likes
707

Hi Sriram,

With read you can perform only these operations....

READ

Read an internal table

- READ TABLE itab FROM wa [additions].

- READ TABLE itab WITH TABLE KEY k1 = v1 ...kn = vn [additions].

- READ TABLE itab WITH KEY k1 = v1 ...kn = vn [BINARY SEARCH] [additions].

- READ TABLE itab INDEX i [additions].

- Obsolete Variants

Read a program

- READ REPORT prog INTO itab.

Read text elements

- READ TEXTPOOL prog ...INTO itab ...LANGUAGE lg.

Read from a file

- READ DATASET dsn INTO f.

Read a database table

- READ TABLE dbtab.

Thanks & Regards,

Dileep .C

Read only

Former Member
0 Likes
707

Hi,

The other posters are right. You can't use READ to get more than one entry.

The best thing you can use if you don't want to use loop is to use FOR ALL ENTRIES inside your SELECT statement:

Select
KBSTAT
KNUMH
from A912 into table i_a912 FOR ALL ENTRIES IN internal_table where knumh = internal_table-knumh