Friday, November 20, 2009

How to get the Status of an Invoice

select APPS.Ap_Invoices_Pkg.GET_APPROVAL_STATUS(I.INVOICE_ID, I.INVOICE_AMOUNT,I.PAYMENT_STATUS_FLAG,I.INVOICE_TYPE_LOOKUP_CODE) FROM AP_INVOICES_ALL I where i.invoice_id='id of the invoice';

You have to set the Org-Id before you do that. This can be done with

call fnd_client_info.set_org_context('your org-id');  

How to get the invoice(s) corresponding to a PO

select i.invoice_num from ap_invoices_all i, ap_invoice_distributions_all aid, po_distributions_all pd, po_headers_all ph
where i.invoice_id = aid.invoice_id
and aid.po_distribution_id = pd.po_distribution_id
and pd.po_header_id=ph.po_header_id
and ph.segment1='Your PO-Number;