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: 

SubQuery Doubt

Former Member
0 Kudos

Moderator message: Please use meaningful subject in future

Initially i'm doing likes this:-

  • get Material no to itAB.

SELECT MATNR FROM MARA AS F

INTO CORRESPONding Fields of TABLE ITAB

WHERE MATKL IN MATGRP.

LOOP AT ITAB

  • for every MATNR

SELECT *

FROM ( ( MSEG AS A

INNER

JOIN MKPF AS B

ON B~MBLNR = A~MBLNR ) " Material Documber Number

INTO CORRESPONding Fields of TABLE ITAB

WHERE A~WERKS IN PLANTS

AND A~MATNR = MATNR.

  • There is many MBLNR returns for each MATNR

MODIFY the ITAB where ITAB-MBLNR = MBLNR. " Updating only if Material Documber Number matches.

END LOOP

Combing two select statement into Subquery:-

SELECT *

FROM ( ( MSEG AS A

INNER

JOIN MKPF AS B

ON BMBLNR = AMBLNR )

INTO CORRESPONding Fields of TABLE ITAB

WHERE A~WERKS IN PLANTS

AND A~MATNR IN (

SELECT MATNR FROM MARA AS F WHERE MATKL IN MATGRP ).

Will subquery return the same as above.

Should i use EXISTs or IN for every Materinal NO which returns mutiple material number.

Please advise on this.

Edited by: Matt on Dec 3, 2008 10:06 AM

2 REPLIES 2

Former Member
0 Kudos

using " for all entries in ITAB " in second SELECT statement would be a safer .

0 Kudos

you mean in the subquery? is it EXIST or IN, i should use in the subquery