Applying a Credit Memo to an Invoice – ARP_PROCESS_APPLICATION.CM_APPLICATION

Recently I was required to find a way to apply a Credit Memo to a Oracle Account Receivables Transaction (such as an Invoice, or Debit Memo). Unfortunately, there is not a whole lot of documentation available showing how to accomplish this. Many users on OTN Forums, such as this forum post, also have had this requirement, but need an example.

In this post I will make an example I created public. Disclaimer: This is provided with no warranty and is hereby released under the BSD 3 permissive license. In short, you can do what you please with the example and the code, but I take no responsibility and provide no warranty for its use.

The R12 Accounts Receivables Reference Guide explains a public API called AR_CM_APPLICATION_PUB.ACTIVITY_APPLICATION(). This API is documented and intended for use in customizations involving Credit Memo application. However, this API only allows you to apply a Credit Memo to a Receivables Activity. An invoice is not a Receivables Activity, and this is not how Credit Memos are applied when using the Application to apply them to an invoice.

Enter ARP_PROCESS_APPLICATION.CM_APPLICATION(). This package and procedure exists in the APPS schema and according to some it is used by the Accounts Receivables Transaction forms for Credit Memo Application (Receivables Manager -> Transactions -> Transactions Summary). This package and procedure is a Private API and is not actually intended for use by customizations. That being said, you may have no choice but to use it; just make sure you realize that the API could change at any time, and Oracle will not support its use.

A quick analysis of the code shows that ARP_PROCESS_APPLICATION.CM_APPLICATION() does a small amount of validation of input and inserts a row into table APPS.AR_RECEIVABLE_APPLICATIONS. To get the proper input for this procedure, query this table to see examples of Credit Memo applications already made in your Development Instance. My example, apply_credit_memo_test.sql, should help you come up with an anonymous block to apply a Credit Memo to an Invoice.

Feel free to post in comments if you have any questions!

Edit: If you are receiving no data found errors, please try initializing an apps session and mo variables as Muhammad Hasan mentions below in the comments. His example:

fnd_global.apps_initialize(2691, 20678, 222);
mo_global.set_policy_context(‘S’, 247);