create or replace procedure XX_AR_CREDIT_MEMO
as
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_batch_id NUMBER;
l_cnt NUMBER := 0;
l_batch_source_rec ar_invoice_api_pub.batch_source_rec_type;
l_trx_header_tbl ar_invoice_api_pub.trx_header_tbl_type;
l_trx_lines_tbl ar_invoice_api_pub.trx_line_tbl_type;
l_trx_dist_tbl ar_invoice_api_pub.trx_dist_tbl_type;
l_trx_salescredits_tbl ar_invoice_api_pub.trx_salescredits_tbl_type;
l_customer_trx_id NUMBER;
BEGIN
--set applications context if not already set.
fnd_global.apps_initialize(1190, 20678, 222,0);
l_trx_header_tbl(1).trx_header_id := 101;
l_trx_header_tbl(1).trx_number := 'Test Invoice API';
l_trx_header_tbl(1).bill_to_customer_id := 2394;
l_trx_header_tbl(1).cust_trx_type_id := 1099;
--Populate batch source information.
l_batch_source_rec.batch_source_id := 1107;
--Populate line 1 information.
l_trx_lines_tbl(1).trx_header_id := 10001;
l_trx_lines_tbl(1).trx_line_id := 10001;
l_trx_lines_tbl(1).line_number := 1;
l_trx_lines_tbl(1).memo_line_id := null;
l_trx_lines_tbl(1).quantity_invoiced := 1;
l_trx_lines_tbl(1).unit_selling_price := 12;
l_trx_lines_tbl(1).line_type := 'LINE';
--Call the invoice api to create multiple invoices in a batch.
AR_INVOICE_API_PUB.create_single_invoice(
p_api_version => 1.0,
p_batch_source_rec => l_batch_source_rec,
p_trx_header_tbl => l_trx_header_tbl,
p_trx_lines_tbl => l_trx_lines_tbl,
p_trx_dist_tbl => l_trx_dist_tbl,
p_trx_salescredits_tbl => l_trx_salescredits_tbl,
x_customer_trx_id => l_customer_trx_id,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
IF l_return_status = fnd_api.g_ret_sts_error OR
l_return_status = fnd_api.g_ret_sts_unexp_error THEN
dbms_output.put_line('unexpected errors found!');
ELSE
--Check whether any record exist in error table
SELECT count(*)
Into cnt
From ar_trx_errors_gt;
IF cnt = 0
THEN
dbms_output.put_line ( 'Customer Trx id '|| l_customer_trx_id);
ELSE
dbms_output.put_line ( 'Transaction not Created, Please check ar_trx_errors_gt table');
END IF;
END;
No comments:
Post a Comment