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

SQL query with subquery of internal table

Former Member
0 Likes
928

Hi,

Can i use internal table for subquery, like

select ... into table itab_list from aufk where

aufk~objnr in (select objnr from itab1)

itab1 is a internal table which contain the valid objnr list.

How can i do that. Thanks.

Hi,

Can i use internal table for subquery, like

select ... into table itab_list from aufk where

aufk~objnr in (select objnr from itab1)

itab1 is a internal table which contain the valid objnr list.

How can i do that. Thanks.

4 REPLIES 4
Read only

Former Member
0 Likes
737

FOR ALL ENTRIES is preferred rather than subqueries in terms of performance.

However you can check below link on how to use subqueries:

http://help.sap.com/saphelp_erp2004/helpdata/en/dc/dc7614099b11d295320000e8353423/frameset.htm

Thanks,

Santosh

Read only

Former Member
0 Likes
737

Assuming itab1 has a field OBJNR, and you want to get records from AUFK where the objnr is in itab1, the syntax is:

select ...

from aufk

for all entries in itab1

where objnr = itab1-objnr.

Michael

Read only

Former Member
0 Likes
737
select objnr from ztable into table itab1.


if not itab[] is initial.
select ... into table itab_list from aufk  FOR 
ALL ENTRIES in ITAB1 where aufk~objnr = itab-objnr.
endif.
Read only

Former Member
0 Likes
737

Hi Portfolio,

You can't use like below.Instead of that use for all entries.

Ex: Assume you have data in ITAB1.

IF NOT itab1 IS INITIAL.

SELECT * FROM aufk into table ITAB2

for all entries in itab1

where objnr eq itab-objnr.

ENDIF.

Pls. mark if useful.