Sunteți pe pagina 1din 6

---- POR is Enabled at Suuplier Site and PO Level

SELECT DISTINCT apss.pay_on_code por_supp_site, pha.pay_on_code por_po

FROM apps.ap_suppliers aps,

apps.ap_supplier_sites_all apss,

apps.po_headers_all pha

WHERE aps.vendor_id = apss.vendor_id

AND pha.vendor_id = apss.vendor_id

AND pha.vendor_site_id = apss.vendor_site_id

AND pha.segment1 = '1801400541' --- PO Number/LPO Number

--- Item is enbled for POR

SELECT DISTINCT segment1

FROM apps.mtl_system_items_b msi

WHERE 1 = 1

AND EXISTS (

SELECT 1

FROM apps.fnd_lookup_values_vl

WHERE lookup_type = 'XXET_POR_ITEMS_LKP'

AND lookup_code = SUBSTR (msi.segment1, 1, 2)

AND enabled_flag = 'Y')

AND inventory_item_id IN (

SELECT item_id

FROM apps.po_lines_all

WHERE po_header_id IN (

SELECT po_header_id
FROM apps.po_headers_all

WHERE segment1 = '1801400541' --- PO Number/LPO Number

));

-- GRN Creation date/transaction_date should be less than 3 days of current date

SELECT

DISTINCT rsl.to_subinventory, rts.invoice_status_code, phs.org_id,

phs.segment1 po_number, rts.transaction_date

FROM apps.po_vendor_sites_all pvss,

apps.po_vendor_sites_all pvss2,

apps.po_vendors pvds,

apps.po_headers_all phs,

apps.po_lines_all pls,

apps.po_line_locations_all plls,

apps.rcv_shipment_headers rsh,

apps.rcv_shipment_lines rsl,

apps.inl_ship_lines_all isl,

apps.rcv_transactions rts,

apps.mtl_system_items_b msi

WHERE rts.shipment_header_id = rsh.shipment_header_id

AND rts.po_header_id = phs.po_header_id

AND rts.po_line_location_id = plls.line_location_id

AND rts.po_line_id = pls.po_line_id

AND rts.shipment_header_id = rsl.shipment_header_id

AND rts.shipment_line_id = rsl.shipment_line_id

AND rts.lcm_shipment_line_id = isl.ship_line_id(+)

AND rts.lcm_adjustment_num = isl.adjustment_num(+)

AND phs.vendor_id = pvds.vendor_id


AND phs.vendor_site_id = pvss.vendor_site_id

AND rsh.receipt_source_code = 'VENDOR'

AND rts.source_document_code = 'PO'

AND phs.segment1 = '1801400541' --- PO Number/LPO Number

--AND NVL (rts.invoice_status_code, 'NA') IN ('PENDING', 'REJECTED')

AND ( (rts.transaction_type = 'RECEIVE')

OR ( 'N' = 'Y'

AND rts.transaction_type = 'CORRECT'

AND rts.timecard_id IS NOT NULL

AND EXISTS (

SELECT 1

FROM apps.rcv_transactions prt

WHERE prt.transaction_type = 'RECEIVE'

AND prt.source_document_code = 'PO'

AND prt.transaction_id =

rts.parent_transaction_id

AND prt.invoice_status_code = 'INVOICED'

AND prt.last_update_date <= rts.creation_date)

AND pvss.pay_on_code IN ('RECEIPT', 'RECEIPT_AND_USE')

AND phs.pay_on_code IN ('RECEIPT', 'RECEIPT_AND_USE')

AND NVL (plls.consigned_flag, 'N') <> 'Y'

AND pvss2.vendor_site_id =

NVL (pvss.default_pay_site_id, pvss.vendor_site_id)

AND NVL (rsh.asn_type, ' ') <> 'ASBN'

AND rts.po_release_id IS NULL

AND rsl.item_id = msi.inventory_item_id

AND rts.organization_id = msi.organization_id


AND rts.transaction_date >= '09-SEP-2018';

--- Failed in Invoice Interface

SELECT *

FROM (SELECT aif.invoice_id, ailf.invoice_line_id, aif.invoice_num,

air.reject_lookup_code, aif.invoice_amount,

ailf.amount line_amount, ailf.line_number, aif.SOURCE,

ailf.accounting_date, aif.gl_date, aif.invoice_date,

aif.creation_date,

(SELECT vendor_name

FROM apps.ap_suppliers

WHERE vendor_id = aif.vendor_id) vendor_name,

(SELECT end_date_active

FROM apps.ap_suppliers

WHERE vendor_id = aif.vendor_id) vendor_end_date_active,

(SELECT last_update_date

FROM apps.ap_suppliers

WHERE vendor_id = aif.vendor_id) vendor_last_update_date,

(SELECT segment1

FROM apps.po_headers_all

WHERE po_header_id = ailf.po_header_id) po_number,

(SELECT NAME

FROM apps.hr_operating_units

WHERE organization_id = aif.org_id) operating_unit

FROM ap_invoices_interface aif,

ap_interface_rejections air,

ap_invoice_lines_interface ailf

WHERE aif.invoice_id = ailf.invoice_id


AND ailf.invoice_line_id = air.parent_id

-- AND aif.group_id =v_group_id

AND air.parent_table = 'AP_INVOICE_LINES_INTERFACE'

AND aif.status = 'REJECTED'

AND aif.SOURCE = 'ERS'

UNION

SELECT aif.invoice_id, ailf.invoice_line_id, aif.invoice_num,

air.reject_lookup_code, aif.invoice_amount,

ailf.amount line_amount, ailf.line_number, aif.SOURCE,

ailf.accounting_date, aif.gl_date, aif.invoice_date,

aif.creation_date,

(SELECT vendor_name

FROM apps.ap_suppliers

WHERE vendor_id = aif.vendor_id) vendor_name,

(SELECT end_date_active

FROM apps.ap_suppliers

WHERE vendor_id = aif.vendor_id) vendor_end_date_active,

(SELECT last_update_date

FROM apps.ap_suppliers

WHERE vendor_id = aif.vendor_id) vendor_last_update_date,

(SELECT segment1

FROM apps.po_headers_all

WHERE po_header_id = ailf.po_header_id) po_number,

(SELECT NAME

FROM apps.hr_operating_units

WHERE organization_id = aif.org_id) operating_unit

FROM ap_invoices_interface aif,

ap_interface_rejections air,

ap_invoice_lines_interface ailf
WHERE aif.invoice_id = ailf.invoice_id

AND aif.invoice_id = air.parent_id

-- AND aif.group_id =v_group_id

AND air.parent_table = 'AP_INVOICES_INTERFACE'

AND aif.status = 'REJECTED'

AND aif.SOURCE = 'ERS')

WHERE po_number ='1801400541' --- PO Number/LPO Number

S-ar putea să vă placă și