Академический Документы
Профессиональный Документы
Культура Документы
AND mmt.transaction_action_id IN(9, 14) /* Logical Intercompany Sales Issue and Logical Intercompany Sales Return */
AND mmt.logical_trx_type_code IN(1, 3) /* Drop Ship Receipt and Global Procurement */
AND mmt.trx_flow_header_id = mtfh.header_id
AND mtfh.flow_type = 2
AND poh.po_header_id = mmt.transaction_source_id
AND hoi.org_information3 = NVL(TO_CHAR(&orgId), hoi.org_information3)
AND hoi.organization_id = mmt.organization_id
AND hoi.org_information_context = 'Accounting Information'
AND hoi2.organization_id = mmt.transfer_organization_id
AND hoi2.org_information_context = 'Accounting Information'
UNION ALL /** Global Procurement in RAE table **/
SELECT rae.accounting_event_id transaction_id
, rae.organization_id
, 0 /* movement id */
, rae.po_distribution_id /* picking line id */
, NVL(rae.inventory_item_id, 0)
, uom.uom_code
, rae.org_id /* procuring org id */
, rae.transfer_org_id /* receiving org id */
, pol.org_id /* purchase order org id */
, 1 rae_flag /* Bug : 4391117 Indicator that the record comes from RAE */
/*, 'Y' rae_flag Indicator that the record comes from RAE */
, 0 /* Internal Order flag */
FROM rcv_accounting_events rae
, mtl_units_of_measure uom
, po_lines_all pol
, mtl_transaction_flow_headers mtfh
WHERE rae.event_type_id IN(11, 12) /* Intercompany */
AND rae.po_line_id = pol.po_line_id
AND rae.transaction_unit_of_measure = uom.unit_of_measure
AND rae.trx_flow_header_id = mtfh.header_id
AND rae.invoiced_flag = 'N'
AND rae.org_id = &orgId
ORDER BY 7, 8, 1;