CREATE OR REPLACE PROCEDURE APPS.cite_ar_invoice IS --1. 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; cnt number; BEGIN ---2. --1. Set applications context if not already set. --fnd_global.apps_initialize(1013435, 55167, 222,0); --2. Populate header information. --6-20 Oracle Receivables Reference Guide --l_trx_header_tbl(1).trx_header_id := 101; --l_trx_header_tbl(1).trx_header_id := 1000000; --l_trx_header_tbl(1).trx_number := 'Test Invoice API'; l_trx_header_tbl(1).bill_to_customer_id := 1001; --l_trx_header_tbl(1).cust_trx_type_id := 2376; l_trx_header_tbl(1).cust_trx_type_id := 1923; --3. Populate batch source information. --l_batch_source_rec.batch_source_id := 1188; l_batch_source_rec.batch_source_id := -1; --4. Populate line 1 information. --l_trx_lines_tbl(1).trx_header_id := 1000000; --l_trx_lines_tbl(1).trx_line_id := 101; l_trx_lines_tbl(1).line_number := 1; l_trx_lines_tbl(1).memo_line_id := 8; l_trx_lines_tbl(1).quantity_invoiced := 1; l_trx_lines_tbl(1).unit_selling_price := 1; l_trx_lines_tbl(1).line_type := 'LINE'; --5. Populate line 2 information. --l_trx_lines_tbl(2).trx_header_id := 101; --l_trx_lines_tbl(2).trx_line_id := 102; --l_trx_lines_tbl(2).line_number := 2; --l_trx_lines_tbl(2).description := 'Test'; --l_trx_lines_tbl(2).quantity_invoiced := 12; --l_trx_lines_tbl(2).unit_selling_price := 12; --l_trx_lines_tbl(2).line_type := 'LINE'; --6. Populate freight information and link it to line 1. --l_trx_lines_tbl(3).trx_header_id := 101; --l_trx_lines_tbl(3).trx_line_id := 103; --l_trx_lines_tbl(3).link_to_trx_line_id := 101; --l_trx_lines_tbl(3).line_number := 1; --l_trx_lines_tbl(3).line_type := 'FREIGHT'; --l_trx_lines_tbl(3). amount := 25; --7. 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 --8. Check whether any record exist in error table --Invoice Creation API User Notes 6-21 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 if; END cite_ar_invoice; /