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 get records with key itab by one DB access

felix_yan
Employee
Employee
0 Kudos

Hi all,

I am facing such a case to avoid mutliple db access.

What I have is an internal table with key column filled, now I need all the infos. The normal way should loop the itab, and select data from db to fill current line. But you see, it has to access DB line by line.

Hope somebody suggest a new select clause which can retrieve all the info by one access.

Is it possible?

Thanks for your answer.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

To retrieve the data from the DB table using the internal table, then use FOR ALL ENTRIES key word, then you can retrieve the records from the database table with single select.

ex:

if not tab[] is initial.

select * from kna1

into table t_kna1

for all entries in itab

where kunnr eq itab-kunnr.

endif.

Even we can push the data to the DB (database) table using internal table.

INSERT INTO [DB table] FROM TABLE itab [ACCEPTING DUPLICATE KEYS]

Same we can do update... etc

Reward with points if it is helpful.

3 REPLIES 3

Former Member
0 Kudos

Hi,

To retrieve the data from the DB table using the internal table, then use FOR ALL ENTRIES key word, then you can retrieve the records from the database table with single select.

ex:

if not tab[] is initial.

select * from kna1

into table t_kna1

for all entries in itab

where kunnr eq itab-kunnr.

endif.

Even we can push the data to the DB (database) table using internal table.

INSERT INTO [DB table] FROM TABLE itab [ACCEPTING DUPLICATE KEYS]

Same we can do update... etc

Reward with points if it is helpful.

Former Member
0 Kudos

Hi,

The solution provided by Ravi is correct. Why you have not marked your post as answered. Is there anything else you are looking for.

0 Kudos

Thank you both.