DATA:LT_TMP TYPE TABLE OF MATDOC WITH NON-UNIQUE SORTED KEY KEY COMPONENTS SMBLN SJAHR SMBLP. "过滤掉已取消 SELECT A~MATNR,A~WERKS,A~KOSTL,A~MENGE,A~BWART,A~BUDAT, A~MBLNR,A~MJAHR,A~ZEILE, A~SMBLN,A~SJAHR,A~SMBLP FROM MATDOC AS A INNER JOIN @LT_DATA AS B ON A~MATNR = B~MATNR AND A~WERKS = B~WERKS WHERE A~BUDAT IN @S_JZDAT AND ( A~BWART = '301' OR A~BWART = '302' OR A~BWART = '311' OR A~BWART = '312' ) AND CANCELLED IS INITIAL AND XAUTO IS INITIAL INTO CORRESPONDING FIELDS OF TABLE @LT_TMP. "过滤掉反向冲销 DATA(LT_TMP_REV) = FILTER #( LT_TMP IN LT_TMP USING KEY KEY WHERE MBLNR NE SMBLN ). LOOP AT LT_TMP INTO DATA(LS_TMP) WHERE BWART = '301' OR BWART = '311'. READ TABLE LT_TMP_REV INTO DATA(LS_TMP_REV) WITH TABLE KEY KEY COMPONENTS SMBLN = LS_TMP-MBLNR SJAHR = LS_TMP-MJAHR SMBLP = LS_TMP-ZEILE. IF SY-SUBRC NE 0. APPEND CORRESPONDING #( LS_TMP ) TO LT_MATDOC. ENDIF. ENDLOOP.
或者
SELECT FROM MATDOC AS M INNER JOIN +ORD AS D ON M~AUFNR = D~AUFNR AND M~WERKS = D~WERKS FIELDS M~MBLNR, M~MJAHR, M~ZEILE, M~AUFNR, M~WERKS, M~MATNR, "M~MENGE, M~STOCK_QTY AS MENGE, M~BWART WHERE M~BUDAT EQ @P_BUDAT AND M~CANCELLED IS INITIAL "AND M~MBLNR NE M~LFBNR AND NOT EXISTS ( SELECT * FROM M_MBMPS AS S WHERE S~SMBLN = M~MBLNR AND S~SJAHR = M~MJAHR AND S~SMBLP = M~ZEILE ) INTO TABLE @_T_MATDOC.
标签:TMP,WERKS,matdoc,取未,MBLNR,LT,冲销,LS,BWART From: https://www.cnblogs.com/yangliu11223/p/18186218