SET serveroutput on
DECLARE
v_init_msg_list VARCHAR2 (1000);
v_commit_flag VARCHAR2 (5) := 'F';
v_validation_level NUMBER (4) := fnd_api.g_valid_level_full;
v_msg_count NUMBER (4);
v_msg_data VARCHAR2 (1000);
v_return_status VARCHAR2 (5);
v_adj_rec ar_adjustments%ROWTYPE;
v_chk_approval_limits VARCHAR2 (5) := 'F';
v_check_amount VARCHAR2 (5) := 'F';
v_move_deferred_tax VARCHAR2 (1) := 'Y';
v_new_adjust_number ar_adjustments.adjustment_number%TYPE;
v_new_adjust_id ar_adjustments.adjustment_id%TYPE;
v_called_from VARCHAR2 (25) := 'ADJ-API';
v_old_adjust_id ar_adjustments.adjustment_id%TYPE;
l_customer_trx_id NUMBER;
l_payment_schedule_id NUMBER;
l_receivables_trx_id NUMBER;
CURSOR trx_lines_to_ar_c
IS
Select * from AR_CM_ADUJUSTMENTS
Where invoice_currency_code='USD' ORDER BY 1;
BEGIN
FOR c1 IN trx_lines_to_ar_c
LOOP
BEGIN
SELECT a.customer_trx_id, b.payment_schedule_id
INTO l_customer_trx_id, l_payment_schedule_id
FROM ra_customer_trx_all a, ar_payment_schedules_all b
WHERE a.customer_trx_id = b.customer_trx_id
AND a.trx_number = c1.trx_number;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Transaction Number does not exist'
|| c1.trx_number
);
END;
BEGIN
SELECT receivables_trx_id
INTO l_receivables_trx_id
FROM ar_receivables_trx_all
WHERE NAME = 'Adjustment-Data Migration';
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Receivable Transaction does not exist'
|| 'Adjustment-Data Migration'
);
END;
/*------------------------------------+
| Setting global initialization |
+------------------------------------*/
mo_global.init ('AR');
mo_global.set_policy_context ('S', '82');
fnd_global.apps_initialize (1113, 20678, 222, 0);
/*------------------------------------+
| Setting value to input parameters |
+------------------------------------*/
--Populate v_adj_rec record
v_adj_rec.customer_trx_id := l_customer_trx_id;
v_adj_rec.TYPE := 'LINE';
v_adj_rec.payment_schedule_id := l_payment_schedule_id;
v_adj_rec.receivables_trx_id := l_receivables_trx_id;
v_adj_rec.amount := c1.AMOUNT;
v_adj_rec.apply_date := TO_DATE (c1.apply_date);
v_adj_rec.gl_date := TO_DATE (c1.gl_date);
v_adj_rec.created_from := 'ADJ-API';
ar_adjust_pub.create_adjustment ('AR_ADJUST_PUB',
1.0,
v_init_msg_list,
v_commit_flag,
v_validation_level,
v_msg_count,
v_msg_data,
v_return_status,
v_adj_rec,
v_chk_approval_limits,
v_check_amount,
v_move_deferred_tax,
v_new_adjust_number,
v_new_adjust_id,
v_called_from,
v_old_adjust_id
);
DBMS_OUTPUT.put_line (v_msg_data);
DBMS_OUTPUT.put_line (v_new_adjust_number);
DBMS_OUTPUT.put_line (v_new_adjust_id);
DBMS_OUTPUT.put_line (v_init_msg_list);
DBMS_OUTPUT.put_line ('Successfully Completed');
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
FOR i IN 1 .. v_msg_count
LOOP
DBMS_OUTPUT.put_line (v_msg_data);
DBMS_OUTPUT.put_line (v_new_adjust_number);
DBMS_OUTPUT.put_line (v_new_adjust_id);
DBMS_OUTPUT.put_line (v_init_msg_list);
END LOOP;
END;
/
This comment has been removed by the author.
ReplyDelete