CKM3 可以查指定期间的某个物料的成本构成,但只能一次查一个,以下SQL 可以成批查询。原创归:唐
SELECT DD.MATNR,DD.BWKEY,RP.JAHRPER,RP.MEINS,CC.ELEMENT,SUM (CC.TOT) TOT FROM MLDOC RP INNER JOIN MLDOCCCS CC ON RP.MANDT = CC.MANDT AND RP.DOCREF = CC.DOCREF AND RP.CURTP = CC.CURTP INNER JOIN CKMLHD DD ON RP.KALNR = DD.KALNR WHERE RP.CURTP = '10' AND RP.CATEG = 'ZU' AND ( RP.JAHRPER = '2021010' AND RP.XABR IN ( '','X') OR RP.JAHRPER <= '2021010' AND RP.JAHRPER >= '2021010' AND RP.XABR = '' ) AND RP.RUNREF IN ( 'ACT','' ) AND CC.MLCCT IN ('E','F','V') AND CC.KEART = 'H' AND ( CC.SVREL = 'X' OR CC.ELEMENT = '000') GROUP BY DD.MATNR,DD.BWKEY,RP.JAHRPER,RP.MEINS,CC.ELEMENT ORDER BY CC.ELEMENT