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 table statement

Former Member
0 Kudos

Hi all ,

I have written select statement extracted values in itab.iam uding read table like this.

read table itab with key a = b.

but filed a contains multiple records how to get those multiple records.with read statement iam getting single value ( I dont want to use loop statement and select statement ). Please let me know.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI Priya..

READ statement gives a single record which satisfies the condition first.

U have to use LOOP....ENDLOOP for multiple records for internal table

u cna write as..

Loop at itab where a = b.

......

..... ur code as per requirement.

Endloop.

Regards

CNU

7 REPLIES 7

Former Member
0 Kudos

HI Priya..

READ statement gives a single record which satisfies the condition first.

U have to use LOOP....ENDLOOP for multiple records for internal table

u cna write as..

Loop at itab where a = b.

......

..... ur code as per requirement.

Endloop.

Regards

CNU

Former Member
0 Kudos

HI,

You will get only one row..If you use READ TABLE..You have to use LOOP AT to get multiple records..

Thanks,

Naren

Former Member
0 Kudos

Check this:

/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops

No need to LOOP. You can read an entire table using READ.

Rob

Message was edited by:

Rob Burbank

0 Kudos

Try running this (not terribly efficient, but no loops):


REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80
  MESSAGE-ID 00.

PARAMETERS p_bukrs LIKE bkpf-bukrs.

DATA: BEGIN OF bkpf_int OCCURS 0.
        INCLUDE STRUCTURE bkpf.
DATA: END   OF bkpf_int.

DATA: no_lines  TYPE i,
      tab_index TYPE i.

SELECT * FROM bkpf
  INTO TABLE bkpf_int
  WHERE bukrs = p_bukrs.

DESCRIBE TABLE bkpf_int LINES no_lines.

tab_index = 1.

DO no_lines TIMES.
  READ TABLE bkpf_int INDEX tab_index.
  tab_index = tab_index + 1.

  WRITE: /001 bkpf_int-belnr.

ENDDO.

Rob

Former Member
0 Kudos

Hi priya.

to REAd all the records in itab u have to use LOOP ...ENdloop.

may i know why u dont want loop??

Former Member
0 Kudos

Through read statement you can get only single record.

you have to loop ... endloop. for more than 1 record.

regds,

kiran

Former Member
0 Kudos

Hi Priya,

If you dont need the records in the future which doesn't match those condition.

Then write the statement :

Delete table itab where a <> b.

Then all the records whose key is a <> b are deleted, Remaining are the records which are matching the key a = b.

Points Reward , If helpful.

Regards

Kannu