SELECT imt.transaction_id
, iop.organization_code warehouse_code
, To_char(imt.creation_date, 'DD-MON-YYYY') txn_creation_date
, ittv.transaction_type_name
, flva.meaning transaction_action
, itst.transaction_source_type_name
, esi.item_number
, imt.subinventory_code
, imt.transaction_quantity
, imt.transaction_uom
, imt.primary_quantity
, imt.transaction_date
, imt.transaction_source_id
, imt.transaction_source_name
, imt.rcv_transaction_id
, imt.distribution_account_id
, imt.trx_source_line_id
, imt.trx_source_delivery_id
, imt.rma_line_id
, imt.transfer_transaction_id
, imt.transaction_set_id
, imt.source_code
, imt.source_line_id
, imt.transfer_organization_id
, imt.transfer_subinventory
, imt.shipment_number
, iut.serial_number
, rsh.receipt_num rma_receipt_number
FROM fusion.inv_material_txns imt
, fusion.inv_org_parameters iop
, fusion.egp_system_items_b esi
, fusion.inv_transaction_types_vl ittv
, fusion.fnd_lookup_values_vl flva
, fusion.inv_txn_source_types_vl itst
, fusion.inv_unit_transactions iut
, fusion.rcv_shipment_headers rsh
, fusion.rcv_shipment_lines rsl
, fusion.rcv_transactions rt
, fusion.DOO_FULFILL_LINE_DETAILS dfld
, fusion.DOO_FULFILL_LINES_ALL dfla
, fusion.DOO_HEADERS_ALL dha
WHERE imt.organization_id = iop.organization_id
AND imt.organization_id = esi.organization_id
AND imt.inventory_item_id = esi.inventory_item_id
AND imt.transaction_type_id = ittv.transaction_type_id
AND ittv.transaction_action_id = flva.lookup_code
AND flva.lookup_type = 'INV_TRANSACTION_ACTION'
AND flva.enabled_flag = 'Y'
AND ittv.transaction_source_type_id = itst.transaction_source_type_id
AND imt.transaction_id = iut.transaction_id(+)
AND ittv.transaction_type_name = 'RMA Receipt'
AND itst.transaction_source_type_name = 'RMA'
AND rsh.shipment_header_id = rsl.shipment_header_id
AND rsh.shipment_header_id = rt.shipment_header_id
AND rsl.shipment_header_id = rt.shipment_header_id
AND rsl.shipment_line_id = rt.shipment_line_id
AND rt.transaction_id = imt.rcv_transaction_id
AND imt.rcv_transaction_id = dfld.RMA_RECEIPT_TRANSACTION_ID
AND dfld.fulfill_line_id = dfla.fulfill_line_id
AND dfla.header_id = dha.header_id
and dha.submitted_flag = 'Y'
AND dha.order_number = :p_order_number
ORDER BY imt.creation_date DESC
Tuesday, March 22, 2022
Fusion: SCM: SQL to get the RMA receipts and order number details
Subscribe to:
Posts (Atom)