Skip to Content
0
Former Member
Dec 03, 2008 at 07:48 AM

SubQuery Doubt

17 Views

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