CREATE OR REPLACE FUNCTION APPS.XX_AR_CA_CMPTL_SUB_F(p_credit_memo VARCHAR2,p_invoice_num VARCHAR2,p_amt NUMBER) RETURN NUMBER
IS
ln_request_id NUMBER;
lc_inv NUMBER;
lb_complete BOOLEAN;
lc_phase VARCHAR2 (100);
lc_status VARCHAR2 (100);
lc_dev_phase VARCHAR2 (100);
lc_dev_status VARCHAR2 (100);
lc_message VARCHAR2 (100);
v_cm_payment_schedule number ; -- Payment Schedule ID of Credit Memo from APPS.AR_PAYMENT_SCHEDULES_ALL
v_inv_payment_schedule number ; -- Payment Schedule ID of Invoice from APPS.AR_PAYMENT_SCHEDULES_ALL
v_amount_applied number ; -- 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
lc_msg_txt varchar2(1000);
--
-- Output
--
v_out_rec_application_id number;
v_acctd_amount_applied_from number;
v_acctd_amount_applied_to number;
ln_org_id NUMBER := fnd_profile.value('ORG_ID');
lc_trx number;
BEGIN
BEGIN
select payment_schedule_id
into v_cm_payment_schedule
from ar_payment_schedules_all ps,
ra_customer_trx_all ract
where ps.customer_trx_id = ract.customer_trx_id
AND ract.trx_number = p_credit_memo
AND ract.org_id = ln_org_id;
select payment_schedule_id
into v_inv_payment_schedule
from ar_payment_schedules_all ps,
ra_customer_trx_all ract
where ps.customer_trx_id = ract.customer_trx_id
AND ract.trx_number = p_invoice_num
AND ract.org_id = ln_org_id;
EXCEPTION
WHEN OTHERS THEN
v_cm_payment_schedule := 0;
v_inv_payment_schedule := 0;
END;
v_amount_applied := p_amt;
fnd_client_info.set_org_context(8908);
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, -- NULL
p_attribute_category => v_null_flex, -- NULL
p_attribute1 => v_null_flex, -- NULL
p_attribute2 => v_null_flex, -- NULL
p_attribute3 => v_null_flex, -- NULL
p_attribute4 => v_null_flex, -- NULL
p_attribute5 => v_null_flex, -- NULL
p_attribute6 => v_null_flex, -- NULL
p_attribute7 => v_null_flex, -- NULL
p_attribute8 => v_null_flex, -- NULL
p_attribute9 => v_null_flex, -- NULL
p_attribute10 => v_null_flex, -- NULL
p_attribute11 => v_null_flex, -- NULL
p_attribute12 => v_null_flex, -- NULL
p_attribute13 => v_null_flex, -- NULL
p_attribute14 => v_null_flex, -- NULL
p_attribute15 => v_null_flex, -- NULL
p_global_attribute_category => v_null_flex, -- NULL
p_global_attribute1 => v_null_flex, -- NULL
p_global_attribute2 => v_null_flex, -- NULL
p_global_attribute3 => v_null_flex, -- NULL
p_global_attribute4 => v_null_flex, -- NULL
p_global_attribute5 => v_null_flex, -- NULL
p_global_attribute6 => v_null_flex, -- NULL
p_global_attribute7 => v_null_flex, -- NULL
p_global_attribute8 => v_null_flex, -- NULL
p_global_attribute9 => v_null_flex, -- NULL
p_global_attribute10 => v_null_flex, -- NULL
p_global_attribute11 => v_null_flex, -- NULL
p_global_attribute12 => v_null_flex, -- NULL
p_global_attribute13 => v_null_flex, -- NULL
p_global_attribute14 => v_null_flex, -- NULL
p_global_attribute15 => v_null_flex, -- NULL
p_global_attribute16 => v_null_flex, -- NULL
p_global_attribute17 => v_null_flex, -- NULL
p_global_attribute18 => v_null_flex, -- NULL
p_global_attribute19 => v_null_flex, -- NULL
p_global_attribute20 => v_null_flex, -- NULL
p_customer_trx_line_id => v_customer_trx_line_id, -- NULL
p_comments => v_comments, -- NULL
p_module_name => v_module_name, -- NULL
p_module_version => v_module_version, -- NULL
p_out_rec_application_id => v_out_rec_application_id, --NULL
p_acctd_amount_applied_from => v_acctd_amount_applied_from, -- NULL
p_acctd_amount_applied_to => v_acctd_amount_applied_to -- NULL
);
COMMIT;
RETURN ln_request_id;
END;
/
IS
ln_request_id NUMBER;
lc_inv NUMBER;
lb_complete BOOLEAN;
lc_phase VARCHAR2 (100);
lc_status VARCHAR2 (100);
lc_dev_phase VARCHAR2 (100);
lc_dev_status VARCHAR2 (100);
lc_message VARCHAR2 (100);
v_cm_payment_schedule number ; -- Payment Schedule ID of Credit Memo from APPS.AR_PAYMENT_SCHEDULES_ALL
v_inv_payment_schedule number ; -- Payment Schedule ID of Invoice from APPS.AR_PAYMENT_SCHEDULES_ALL
v_amount_applied number ; -- 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
lc_msg_txt varchar2(1000);
--
-- Output
--
v_out_rec_application_id number;
v_acctd_amount_applied_from number;
v_acctd_amount_applied_to number;
ln_org_id NUMBER := fnd_profile.value('ORG_ID');
lc_trx number;
BEGIN
BEGIN
select payment_schedule_id
into v_cm_payment_schedule
from ar_payment_schedules_all ps,
ra_customer_trx_all ract
where ps.customer_trx_id = ract.customer_trx_id
AND ract.trx_number = p_credit_memo
AND ract.org_id = ln_org_id;
select payment_schedule_id
into v_inv_payment_schedule
from ar_payment_schedules_all ps,
ra_customer_trx_all ract
where ps.customer_trx_id = ract.customer_trx_id
AND ract.trx_number = p_invoice_num
AND ract.org_id = ln_org_id;
EXCEPTION
WHEN OTHERS THEN
v_cm_payment_schedule := 0;
v_inv_payment_schedule := 0;
END;
v_amount_applied := p_amt;
fnd_client_info.set_org_context(8908);
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, -- NULL
p_attribute_category => v_null_flex, -- NULL
p_attribute1 => v_null_flex, -- NULL
p_attribute2 => v_null_flex, -- NULL
p_attribute3 => v_null_flex, -- NULL
p_attribute4 => v_null_flex, -- NULL
p_attribute5 => v_null_flex, -- NULL
p_attribute6 => v_null_flex, -- NULL
p_attribute7 => v_null_flex, -- NULL
p_attribute8 => v_null_flex, -- NULL
p_attribute9 => v_null_flex, -- NULL
p_attribute10 => v_null_flex, -- NULL
p_attribute11 => v_null_flex, -- NULL
p_attribute12 => v_null_flex, -- NULL
p_attribute13 => v_null_flex, -- NULL
p_attribute14 => v_null_flex, -- NULL
p_attribute15 => v_null_flex, -- NULL
p_global_attribute_category => v_null_flex, -- NULL
p_global_attribute1 => v_null_flex, -- NULL
p_global_attribute2 => v_null_flex, -- NULL
p_global_attribute3 => v_null_flex, -- NULL
p_global_attribute4 => v_null_flex, -- NULL
p_global_attribute5 => v_null_flex, -- NULL
p_global_attribute6 => v_null_flex, -- NULL
p_global_attribute7 => v_null_flex, -- NULL
p_global_attribute8 => v_null_flex, -- NULL
p_global_attribute9 => v_null_flex, -- NULL
p_global_attribute10 => v_null_flex, -- NULL
p_global_attribute11 => v_null_flex, -- NULL
p_global_attribute12 => v_null_flex, -- NULL
p_global_attribute13 => v_null_flex, -- NULL
p_global_attribute14 => v_null_flex, -- NULL
p_global_attribute15 => v_null_flex, -- NULL
p_global_attribute16 => v_null_flex, -- NULL
p_global_attribute17 => v_null_flex, -- NULL
p_global_attribute18 => v_null_flex, -- NULL
p_global_attribute19 => v_null_flex, -- NULL
p_global_attribute20 => v_null_flex, -- NULL
p_customer_trx_line_id => v_customer_trx_line_id, -- NULL
p_comments => v_comments, -- NULL
p_module_name => v_module_name, -- NULL
p_module_version => v_module_version, -- NULL
p_out_rec_application_id => v_out_rec_application_id, --NULL
p_acctd_amount_applied_from => v_acctd_amount_applied_from, -- NULL
p_acctd_amount_applied_to => v_acctd_amount_applied_to -- NULL
);
COMMIT;
RETURN ln_request_id;
END;
/
No comments:
Post a Comment