Skip to Content
0
Oct 16, 2019 at 10:23 AM

SELECT IN SELECT CODE WITH INNER JOIN

122 Views

hi expert,

i need to get output of (plant, plant name, material, sku, description, descriptiob, loc, stock qty, avg cost, last recv.

please correct my code, because i can't get all the column with this code:

SELECT A~WERKS
C~NAME1
A~MATNR
E~BISMT
B~MAKTX
A~LGORT
SUM( CLABS ) AS SUM_CLABS
INTO TABLE T_COMB
(SELECT CASE WHEN LBKUM = 0 THEN 0 ELSE ROUND(((SALK3 * 100) / LBKUM),0)
FROM MBEW
WHERE BWKEY = A~WERKS
AND MATNR = A~MATNR) AS AVGCOST
(SELECT MAX( BUDAT_MKPF ) AS BUDAT_MKPF
FROM MSEG AS D
WHERE D~WERKS = A~WERKS
AND D~MATNR = A~MATNR
AND BWART = '101') LAST_RECV
FROM MCHB AS A
INNER JOIN MAKT AS B
ON A~MATNR = B~MATNR
INNER JOIN T001W AS C
ON A~WERKS = C~WERKS
INNER JOIN MARA AS E
ON A~MATNR = E~MATNR
WHERE A~WERKS IN ('2297','21B7')
AND LGORT = 'WR02'
AND MTART NOT IN ('ZNS','ZNV','ZSR')
GROUP BY A~WERKS C~NAME1 A~MATNR E~BISMT B~MAKTX A~LGORT
ORDER BY A~WERKS A~MATNR