SELECT CT.SOURCE_TABLE AS TXN_NAME,
C.COST_ORG_CODE,
C.COST_ORG_NAME,
CB.COST_BOOK_CODE,
V.VAL_UNIT_CODE,
IO.ORGANIZATION_CODE,
ITM.ITEM_NUMBER,
CT.QUANTITY,
CT.UOM_CODE,
CT.TXN_SOURCE_DOC_TYPE,
CT.TXN_SOURCE_DOC_NUMBER,
CT.TXN_SOURCE_REF_DOC_TYPE,
CT.TXN_SOURCE_REF_DOC_NUMBER,
CTYP.BASE_TXN_TYPE_NAME,
TO_CHAR(CT.BASE_TXN_SOURCE_TYPE_ID) AS TX_SRC_TYPE_ID,
TO_CHAR(CT.BASE_TXN_ACTION_ID) AS TX_ACT_ID,
CT.TRANSACTION_DATE,
CT.COST_DATE,
CT.TRANSACTION_ID,
CT.COST_STATUS,
CT.ACCOUNTING_STATUS,
CT.INTRANSIT_FLAG,
CT.COST_METHOD_CODE,
CD.DISTRIBUTION_ID,
CDL.LINE_NUMBER,
CD.EVENT_ID,
CD.GL_DATE,
CD.DEP_TRXN_ID,
CD.REC_TRXN_ID,
CDL.COST_ID,
CDL.SOURCE_TABLE,
CEL.COST_ELEMENT_TYPE,
CDL.ACCOUNTING_LINE_TYPE,
CASE WHEN CDL.LEDGER_AMOUNT >= 0
THEN CDL.LEDGER_AMOUNT
ELSE NULL
END AS LEDGER_DR,
CASE WHEN CDL.LEDGER_AMOUNT < 0
THEN -1.0 * CDL.LEDGER_AMOUNT
ELSE NULL
END AS LEDGER_CR,
CDL.ENTERED_CURRENCY_AMOUNT,
CDL.CODE_COMBINATION_ID,
CD.ACCOUNTED_FLAG,
CD.ADDITIONAL_PROCESSING_CODE,
CEL.COST_ELEMENT_CODE,
CEL.SET_ID AS COST_ELEM_SETID,
CT.COST_TRANSACTION_TYPE,
CT.TRANSACTION_FLOW_TYPE,
CT.CONSIGNED_FLAG,
CT.LE_TIMEZONE_CODE,
CT.CST_INV_TRANSACTION_ID,
CT.CREATION_DATE,
CT.LAST_UPDATE_DATE
FROM FUSION.CST_ALL_COST_TRANSACTIONS_V CT,
FUSION.CST_COST_ORGS_V C,
FUSION.CST_COST_BOOKS_B CB,
FUSION.CST_COST_ORG_BOOKS COB,
FUSION.CST_VAL_UNITS_B V,
FUSION.INV_ORG_PARAMETERS IO,
FUSION.EGP_SYSTEM_ITEMS ITM,
FUSION.CST_ALL_TXN_TYPES_V CTYP,
FUSION.CST_COST_DISTRIBUTIONS CD,
FUSION.CST_COST_DISTRIBUTION_LINES CDL,
FUSION.CST_COST_ELEMENTS_B CEL
WHERE CD.DISTRIBUTION_ID = CDL.DISTRIBUTION_ID(+)
AND CDL.COST_ELEMENT_ID = CEL.COST_ELEMENT_ID(+)
AND CT.TRANSACTION_ID = CD.TRANSACTION_ID(+)
AND COB.COST_ORG_ID = C.COST_ORG_ID
AND COB.COST_BOOK_ID = CB.COST_BOOK_ID
AND CT.VAL_UNIT_ID = V.VAL_UNIT_ID(+)
AND CT.INVENTORY_ORG_ID = IO.ORGANIZATION_ID
AND NVL(
IO.MASTER_ORGANIZATION_ID, IO.ORGANIZATION_ID
) = ITM.ORGANIZATION_ID
AND CT.INVENTORY_ITEM_ID = ITM.INVENTORY_ITEM_ID
AND CT.COST_ORG_ID = COB.COST_ORG_ID
AND CT.COST_BOOK_ID = COB.COST_BOOK_ID
AND -- Enter the Reference Document such as Work Order# /PO#/ SO#/ TO#
CT.TXN_SOURCE_REF_DOC_NUMBER IN (:REF_DOC_NUM)
-- itm.item_number = 'XYZ'
AND CT.BASE_TXN_TYPE_ID = CTYP.BASE_TXN_TYPE_ID(+)
AND CT.BASE_TXN_SOURCE_TYPE_ID = CTYP.BASE_TXN_SOURCE_TYPE_ID(+)
AND CT.BASE_TXN_ACTION_ID = CTYP.BASE_TXN_ACTION_ID(+)
ORDER BY 2, 4
C.COST_ORG_CODE,
C.COST_ORG_NAME,
CB.COST_BOOK_CODE,
V.VAL_UNIT_CODE,
IO.ORGANIZATION_CODE,
ITM.ITEM_NUMBER,
CT.QUANTITY,
CT.UOM_CODE,
CT.TXN_SOURCE_DOC_TYPE,
CT.TXN_SOURCE_DOC_NUMBER,
CT.TXN_SOURCE_REF_DOC_TYPE,
CT.TXN_SOURCE_REF_DOC_NUMBER,
CTYP.BASE_TXN_TYPE_NAME,
TO_CHAR(CT.BASE_TXN_SOURCE_TYPE_ID) AS TX_SRC_TYPE_ID,
TO_CHAR(CT.BASE_TXN_ACTION_ID) AS TX_ACT_ID,
CT.TRANSACTION_DATE,
CT.COST_DATE,
CT.TRANSACTION_ID,
CT.COST_STATUS,
CT.ACCOUNTING_STATUS,
CT.INTRANSIT_FLAG,
CT.COST_METHOD_CODE,
CD.DISTRIBUTION_ID,
CDL.LINE_NUMBER,
CD.EVENT_ID,
CD.GL_DATE,
CD.DEP_TRXN_ID,
CD.REC_TRXN_ID,
CDL.COST_ID,
CDL.SOURCE_TABLE,
CEL.COST_ELEMENT_TYPE,
CDL.ACCOUNTING_LINE_TYPE,
CASE WHEN CDL.LEDGER_AMOUNT >= 0
THEN CDL.LEDGER_AMOUNT
ELSE NULL
END AS LEDGER_DR,
CASE WHEN CDL.LEDGER_AMOUNT < 0
THEN -1.0 * CDL.LEDGER_AMOUNT
ELSE NULL
END AS LEDGER_CR,
CDL.ENTERED_CURRENCY_AMOUNT,
CDL.CODE_COMBINATION_ID,
CD.ACCOUNTED_FLAG,
CD.ADDITIONAL_PROCESSING_CODE,
CEL.COST_ELEMENT_CODE,
CEL.SET_ID AS COST_ELEM_SETID,
CT.COST_TRANSACTION_TYPE,
CT.TRANSACTION_FLOW_TYPE,
CT.CONSIGNED_FLAG,
CT.LE_TIMEZONE_CODE,
CT.CST_INV_TRANSACTION_ID,
CT.CREATION_DATE,
CT.LAST_UPDATE_DATE
FROM FUSION.CST_ALL_COST_TRANSACTIONS_V CT,
FUSION.CST_COST_ORGS_V C,
FUSION.CST_COST_BOOKS_B CB,
FUSION.CST_COST_ORG_BOOKS COB,
FUSION.CST_VAL_UNITS_B V,
FUSION.INV_ORG_PARAMETERS IO,
FUSION.EGP_SYSTEM_ITEMS ITM,
FUSION.CST_ALL_TXN_TYPES_V CTYP,
FUSION.CST_COST_DISTRIBUTIONS CD,
FUSION.CST_COST_DISTRIBUTION_LINES CDL,
FUSION.CST_COST_ELEMENTS_B CEL
WHERE CD.DISTRIBUTION_ID = CDL.DISTRIBUTION_ID(+)
AND CDL.COST_ELEMENT_ID = CEL.COST_ELEMENT_ID(+)
AND CT.TRANSACTION_ID = CD.TRANSACTION_ID(+)
AND COB.COST_ORG_ID = C.COST_ORG_ID
AND COB.COST_BOOK_ID = CB.COST_BOOK_ID
AND CT.VAL_UNIT_ID = V.VAL_UNIT_ID(+)
AND CT.INVENTORY_ORG_ID = IO.ORGANIZATION_ID
AND NVL(
IO.MASTER_ORGANIZATION_ID, IO.ORGANIZATION_ID
) = ITM.ORGANIZATION_ID
AND CT.INVENTORY_ITEM_ID = ITM.INVENTORY_ITEM_ID
AND CT.COST_ORG_ID = COB.COST_ORG_ID
AND CT.COST_BOOK_ID = COB.COST_BOOK_ID
AND -- Enter the Reference Document such as Work Order# /PO#/ SO#/ TO#
CT.TXN_SOURCE_REF_DOC_NUMBER IN (:REF_DOC_NUM)
-- itm.item_number = 'XYZ'
AND CT.BASE_TXN_TYPE_ID = CTYP.BASE_TXN_TYPE_ID(+)
AND CT.BASE_TXN_SOURCE_TYPE_ID = CTYP.BASE_TXN_SOURCE_TYPE_ID(+)
AND CT.BASE_TXN_ACTION_ID = CTYP.BASE_TXN_ACTION_ID(+)
ORDER BY 2, 4
No comments:
Post a Comment