Search This Blog

Saturday, November 20, 2010

AP Invoice Cancel API

DECLARE

l_message_name VARCHAR2 (1000);
l_invoice_amount NUMBER;
l_base_amount NUMBER;
l_tax_amount NUMBER;
l_temp_cancelled_amount NUMBER;
l_cancelled_by VARCHAR2 (1000);
l_cancelled_amount NUMBER;
l_cancelled_date DATE;
l_last_update_date DATE;
l_original_prepayment_amount NUMBER;
l_pay_curr_invoice_amount NUMBER;
l_token VARCHAR2 (100);
l_boolean BOOLEAN;
l_user_id NUMBER := 2083;
l_resp_id NUMBER := 20639;
l_appl_id NUMBER := 200;

CURSOR C_Inv_Det is

SELECT distinct aia.*
FROM ap_invoices_all aia, ap_invoice_lines_all aila
WHERE aia.invoice_id = aila.invoice_id
AND aia.org_id = aila.org_id
AND aia.org_id = 308
AND aia.invoice_num = '300040823'
AND aia.payment_status_flag = 'N'
AND NVL(aila.cancelled_flag, 'N') <> 'Y';


BEGIN


fnd_global.apps_initialize(l_user_id, l_resp_id, l_appl_id);


FOR l_inv_rec IN C_Inv_Det LOOP

mo_global.init ('SQLAP');
mo_global.set_policy_context ('S', l_inv_rec.org_id);


DBMS_OUTPUT.put_line ('Calling API ap_cancel_pkg.ap_cancel_single_invoice to Cancel Invoice: ' l_inv_rec.invoice_num);
DBMS_OUTPUT.put_line ('**************************************************************');





l_boolean := ap_cancel_pkg.ap_cancel_single_invoice
(p_invoice_id => l_inv_rec.invoice_id,
p_last_updated_by => l_inv_rec.last_updated_by,
p_last_update_login => l_inv_rec.last_update_login,
p_accounting_date => l_inv_rec.gl_date,
p_message_name => l_message_name,
p_invoice_amount => l_invoice_amount,
p_base_amount => l_base_amount,
p_temp_cancelled_amount => l_temp_cancelled_amount,
p_cancelled_by => l_cancelled_by,
p_cancelled_amount => l_cancelled_amount,
p_cancelled_date => l_cancelled_date,
p_last_update_date => l_last_update_date,
p_original_prepayment_amount => l_original_prepayment_amount,
p_pay_curr_invoice_amount => l_pay_curr_invoice_amount,
P_Token => l_token,
p_calling_sequence => NULL);


DBMS_OUTPUT.put_line ('l_message_name => ' l_message_name);
DBMS_OUTPUT.put_line ('l_invoice_amount => ' l_invoice_amount);
DBMS_OUTPUT.put_line ('l_base_amount => ' l_base_amount);
DBMS_OUTPUT.put_line ('l_tax_amount => ' l_tax_amount);
DBMS_OUTPUT.put_line ('l_temp_cancelled_amount => ' l_temp_cancelled_amount);
DBMS_OUTPUT.put_line ('l_cancelled_by => ' l_cancelled_by);
DBMS_OUTPUT.put_line ('l_cancelled_amount => ' l_cancelled_amount);
DBMS_OUTPUT.put_line ('l_cancelled_date => ' l_cancelled_date);
DBMS_OUTPUT.put_line ('P_last_update_date => ' l_last_update_date);
DBMS_OUTPUT.put_line ('P_original_prepayment_amount => ' l_original_prepayment_amount);
DBMS_OUTPUT.put_line ('l_pay_curr_invoice_amount => ' l_pay_curr_invoice_amount);




IF l_boolean
THEN
DBMS_OUTPUT.put_line ('Successfully Cancelled the Invoice => ' l_inv_rec.invoice_num);
COMMIT;
ELSE
DBMS_OUTPUT.put_line ('Failed to Cancel the Invoice => ' l_inv_rec.invoice_num);
ROLLBACK;
END IF;

END LOOP;
END;

4 comments:

  1. Hi there to every body, it's my first visit of this website; this web site consists of remarkable and actually good material in support of visitors.

    Look into my blog :: Curved-shower-rod-col7o912fo.tumblr.com
    my site :: digial bathroom scale

    ReplyDelete
  2. Without anу ωatering thе гoots of a tгee it is
    futіle to hoρe іt to maturе and give us lusсious fгuitѕ, ѵіbrant bοuquets еtc.
    Masonгу hеaterѕ сonsіst of a small firерlaсe box built to ratio wіth the smoκe chamber
    oνer. Stir in onions, celery, chopped уellow bell pepper and pгеpare dinneг until such tіme as tеnԁer.


    my page: http://olinraft15.tumblr.com/

    ReplyDelete
  3. Thanκ you fοr the auspiсious writeup.
    It if truth be told ωas οnce a entertainment
    account it. Lοok complicatеd to more addeԁ agгeeable from you!

    By the wау, how could we be in contact?

    Mу weblog ... Chemietoilette

    ReplyDelete
  4. I've been surfing online more than 3 hours today, yet I never found any interesting article like yours. It'ѕ рrettу ωorth enough fоr me.
    In my opinіon, if all webmаsters and bloggers
    made goοd сontent as you did, the net will
    bе much more useful than ever beforе.


    my web blog ... www.123backlinks.de

    ReplyDelete