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

working with a internal table and database

Former Member
0 Likes
610

hi!

I have a question with database tables.

If I want to read data from a database table using a record in an internal table, what is the best way of doing that? (for each record in the internal table, I have to read some records from the database table).

Thanks,

Srikanth.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
582

hi,

<b>use for all entries syntax</b>



REPORT abc.

DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

*--------------------

itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.


*--------------------

SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.


*--------------------------
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.

rgds

Anver

hi!

I have a question with database tables.

If I want to read data from a database table using a record in an internal table, what is the best way of doing that? (for each record in the internal table, I have to read some records from the database table).

Thanks,

Srikanth.

4 REPLIES 4
Read only

anversha_s
Active Contributor
0 Likes
583

hi,

<b>use for all entries syntax</b>



REPORT abc.

DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

*--------------------

itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.


*--------------------

SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.


*--------------------------
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.

rgds

Anver

Read only

Former Member
0 Likes
582

use FOR ALL ENTRIES in select statement

Read only

Former Member
0 Likes
582

hi,

You can use SELECT .. FOR ALL ENTRIES

Read only

Former Member
0 Likes
582

Use the FOR ALL ENTRIES, so that for all the data in the internal table, you get the data form the database.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm

Else you will have to loop at the internal table and fire the select inside the loop which will have performance issues.

Regards,

Ravi

Note - Please mark all the helpful answers