全部博文(38)
分类: 信息化
2015-04-21 17:38:47
INSERT INTO ZMMCV01(MANDT, MATNR,ATINN, ATZHL, ATWRT, ATBEZ)
SELECT A.MANDT, A.MATNR, B.ATINN, B.ATZHL, B.ATWRT, N.ATBEZ FROM MARA A
INNER JOIN AUSP B ON A.MANDT = B.MANDT AND trim(to_char( A.CUOBF,'000000000000000000')) = B.OBJEK
INNER JOIN CABN M ON B.MANDT = M.MANDT AND B.ATINN = M.ATINN
INNER JOIN CABNT N ON M.MANDT = N.MANDT AND M.ATINN = N.ATINN
INNER JOIN KLAH E ON A.MANDT = E.MANDT AND E.CLASS = A.SATNR
INNER JOIN KSSK F ON A.MANDT = F.MANDT AND length(f.OBJEK)>4 and
trim(to_char(F.OBJEK,'000000000000000000')) = trim(to_char(E.CLINT,'000000000000000000')) AND B.MAFID = F.MAFID
INNER JOIN KLAH G ON A.MANDT = G.MANDT AND F.CLINT = G.CLINT
WHERE A.MANDT = :SY-MANDT
AND A.LVORM <> 'X'
AND B.ATAUT <> '8'
AND B.MAFID = 'O'
AND F.MAFID = 'O'
AND N.SPRAS = '1'
AND A.MATNR NOT IN ( SELECT DISTINCT MATNR FROM ZMMCV01 WHERE MANDT = :SY-MANDT )
GROUP BY A.MANDT, A.MATNR, B.ATINN, B.ATZHL, B.ATWRT, N.ATBEZ
INSERT INTO ZMMCV01(MANDT, MATNR,ATINN, ATZHL, ATWRT, ATBEZ)
SELECT A.MANDT, A.MATNR, B.ATINN, B.ATZHL, B.ATWRT, N.ATBEZ
FROM MARA A
INNER JOIN AUSP B ON A.MANDT = B.MANDT AND B.ATAUT <> '8' AND B.MAFID = 'O'
AND trim(to_char( A.CUOBF,'000000000000000000')) = B.OBJEK
INNER JOIN CABN M ON B.MANDT = M.MANDT AND B.ATINN = M.ATINN
INNER JOIN CABNT N ON M.MANDT = N.MANDT AND M.ATINN = N.ATINN AND N.SPRAS = '1'
INNER JOIN KLAH E ON A.MANDT = E.MANDT AND E.CLASS = A.SATNR
INNER JOIN KSSK F ON A.MANDT = F.MANDT AND length(f.OBJEK)>4 AND F.MAFID = 'O'
and trim(to_char(F.OBJEK,'000000000000000000')) = trim(to_char(E.CLINT,'000000000000000000'))
AND B.MAFID = F.MAFID
INNER JOIN KLAH G ON A.MANDT = G.MANDT AND F.CLINT = G.CLINT
WHERE A.MANDT = :SY-MANDT AND A.LVORM = ' '
AND not exists ( SELECT MATNR FROM ZMMCV01 C where a.mandt=c.mandt and a.matnr=c.matnr)
GROUP BY A.MANDT, A.MATNR, B.ATINN, B.ATZHL, B.ATWRT, N.ATBEZ