Escolar Documentos
Profissional Documentos
Cultura Documentos
1
Copyright (c) 2019, Oracle. All rights reserved. Oracle Confidential.
Credit Memo API: Sample Code to Apply and Unapply On Account Credit Memos using
AR_CM_API_PUB API in 11.5.10.2 and R12 (Doc ID 753244.1)
In this Document
Purpose
Requirements
Configuring
Instructions
Sample Code
Sample Output
References
APPLIES TO:
PURPOSE
Oracle has provided a new API AR_CM_API_PUB through which we can Apply and Unapply On-Account Credit Memos to to
open Invoices / Debit Memos.
This feature was developed in Bug 5257046 NEED AN API TO APPLY ON ACCOUNT CREDIT MEMO TO OPEN DEBIT ITEMS
The code was delivered via ARXPCMEB.pls, and is released for 11i.AR.N via Patch 10185853 and is also available in Release
12.1 via Patch 14065856.
If there is no patch available for your release, and you require this functionality, please contact the E-Business Patching
Community.
REQUIREMENTS
You can use SQL PLUS /SQL*Plus / Oracle SQL Developer to run the script
CONFIGURING
INSTRUCTIONS
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=7pj20vo1o_4&id=753244.1 1/6
4/16/2019 Document 753244.1
AR_CM_API_PUB.UNAPPLY_ON_ACCOUNT
================================
Call this routine to unapply on-account credit memo applied to a debit item.
Besides the standard input parameters, the API accepts the receivable application parameters as a record type. The API needs
input parameters to determine the transaction to unapply. If the required parameters are not passed in a call to this API, then
the call will fail.
For other uses of the Credit Memo API, please see Note 1272600.1: Oracle Receivables Credit Memo API: Setup and Sample
Scripts
For Invoice API information, please see Note 1242202.1: Oracle Receivables Invoice API: Setup and Sample Scripts
CAUTION
This sample code is provided for educational purposes only, and is not supported by Oracle Support. It has been tested
internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before
using.
SAMPLE CODE
The API code (AR_CM_API_PUB) was written and is supported by Oracle. However, Oracle Support cannot assist in
debugging or troubleshooting the custom code you write to call the API.
The sample code below was written and has been tested successfully in our internal instances. The code here is provided
as examples to guide you in adapting it to your particular requirements. Please test your code thoroughly before
implementing in a Production instance.
Step 1. Find out user_id and RESPONSIBILITY_ID through which you will submit the program to set the context :
SELECT USER_ID,RESPONSIBILITY_ID
FROM FND_USER_RESP_GROUPS
WHERE USER_ID = (SELECT USER_ID
FROM FND_USER
WHERE USER_NAME = '&user_name')
AND RESPONSIBILITY_ID = (SELECT RESPONSIBILITY_ID
FROM FND_RESPONSIBILITY_VL
WHERE RESPONSIBILITY_NAME = '&resp_name');
Step 2. Determine the customer_trx_id of the Invoice and Credit Memo using the following sql :
select Customer_Trx_ID
from RA_CUSTOMER_TRX_ALL
where trx_number ='&transaction_number';
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=7pj20vo1o_4&id=753244.1 2/6
4/16/2019 Document 753244.1
DECLARE
BEGIN
/* IMPORTANT: Before calling the API, you need properly initialize org/user/resp information,
otherwise the API will fail.
Please read the following instructions to set these properly.
R11.5: fnd_client_info.set_org_context(&org_id);
R12: Mo_global.init('AR');
Mo_global.set_policy_context('S', 204);
2. User/Responsibility Information
Before running the API, you need to provide your login credentials using
fnd_global.apps_initialize()
This procedure requires three parameters: UserId, ResponsibilityId, applicationId
See Step 1. above to get the proper values and use them in the following line of code
*/
-- Set User/Resp
Fnd_Global.apps_initialize(&user_Id,&responsibility_Id,222)
l_cm_app_rec.cm_customer_trx_id := &Credit_Memo_Customer_trx_id;
l_cm_app_rec.cm_trx_number := null; -- Credit Memo Number
l_cm_app_rec.inv_customer_trx_id := &Invoice_Customer_trx_id;
l_cm_app_rec.inv_trx_number := null ; -- Invoice Number
l_cm_app_rec.installment := null;
l_cm_app_rec.applied_payment_schedule_id := null;
l_cm_app_rec.amount_applied := &Amount_to_be_applied;
l_cm_app_rec.apply_date := TRUNC(SYSDATE);
l_cm_app_rec.gl_date := TRUNC(SYSDATE);
l_cm_app_rec.inv_customer_trx_line_id := null;
l_cm_app_rec.inv_line_number := null;
l_cm_app_rec.show_closed_invoices := null;
l_cm_app_rec.ussgl_transaction_code := null;
l_cm_app_rec.attribute_category := null;
l_cm_app_rec.attribute1 :=null ;
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=7pj20vo1o_4&id=753244.1 3/6
4/16/2019 Document 753244.1
l_cm_app_rec.attribute2 :=null ;
l_cm_app_rec.attribute3 := null ;
l_cm_app_rec.attribute4 := null;
l_cm_app_rec.attribute5 := null;
l_cm_app_rec.attribute6 := null;
l_cm_app_rec.attribute7 := null;
l_cm_app_rec.attribute8 := null;
l_cm_app_rec.attribute9 := null;
l_cm_app_rec.attribute10 := null;
l_cm_app_rec.attribute11 := null;
l_cm_app_rec.attribute12 := null;
l_cm_app_rec.attribute13 := null;
l_cm_app_rec.attribute14 := null;
l_cm_app_rec.attribute15 := null;
l_cm_app_rec.global_attribute_category := null;
l_cm_app_rec.global_attribute1 := null;
l_cm_app_rec.global_attribute2 := null;
l_cm_app_rec.global_attribute3 := null;
l_cm_app_rec.global_attribute4 := null;
l_cm_app_rec.global_attribute5 := null;
l_cm_app_rec.global_attribute6 := null;
l_cm_app_rec.global_attribute7 := null;
l_cm_app_rec.global_attribute8 := null;
l_cm_app_rec.global_attribute9 := null;
l_cm_app_rec.global_attribute10 := null;
l_cm_app_rec.global_attribute11 := null;
l_cm_app_rec.global_attribute12 := null;
l_cm_app_rec.global_attribute12 := null;
l_cm_app_rec.global_attribute14 := null;
l_cm_app_rec.global_attribute15 := null;
l_cm_app_rec.global_attribute16 := null;
l_cm_app_rec.global_attribute17 := null;
l_cm_app_rec.global_attribute18 := null;
l_cm_app_rec.global_attribute19 := null;
l_cm_app_rec.global_attribute20 := null;
l_cm_app_rec.comments := K_comments;
l_cm_app_rec.called_from := null;
1. Identify the receivable_application_id of the Application line which is joining Credit Memo and Invoice is:
DECLARE
BEGIN
/* IMPORTANT: Before calling the API, you need properly initialize org/user/resp information,
otherwise the API will fail.
Please read the following instructions to set these properly.
R11.5: fnd_client_info.set_org_context(&org_id);
R12: Mo_global.init('AR');
Mo_global.set_policy_context('S', 204);
2. User/Responsibility Information
Before running the API, you need to provide your login credentials using
fnd_global.apps_initialize()
This procedure requires three parameters: UserId, ResponsibilityId, applicationId
See Step 1. above to get the proper values and use them in the following line of code
*/
-- Set User/Resp
Fnd_Global.apps_initialize(&user_Id,&responsibility_Id,222)
l_cm_unapp_rec.cm_customer_trx_id := &Credit_Memo_Customer_trx_id;
l_cm_unapp_rec.cm_trx_number := null; -- Credit Memo Number
l_cm_unapp_rec.inv_customer_trx_id := &Invoice_Memo_Customer_trx_id;
l_cm_unapp_rec.inv_trx_number := null ; -- Invoice Number
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=7pj20vo1o_4&id=753244.1 5/6
4/16/2019 Document 753244.1
l_cm_unapp_rec.installment := null;
l_cm_unapp_rec.applied_payment_schedule_id := null;
l_cm_unapp_rec.receivable_application_id := &receivable_application_id;
l_cm_unapp_rec.reversal_gl_date := TRUNC(SYSDATE);
l_cm_unapp_rec.called_from := null;
SAMPLE OUTPUT
return_status: S
msg_count: 0
out_rec_application_id: 163958
acctd_amount_applied_from: 100
acctd_amount_applied_to: 100
return_status: S
REFERENCES
NOTE:1272600.1 - Oracle Receivables Credit Memo API: Setup and Sample Scripts
Didn't find what you are looking for?
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=7pj20vo1o_4&id=753244.1 6/6