Tuesday 26 November 2013

R12 PO Amendment Query

SELECT APS.segment1 VENDOR,
APS.vendor_name NAME,
POH.segment1 PO,
POH.revision_num REV,
POH.attribute11 HEADER_EFFECTIVE_DATE,
POH.note_to_vendor NOTE_TO_VENDOR,
POH.note_to_receiver NOTE_TO_RECEIVER,
POH.org_id,
POH.creation_date PO_CREATION_DATE,
TRUNC(POH.approved_date) APPROVED_DATE,
POL.item_description DESCRIPTION,
POL.line_num,
POL.unit_price,
POL.attribute12 LINES_AMMENDMENT,
POL.attribute11 LINES_EFFECTIVE_DATE,
POL.creation_date LINE_CREATION_DATE,
MSIB.segment1 ITEMCODE,
MSIB.organization_id,
NVL(PL.quantity,0),
POH.type_lookup_code,
PAH.note
FROM APPS.PO_HEADERS_ARCHIVE_ALL POH,
    APPS.PO_LINES_ARCHIVE_ALL POL,
    APPS.MTL_SYSTEM_ITEMS_B MSIB,
    APPS.AP_SUPPLIERS APS,
    APPS.PO_LINES_ALL PL,
    APPS.PO_ACTION_HISTORY PAH
WHERE POH.po_header_id = POL.po_header_id
and poh.revision_num = pol.revision_num
and POL.item_id = MSIB.inventory_item_id
and POH.vendor_id = APS.vendor_id
and POH.po_header_id = PL.po_header_id
and pol.line_num = pl.line_num
and POH.po_header_id = PAH.object_id(+)
and POH.revision_num = PAH.object_revision_num(+)
and POh.type_lookup_code = PAH.object_sub_type_code(+)
and pah.action_code(+) = 'SUBMIT'
and poh.org_id=:p_org_id
and msib.organization_id=:p_orgn_id
and POH.approved_date between :p_from_date and :p_to_date
and POH.segment1 between :p_from_po and :p_to_po
ORDER BY
poh.segment1,
POH.revision_num,
pol.line_num

No comments:

Post a Comment