Last active
December 14, 2015 14:49
-
-
Save zschallz/5103605 to your computer and use it in GitHub Desktop.
Anonymous block to apply a credit memo to an EBS transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Copyright (c) 2012, Zachary Zimmerman | |
--All rights reserved. | |
--Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
--Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |
--Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
declare | |
-- | |
-- Input | |
-- | |
v_cm_payment_schedule number := 101502; -- Payment Schedule ID of Credit Memo from APPS.AR_PAYMENT_SCHEDULES_ALL | |
v_inv_payment_schedule number := 101500; -- Payment Schedule ID of Invoice from APPS.AR_PAYMENT_SCHEDULES_ALL | |
v_amount_applied number := 1000; -- Amount of credit memo to apply to invoice | |
v_apply_date date := SYSDATE; | |
v_gl_date date := SYSDATE-1; | |
v_ussgl_transaction_code varchar2(1024); -- null, but check AR_RECEIVABLE_APPLICATIONS_ALL | |
v_null_flex varchar2(1024); -- null, unless you have flexfield segments to define | |
v_customer_trx_line_id number; -- null, but check AR_RECEIVABLE_APPLICATIONS_ALL | |
v_comments varchar2(240) := 'Applied automatically'; | |
v_module_name varchar2(128) := 'XXCREDIT_APPLICATION.APPLY_CREDIT_MEMO'; -- If null, validation won't occur | |
v_module_version varchar2(128) := '1'; -- If null, validation won't occur | |
-- | |
-- Output | |
-- | |
v_out_rec_application_id number; | |
v_acctd_amount_applied_from number; | |
v_acctd_amount_applied_to number; | |
begin | |
arp_process_application.cm_application( | |
p_cm_ps_id => v_cm_payment_schedule, | |
p_invoice_ps_id => v_inv_payment_schedule, | |
p_amount_applied => v_amount_applied, | |
p_apply_date => v_apply_date, | |
p_gl_date => v_gl_date, | |
p_ussgl_transaction_code => v_ussgl_transaction_code, | |
p_attribute_category => v_null_flex, | |
p_attribute1 => v_null_flex, | |
p_attribute2 => v_null_flex, | |
p_attribute3 => v_null_flex, | |
p_attribute4 => v_null_flex, | |
p_attribute5 => v_null_flex, | |
p_attribute6 => v_null_flex, | |
p_attribute7 => v_null_flex, | |
p_attribute8 => v_null_flex, | |
p_attribute9 => v_null_flex, | |
p_attribute10 => v_null_flex, | |
p_attribute11 => v_null_flex, | |
p_attribute12 => v_null_flex, | |
p_attribute13 => v_null_flex, | |
p_attribute14 => v_null_flex, | |
p_attribute15 => v_null_flex, | |
p_global_attribute_category => v_null_flex, | |
p_global_attribute1 => v_null_flex, | |
p_global_attribute2 => v_null_flex, | |
p_global_attribute3 => v_null_flex, | |
p_global_attribute4 => v_null_flex, | |
p_global_attribute5 => v_null_flex, | |
p_global_attribute6 => v_null_flex, | |
p_global_attribute7 => v_null_flex, | |
p_global_attribute8 => v_null_flex, | |
p_global_attribute9 => v_null_flex, | |
p_global_attribute10 => v_null_flex, | |
p_global_attribute11 => v_null_flex, | |
p_global_attribute12 => v_null_flex, | |
p_global_attribute13 => v_null_flex, | |
p_global_attribute14 => v_null_flex, | |
p_global_attribute15 => v_null_flex, | |
p_global_attribute16 => v_null_flex, | |
p_global_attribute17 => v_null_flex, | |
p_global_attribute18 => v_null_flex, | |
p_global_attribute19 => v_null_flex, | |
p_global_attribute20 => v_null_flex, | |
p_customer_trx_line_id => v_customer_trx_line_id, | |
p_comments => v_comments, | |
p_module_name => v_module_name, | |
p_module_version => v_module_version, | |
p_out_rec_application_id => v_out_rec_application_id, | |
p_acctd_amount_applied_from => v_acctd_amount_applied_from, | |
p_acctd_amount_applied_to => v_acctd_amount_applied_to | |
); | |
-- Print OUT parameters | |
dbms_output.put_line(' v_out_rec_application_id ' || v_out_rec_application_id); | |
dbms_output.put_line(' v_acctd_amount_applied_from ' || v_acctd_amount_applied_from); | |
dbms_output.put_line(' v_acctd_amount_applied_to ' || v_acctd_amount_applied_to); | |
if v_out_rec_application_id is not null then | |
dbms_output.put_line('Committing.'); | |
commit; | |
else | |
dbms_output.put_line('Rolling back.'); | |
rollback; | |
end if; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment