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: 

Nested SQL query in ABAP

Former Member
0 Kudos

Hi experts,

I would like to know how can I translate this nested SQL statement into an ABAP query (both MyTable1 and MyTable2 have as primary key the field "myfield"):

SELECT t1.myfield

FROM MyTable1 as t1

WHERE t1.myfield NOT IN (SELECT t2.myfield

FROM MyTable2 as t2)

Full points available

Thank you

Francesco

4 REPLIES 4

Former Member
0 Kudos

Hi

SELECT T1.MYFILED FROM TABLE1 INTO TABLE ITAB1 WHERE CONDITION .

IF NOT ITAB1[] IS INITIAL

SELECT T2.MYFILED FROM TABLE2 INTO ITAB2 FOR ALL ENTRIES IN ITAB1 WHERE CONDITION T2.MYFILED = ITAB1-T1.MYFIELD.

ENDIF.

reward if usefull

Former Member
0 Kudos

hi

yes this i s possible with the for all entries in abap

u can use like this

select myfield

from mytable1

into table itab1

for all entries not in itab2

where myfield = itab2-myfield.

otherwise

u can use joins also

Former Member
0 Kudos

Hi Francesco,

try this.

SELECT T1.MYFILED FROM TABLE1 INTO TABLE ITAB1 WHERE CONDITION .

IF NOT ITAB1[] IS INITIAL

SELECT T2.MYFILED FROM TABLE2 INTO ITAB2 FOR ALL ENTRIES IN ITAB1 WHERE CONDITION T2.MYFILED NE ITAB1-T1.MYFIELD. ( bcos, in the select statemnet there its given <b>NOT IN</b> )

ENDIF.

Reward If uSeful

Regards,

Chitra

Former Member
0 Kudos

Thank you all! I resolved thanks to your help. I'm trying to assing points but the radio button are not visible....