SELECT a.PROCESS_INSTANCE , a.OPRID , a.RUN_CNTL_ID , a.REQUEST_ID , a.BUSINESS_UNIT_GL , a.BUSINESS_UNIT_RECV , a.RECEIVER_ID , a.RECV_LN_NBR , a.RECV_SHIP_SEQ_NBR , a.INV_ITEM_ID , a.BUSINESS_UNIT_IN , a.FISCAL_YEAR , a.ACCOUNTING_PERIOD , a.ACCOUNT , a.CURRENCY_CD ,%Abs(SUM(b.MONETARY_AMOUNT)) ,%Abs(SUM(a.MONETARY_AMOUNT)) , (%Abs(SUM(b.MONETARY_AMOUNT)) - %Abs(SUM(a.MONETARY_AMOUNT))) FROM PS_CM_APRECN_TBL a , PS_CM_APRECN_TBL2 b WHERE a.process_instance = b.process_instance AND a.oprid = b.oprid AND a.RUN_CNTL_ID = b.RUN_CNTL_ID AND a.REQUEST_ID = b.REQUEST_ID AND a.BUSINESS_UNIT_RECV = b.BUSINESS_UNIT_RECV AND a.RECEIVER_ID = b.RECEIVER_ID AND a.RECV_LN_NBR = b.RECV_LN_NBR AND a.RECV_SHIP_SEQ_NBR = b.RECV_SHIP_SEQ_NBR AND A.CM_AP_ERROR_OK = 'N' GROUP BY a.PROCESS_INSTANCE , a.OPRID , a.RUN_CNTL_ID , a.REQUEST_ID , a.BUSINESS_UNIT_GL , a.BUSINESS_UNIT_RECV , a.RECEIVER_ID , a.RECV_LN_NBR , a.RECV_SHIP_SEQ_NBR , a.INV_ITEM_ID , a.BUSINESS_UNIT_IN , a.FISCAL_YEAR , a.ACCOUNTING_PERIOD , a.ACCOUNT , a.CURRENCY_CD UNION ALL SELECT a.PROCESS_INSTANCE , a.OPRID , a.RUN_CNTL_ID , a.REQUEST_ID , a.BUSINESS_UNIT_GL , a.BUSINESS_UNIT_RECV , a.RECEIVER_ID , a.RECV_LN_NBR , a.RECV_SHIP_SEQ_NBR , a.INV_ITEM_ID , a.BUSINESS_UNIT_IN , a.FISCAL_YEAR , a.ACCOUNTING_PERIOD , a.ACCOUNT , a.CURRENCY_CD , 0 , %Abs(SUM(a.MONETARY_AMOUNT)) , 0 - %Abs(SUM(a.MONETARY_AMOUNT)) FROM PS_CM_APRECN_TBL a WHERE A.CM_AP_ERROR_OK = 'N' AND NOT EXISTS ( SELECT 'x' FROM PS_CM_APRECN_TBL2 b WHERE a.process_instance = b.process_instance AND a.oprid = b.oprid AND a.RUN_CNTL_ID = b.RUN_CNTL_ID AND a.REQUEST_ID = b.REQUEST_ID AND a.BUSINESS_UNIT_RECV = b.BUSINESS_UNIT_RECV AND a.RECEIVER_ID = b.RECEIVER_ID AND a.RECV_LN_NBR = b.RECV_LN_NBR AND a.RECV_SHIP_SEQ_NBR = b.RECV_SHIP_SEQ_NBR) GROUP BY a.PROCESS_INSTANCE , a.OPRID , a.RUN_CNTL_ID , a.REQUEST_ID , a.BUSINESS_UNIT_GL , a.BUSINESS_UNIT_RECV , a.RECEIVER_ID , a.RECV_LN_NBR , a.RECV_SHIP_SEQ_NBR , a.INV_ITEM_ID , a.BUSINESS_UNIT_IN , a.FISCAL_YEAR , a.ACCOUNTING_PERIOD , a.ACCOUNT , a.CURRENCY_CD UNION ALL SELECT a.PROCESS_INSTANCE , a.OPRID , a.RUN_CNTL_ID , a.REQUEST_ID , a.BUSINESS_UNIT_GL , a.BUSINESS_UNIT_RECV , a.RECEIVER_ID , a.RECV_LN_NBR , a.RECV_SHIP_SEQ_NBR , a.INV_ITEM_ID , ' ' , a.FISCAL_YEAR , a.ACCOUNTING_PERIOD , a.ACCOUNT , a.CURRENCY_CD , %Abs(SUM( a.MONETARY_AMOUNT)) , 0 , %Abs(SUM( a.MONETARY_AMOUNT)) FROM PS_CM_APRECN_TBL2 a WHERE A.CM_AP_ERROR_OK = 'N' AND NOT EXISTS ( SELECT 'x' FROM PS_CM_APRECN_TBL b WHERE a.process_instance = b.process_instance AND a.oprid = b.oprid AND a.RUN_CNTL_ID = b.RUN_CNTL_ID AND a.REQUEST_ID = b.REQUEST_ID AND a.BUSINESS_UNIT_RECV = b.BUSINESS_UNIT_RECV AND a.RECEIVER_ID = b.RECEIVER_ID AND a.RECV_LN_NBR = b.RECV_LN_NBR AND a.RECV_SHIP_SEQ_NBR = b.RECV_SHIP_SEQ_NBR) GROUP BY a.PROCESS_INSTANCE , a.OPRID , a.RUN_CNTL_ID , a.REQUEST_ID , a.BUSINESS_UNIT_GL , a.BUSINESS_UNIT_RECV , a.RECEIVER_ID , a.RECV_LN_NBR , a.RECV_SHIP_SEQ_NBR , a.INV_ITEM_ID, a.FISCAL_YEAR , a.ACCOUNTING_PERIOD , a.ACCOUNT , a.CURRENCY_CD
|