/* Formatted on 2012/06/30 14:59 (Formatter Plus v4.8.8) */
--- Note no 1361075.1
DECLARE
l_return_status VARCHAR2 (1);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (240);
l_cash_receipt_id NUMBER;
p_count NUMBER := 0;
l_application_ref_type ar_receivable_applications.application_ref_type%TYPE;
l_application_ref_id ar_receivable_applications.application_ref_id%TYPE;
l_application_ref_num ar_receivable_applications.application_ref_num%TYPE;
l_secondary_application_ref_id ar_receivable_applications.secondary_application_ref_id%TYPE;
l_receivable_application_id ar_receivable_applications.receivable_application_id%TYPE;
CURSOR trx_lines_to_ar_c
IS
SELECT sno, receipt_number, customer_name, customer_number,
location_code, apply_amount
FROM XXX_receipt_write_off
WHERE sno not in (9);
BEGIN
-- 1) Set the applications context
mo_global.init ('AR');
mo_global.set_policy_context ('S', '82');
fnd_global.apps_initialize (1110, 20678, 222, 0);
FOR c1 IN trx_lines_to_ar_c
LOOP
BEGIN
SELECT cash_receipt_id
INTO l_cash_receipt_id
FROM ar_cash_receipts_all a, hz_cust_accounts_all b, hz_parties c
WHERE a.pay_from_customer = b.cust_account_id
AND b.party_id = c.party_id
AND receipt_number = c1.receipt_number
AND b.account_number = c1.customer_number
AND UPPER (TRIM (c.party_name)) = UPPER (TRIM (c1.customer_name));
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Receipt Number does not exist'
|| c1.receipt_number
);
END;
ar_receipt_api_pub.activity_application
(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 => -3,
p_receivables_trx_id => 2001,
p_receivable_application_id => l_receivable_application_id,
p_application_ref_type => l_application_ref_type,
p_application_ref_id => l_application_ref_id,
p_application_ref_num => l_application_ref_num,
p_secondary_application_ref_id => l_secondary_application_ref_id
);
-- 3) Review the API output
DBMS_OUTPUT.put_line ('Status ' || l_return_status);
DBMS_OUTPUT.put_line ('Message count ' || l_msg_count);
DBMS_OUTPUT.put_line ('Application ID ' || l_receivable_application_id);
DBMS_OUTPUT.put_line ( 'Successfully Receipt Write off has been done '
|| c1.receipt_number
);
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;
COMMIT;
END LOOP;
COMMIT;
END;
--- Note no 1361075.1
DECLARE
l_return_status VARCHAR2 (1);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (240);
l_cash_receipt_id NUMBER;
p_count NUMBER := 0;
l_application_ref_type ar_receivable_applications.application_ref_type%TYPE;
l_application_ref_id ar_receivable_applications.application_ref_id%TYPE;
l_application_ref_num ar_receivable_applications.application_ref_num%TYPE;
l_secondary_application_ref_id ar_receivable_applications.secondary_application_ref_id%TYPE;
l_receivable_application_id ar_receivable_applications.receivable_application_id%TYPE;
CURSOR trx_lines_to_ar_c
IS
SELECT sno, receipt_number, customer_name, customer_number,
location_code, apply_amount
FROM XXX_receipt_write_off
WHERE sno not in (9);
BEGIN
-- 1) Set the applications context
mo_global.init ('AR');
mo_global.set_policy_context ('S', '82');
fnd_global.apps_initialize (1110, 20678, 222, 0);
FOR c1 IN trx_lines_to_ar_c
LOOP
BEGIN
SELECT cash_receipt_id
INTO l_cash_receipt_id
FROM ar_cash_receipts_all a, hz_cust_accounts_all b, hz_parties c
WHERE a.pay_from_customer = b.cust_account_id
AND b.party_id = c.party_id
AND receipt_number = c1.receipt_number
AND b.account_number = c1.customer_number
AND UPPER (TRIM (c.party_name)) = UPPER (TRIM (c1.customer_name));
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Receipt Number does not exist'
|| c1.receipt_number
);
END;
ar_receipt_api_pub.activity_application
(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 => -3,
p_receivables_trx_id => 2001,
p_receivable_application_id => l_receivable_application_id,
p_application_ref_type => l_application_ref_type,
p_application_ref_id => l_application_ref_id,
p_application_ref_num => l_application_ref_num,
p_secondary_application_ref_id => l_secondary_application_ref_id
);
-- 3) Review the API output
DBMS_OUTPUT.put_line ('Status ' || l_return_status);
DBMS_OUTPUT.put_line ('Message count ' || l_msg_count);
DBMS_OUTPUT.put_line ('Application ID ' || l_receivable_application_id);
DBMS_OUTPUT.put_line ( 'Successfully Receipt Write off has been done '
|| c1.receipt_number
);
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;
COMMIT;
END LOOP;
COMMIT;
END;
No comments :
Post a Comment