Sie sind auf Seite 1von 2

SELECT AR_LOOKUPS.MEANING, OE_ORDER_HEADERS_ALL.ORDER_NUMBER, OE_ORDER_LINES_ALL.ORDERED_QUANTITY, OE_TRANSACTION_TYPES_HEADER_TL.NAME, RA_CUSTOMER_TRX_ALL.TRX_NUMBER, Sum(DECODE(OE_ORDER_LINES_ALL.LINE_CATEGORY_CODE,'RETURN',-1,1)*NVL(OE_ORDER_L INES_ALL.ORDERED_QUANTITY,0)*(NVL(OE_ORDER_LINES_ALL.UNIT_SELLING_PRICE,0) /( de code(OE_ORDER_HEADERS_ALL.CONVERSION_TYPE_CODE,'EMU FIXED',nvl(FND_CURRENCIES.DE RIVE_FACTOR,1),nvl(OE_ORDER_HEADERS_ALL.CONVERSION_RATE,1)) ))), MTL_SYSTEM_ITEMS_B_V.SEGMENT1, sum(DECODE(OE_ORDER_LINES_ALL.

LINE_CATEGORY_CODE,'RETURN',-1,1) *(NVL(OE_ORDER _LINES_ALL.ORDERED_QUANTITY,0) - NVL(OE_ORDER_LINES_ALL.SHIPPED_QUANTITY,0)) * (nvl(OE_ORDER_LINES_ALL.UNIT_SELLING_PRICE,0) /( decode(OE_ORDER_HEADERS_ALL.CON VERSION_TYPE_CODE,'EMU FIXED',nvl(FND_CURRENCIES.DERIVE_FACTOR,1),nvl(OE_ORDER_H EADERS_ALL.CONVERSION_RATE,1)) ))), sum(nvl(OE_ORDER_LINES_ALL.INVOICED_QUANTITY,0)) FROM RA_CUSTOMER_TRX_LINES_ALL, RA_CUSTOMER_TRX_ALL, MTL_SYSTEM_ITEMS_B_V, RA_CUSTOMERS, OE_ORDER_LINES_ALL, OE_ORDER_HEADERS_ALL, OE_TRANSACTION_TYPES_ALL OE_TRANSACTION_TYPES_HEADER, OE_TRANSACTION_TYPES_TL OE_TRANSACTION_TYPES_HEADER_TL, FND_CURRENCIES, AR_LOOKUPS, BO_ACCOUNTS_PARAMETERS_V WHERE ( OE_ORDER_HEADERS_ALL.HEADER_ID=OE_ORDER_LINES_ALL.HEADER_ID ) AND ( OE_ORDER_LINES_ALL.INVENTORY_ITEM_ID=MTL_SYSTEM_ITEMS_B_V.INVENTORY_ITE M_ID ) AND ( RA_CUSTOMER_TRX_ALL.CUSTOMER_TRX_ID(+)=RA_CUSTOMER_TRX_LINES_ALL.CUSTOM ER_TRX_ID ) AND ( RA_CUSTOMER_TRX_LINES_ALL.INTERFACE_LINE_ATTRIBUTE6(+)=OE_ORDER_LINES_A LL.LINE_ID ) AND ( OE_ORDER_HEADERS_ALL.SOLD_TO_ORG_ID=RA_CUSTOMERS.CUSTOMER_ID ) AND ( OE_TRANSACTION_TYPES_HEADER.TRANSACTION_TYPE_CODE='ORDER' ) AND ( OE_TRANSACTION_TYPES_HEADER.TRANSACTION_TYPE_ID=OE_TRANSACTION_TYPES_HE ADER_TL.TRANSACTION_TYPE_ID ) AND ( OE_ORDER_HEADERS_ALL.ORDER_TYPE_ID=OE_TRANSACTION_TYPES_HEADER.TRANSACT ION_TYPE_ID ) AND ( OE_TRANSACTION_TYPES_HEADER_TL.LANGUAGE='US' ) AND ( FND_CURRENCIES.CURRENCY_CODE(+)=OE_ORDER_HEADERS_ALL.TRANSACTIONAL_CURR _CODE ) AND ( FND_CURRENCIES.DERIVE_TYPE(+)='EMU' ) AND ( RA_CUSTOMERS.CUSTOMER_CLASS_CODE=AR_LOOKUPS.LOOKUP_CODE(+) ) AND ( AR_LOOKUPS.LOOKUP_TYPE = 'CUSTOMER CLASS' ) AND ( BO_ACCOUNTS_PARAMETERS_V.ORG_ID = OE_ORDER_HEADERS_ALL.ORG_ID ) AND ( BO_ACCOUNTS_PARAMETERS_V.LEGAL_ORG IN (SELECT APPBO.SECURITY_POLICY_V. RESTRICTION_VALUE FROM APPBO.SECURITY_POLICY_V WHERE APPBO.SECURITY_POLICY_V.APPLICATION_SHORT_NAME='MTLORG' AND APPBO.SECURITY_POLICY_V.FRONT_END_NAME='Business Objects' AND UPPER(APPBO.SECURITY_POLICY_V.LOGIN_NAME) =UPPER(@VARIABLE('BOUSER')) AND APPBO.SECURITY_POLICY_V.RESTRICTION_FIELD='LEGAL_ORGANIZATION' AND APPBO.SECURITY_POLICY_V.TABLE_NAME='GLO_ORGANIZATION_HIERARCHY' AND APPBO.SECURITY_POLICY_V.TABLE_SCHEMA='DWADMIN'

) AND BO_ACCOUNTS_PARAMETERS_V.LEGAL_ORG in @Prompt('Legal Org:','A','Organization \Legal Org',multi,free) ) AND (MTL_SYSTEM_ITEMS_B_V.ORGANIZATION_ID = BO_ACCOUNTS_PARAMETERS_V.ORGANIZA TION_ID AND MTL_SYSTEM_ITEMS_B_V.ORG_ID = decode(MTL_SYSTEM_ITEMS_B_V.LEGAL_ORG, '307',413,MTL_SYSTEM_ITEMS_B_V.ORG_ID)) AND (OE_ORDER_HEADERS_ALL.ORG_ID = BO_ACCOUNTS_PARAMETERS_V.ORG_ID) GROUP BY AR_LOOKUPS.MEANING, OE_ORDER_HEADERS_ALL.ORDER_NUMBER, OE_ORDER_LINES_ALL.ORDERED_QUANTITY, OE_TRANSACTION_TYPES_HEADER_TL.NAME, RA_CUSTOMER_TRX_ALL.TRX_NUMBER, MTL_SYSTEM_ITEMS_B_V.SEGMENT1