API to Apply credit memo to invoice in oracle receivables
API to Apply Credit Memo to AR Invoice in Oracle Receivables
This script will help to Apply the Credit Memo to Open AR
Invoices. We can adjust the Open Credit Memo to our Open AR Invoices in Oracle
application. This API only helps to Apply the Credit Memo to the AR invoices. I
have written this Script as per my business requirements you need to make
changes in this Script as per your needs.
DECLARE
v_api_version CONSTANT NUMBER := 1;
v_init_msg_list CONSTANT
VARCHAR2(1) := FND_API.g_false;
v_comments CONSTANT ar_receivable_applications.comments%TYPE
:= 'Test';
v_commit CONSTANT VARCHAR2(1) := FND_API.g_false;
l_acctd_amount_applied_from ar_receivable_applications_all.
acctd_amount_applied_from%TYPE;
l_acctd_amount_applied_to
ar_receivable_applications_all. acctd_amount_applied_to%TYPE;
v_cm_rec AR_CM_API_PUB.cm_app_rec_type;
l_msg_count NUMBER;
l_msg_data VARCHAR2(2555);
l_out_rec_application_id NUMBER;
l_return_status VARCHAR2(1);
BEGIN
We will run this API from Backend so for this we need to
initialize the User , Responsibility and Org from Backend.
Mo_global.set_policy_context('S',
85);
-- Set User/Resp
Fnd_Global.apps_initialize(2334,20445,
222);
v_cm_rec.cm_customer_trx_id := 455544; -- This is the Credit Memo to Which we will
Apply the Credit Memo.
v_cm_rec.inv_customer_trx_id :=456733; --This is the Invoice in
which we will apply the CM.
v_cm_rec.installment := null;
v_cm_rec.applied_payment_schedule_id
:= null;
v_cm_rec.amount_applied := 2000;
v_cm_rec.apply_date := TRUNC(SYSDATE);
v_cm_rec.gl_date := TRUNC(SYSDATE);
v_cm_rec.inv_customer_trx_line_id := null;
v_cm_rec.inv_line_number := null;
v_cm_rec.show_closed_invoices := null;
v_cm_rec.ussgl_transaction_code := null;
v_cm_rec.attribute_category := null;
v_cm_rec.attribute1 := null;
v_cm_rec.attribute2 := null;
v_cm_rec.attribute3 := null;
v_cm_rec.attribute4 := null;
v_cm_rec.attribute5 := null;
v_cm_rec.attribute6 := null;
v_cm_rec.attribute7 := null;
v_cm_rec.attribute8 := null;
v_cm_rec.attribute9 := null;
v_cm_rec.attribute10 := null;
v_cm_rec.attribute11 := null;
v_cm_rec.attribute12 := null;
v_cm_rec.attribute13 := null;
v_cm_rec.attribute14 := null;
v_cm_rec.attribute15 := null;
v_cm_rec.comments :='Testing Apply CM to
Invoice';
v_cm_rec.called_from := null;
ar_cm_api_pub.apply_on_account(p_api_version => v_api_version ,
p_init_msg_list => v_init_msg_list,
p_commit => v_commit,
p_cm_app_rec =>
v_cm_rec,
x_return_status =>
l_return_status,
x_msg_count =>
l_msg_count,
x_msg_data =>
l_msg_data,
x_out_rec_application_id => l_out_rec_application_id,
x_acctd_amount_applied_from => l_acctd_amount_applied_from,
x_acctd_amount_applied_to =>
l_acctd_amount_applied_to);
COMMIT;
dbms_output.put_line('return_status:
' || l_return_status);
dbms_output.put_line('msg_count:
' || l_msg_count);
dbms_output.put_line('acctd_amount_applied_from:
' ||
l_acctd_amount_applied_from);
dbms_output.put_line('acctd_amount_applied_to:
' ||
l_acctd_amount_applied_to);
IF l_msg_count = 1 THEN
dbms_output.put_line(l_msg_data);
ELSIF l_msg_count >
1 THEN
FOR I IN 1 ..
l_msg_count LOOP
dbms_output.put_line(I
|| '. ' || SubStr(FND_MSG_PUB.Get(p_encoded => FND_API.
G_FALSE),
1,
255));
END LOOP;
END IF;
END;
0 comments:
Post a Comment