api to validate ap invoice : How to approve AP invoice from backend in the API.
In this post , We will discuss about how we can validate AP invoice from backend with the help of API. AP invoice validation is the most important steps in the Oracle payables . Only Validate invoices can be paid in oracle payables. here in this post , I will show share the script which is using api to validate ap invoice.
Sample script using api to validate ap invoice
PROCEDURE XX_VALIDATE_AP_INVOICE(P_ORG_ID IN NUMBER,
pov_err_message OUT VARCHAR2
)
IS
CURSOR cur_unvalidate_invoices IS
SELECT aia.invoice_id ,
aia.approval_iteration
FROM ap_invoices_all AIA
WHERE ap_invoices_pkg.get_approval_status(aia.invoice_id,
aia.invoice_amount,
aia.payment_status_flag,
aia.invoice_type_lookup_code
) NOT IN ('APPROVED','UNPAID')
AND ORG_ID=P_ORG_ID;
ln_processed_cnt NUMBER DEFAULT 0;
ln_failed_cnt NUMBER DEFAULT 0;
ln_holds_cnt NUMBER;
lv_approval_status VARCHAR2(100);
lv_funds_return_code VARCHAR2(100);
BEGIN
FOR rec_unvalidate_invoices IN cur_unvalidate_invoices
LOOP
BEGIN
lv_approval_status := NULL;
lv_funds_return_code := NULL;
ln_holds_cnt := NULL;
IF (AP_APPROVAL_PKG.BATCH_APPROVAL
(p_run_option => NULL,
p_sob_id => fnd_profile.VALUE('gl_set_of_bks_id'),
p_inv_start_date => NULL,
p_inv_end_date => NULL,
p_inv_batch_id => NULL,
p_vendor_id => NULL,
p_pay_group => NULL,
p_invoice_id => rec_unvalidate_invoices.invoice_id,
p_entered_by => NULL,
p_debug_switch => 'N',
p_conc_request_id => fnd_profile.VALUE('CONC_REQUEST_ID'),
p_commit_size => NULL,
p_org_id => P_ORG_ID,
p_report_holds_count => ln_holds_cnt,
p_transaction_num => NULL))
THEN
DBMS_OUTPUT.put_line(rec_unvalidate_invoices..invoice_num
||' Invoice Validated ');
ELSE
DBMS_OUTPUT.put_line(rec_imp_inv.invoice_num
||' Invoice Validation Failed ');
END IF;
ln_processed_cnt := ln_processed_cnt+1;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line(rec_imp_inv.invoice_num
||' Invoice Validation failed with unhandled exception.Error:'||SQLERRM);
ln_failed_cnt := ln_failed_cnt + 1;
END;
END LOOP;
pov_err_message := 'PROCESSED: '||ln_processed_cnt||' FAILED: '||ln_failed_cnt;
END;
0 comments:
Post a Comment