DECLARE
l_return_status VARCHAR2 (1);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (240);
l_count NUMBER;
l_cash_receipt_id NUMBER;
l_msg_data_out VARCHAR2 (240);
l_mesg VARCHAR2 (240);
p_count NUMBER;
l_bill_to_cust_id NUMBER;
l_cash_receipt_id NUMBER;
l_applied_payment_schedule_id NUMBER;
CURSOR trx_lines_to_ar_c
IS
SELECT *
FROM oomco_receipt_unapply
ORDER BY 1;
BEGIN
mo_global.init ('AR');
mo_global.set_policy_context ('S', '82');
fnd_global.apps_initialize (1113, 20678, 222, 0);
arp_standard.enable_debug;
arp_standard.enable_file_debug ('/usr/tmp', 'Api_Create.log');
FOR c1 IN trx_lines_to_ar_c
LOOP
BEGIN
SELECT DISTINCT b.cust_account_id
INTO l_bill_to_cust_id
FROM hz_parties a, hz_cust_accounts b
WHERE a.party_id = b.party_id
AND ROWNUM = 1
AND UPPER (TRIM (a.party_name)) =
UPPER (TRIM (c1.customer_name));
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Customer does not exist in E Business Suite '
|| c1.customer_name
);
END;
BEGIN
SELECT DISTINCT a.cash_receipt_id, a.applied_payment_schedule_id
INTO l_cash_receipt_id, l_applied_payment_schedule_id
FROM ar_receivable_applications_all a,
ar_cash_receipts_all b
WHERE a.cash_receipt_id = b.cash_receipt_id
AND a.applied_customer_trx_id IS NOT NULL
AND b.pay_from_customer = l_bill_to_cust_id
AND b.receipt_number = c1.receipt_number;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line
( 'Receipt Number and Customer Does not exist '
|| c1.receipt_number
);
END;
ar_receipt_api_pub.unapply
(p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
p_validation_level => fnd_api.g_valid_level_full,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_cash_receipt_id => l_cash_receipt_id,
p_applied_payment_schedule_id => l_applied_payment_schedule_id,
p_reversal_gl_date => TO_DATE (c1.gl_date)
);
COMMIT;
DBMS_OUTPUT.put_line ('Message count ' || l_msg_count);
DBMS_OUTPUT.put_line ('Cash Receipt ID ' || l_cash_receipt_id);
IF l_msg_count = 1
THEN
DBMS_OUTPUT.put_line ('l_msg_data ' || l_msg_data);
ELSIF l_msg_count > 1
THEN
LOOP
p_count := p_count + 1;
l_msg_data :=
fnd_msg_pub.get (fnd_msg_pub.g_next, fnd_api.g_false);
IF l_msg_data IS NULL
THEN
EXIT;
END IF;
DBMS_OUTPUT.put_line ('Message' || p_count || ' ---' || l_msg_data);
END LOOP;
END IF;
arp_standard.disable_debug;
COMMIT;
DBMS_OUTPUT.put_line ('Successfully completed');
END LOOP;
END;
No comments :
Post a Comment