/*Query to find Total Receive Quantity Against PO In Oracle Apps R12*/
SELECT ( (SELECT SUM (Nvl (quantity, 0))
FROM rcv_transactions rt
WHERE rt.po_header_id = p_po_header_id
AND rt.po_line_id = p_po_line_id
AND rt.wip_entity_id = p_wip_entity_id
AND rt.transaction_type = 'RECEIVE')
- Nvl ((SELECT SUM (Nvl (quantity, 0))
FROM rcv_transactions rt
WHERE rt.po_header_id = p_po_header_id
AND rt.po_line_id = p_po_line_id
AND rt.wip_entity_id = p_wip_entity_id
AND rt.transaction_type = 'RETURN TO VENDOR'),0)
+ Nvl ((SELECT SUM (Nvl (quantity, 0))
FROM rcv_transactions rt
WHERE rt.po_header_id = p_po_header_id
AND rt.po_line_id = p_po_line_id
AND rt.wip_entity_id = p_wip_entity_id
AND rt.transaction_type = 'CORRECT'
AND EXISTS (SELECT 1
FROM rcv_transactions rt2
WHERE rt2.po_header_id = p_po_header_id
AND rt2.po_line_id = p_po_line_id
AND rt.wip_entity_id = p_wip_entity_id
AND rt2.transaction_type = 'RECEIVE'
AND rt2.transaction_id = rt.parent_transaction_id)),0) )
qty
FROM dual;
No comments:
Post a Comment