Auto Invoice is a tool that can be used to import and validate transaction data from other financial systems from which one can create invoices, debit memos, credit memos, and on-account credits. It rejects transactions with invalid information to insure the integrity of the data.
To make fully functional what else required:
• Loader program
• Validation program
AutoInvoice is a tool consists of 3 main programs. Each program will have unique nature of work to do and they are called internally except Purge program whose execution is derived on the setup otherwise ready to execute stand alone.
• Master (RAXMTR)
• Import (RAXTRX)
• Purge (RAXDEL)
1. Auto Invoice Master program RAXMTR
Selects and marks records in the interface tables to be processed based on the parameters the user entered and then calls the Auto Invoice Import program. Auto Invoice Master Program has no report output.
•Gathers statistics, it means it gathers the stats on interface tables and set the stats on certain indices on interface tables
•Marks interface records for processing by marking request_id
•Submits multiple workers for Parallel Processing by creating instances for request.
2. Auto Invoice Import Program
Validates the selected record and creates transaction if it passes validation. Any record that fails validation is left in the interface table with an error code. Depending on the setup, related records may be rejected as well. This program has an output file called Auto Invoice Execution report, which you can view by clicking the View Report button in the Requests window.
• Workhorse of Auto invoice
• Validates data
• Inserts records
• Deletes interface data
• Only when system option purge set to ‘Y’
3. Auto Invoice Purge Program
Deletes records from the interface tables. If you set the Purge
Interface Table system option to No in Define System Option window, Auto
Invoice does not delete processed records from the interface tables
after each run, and we must submit Auto Invoice Purge Program
periodically to clean up the interface tables. This program only deletes
transaction lines that have been successfully imported.
•Deletes all rows where interface_status =‘P’
•Ra_interface_lines
•Ra_interface_distributions
•Ra_interface_salescredits
How to start
As discussed above, oracle Receivable’s Auto Invoice program will be used to import and validate Invoices.
A custom feeder program is required to transfer data from the Advantage extract files and populate the Auto Invoice interfacetables (RA_INTERFACE_LINES_ALL and RA_INTERFACE_DISTRIBUTIONS_ALL).If there is need to run populate sales credit into RA_INTERFACE_SALESCREDITS_ALL table.
When run, AutoInvoiceproduces the AutoInvoice Execution Report and the AutoInvoice Validation Report.
Any entries which failed validation can be reviewed in Oracle Receivables’ AutoInvoice Interface Exceptions window. Depending on the error, changes may need to be made in Receivables, the feeder program or the imported records in the interface tables.
The main three steps for AR Invoice Interface are:
1] Put the data into your staging tables.
2] Call your package to validate the data and load into AR Interface
tables (RA_INTERFACE_LINES_ALL & RA_INTERFACE_DISTRIBUTIONS_ALL).
3] Then submits a concurrent request for AutoInvoice.
If any errors occur it can be found in ra_interface_errors_all table.
The concurrent program has 2 stages. First the Master program fires
which intern kicks of the Import Program. Once this is completed data is
inserted into the following tables.
1) ra_customer_trx_all (Invoice Header Info)
2) ra_customer_trx_lines_all (Invoice Line Level Info)
3) ra_cust_trx_line_gl_dist_all (Accounting Info. One record for each
Account Type is inserted into this… ex. Receivable Revenue Tax Freight
etc)
4) ar_payment_schedules_all (All Payment related info)
Validations:
Validation are generally done on the below columns.
• Batch_source_name
• Set_of_books_id
• Orig_sys_batch_name
• orig_system_bill_customer_ref
• orig_system_bill_address_ref
• Line_Type
• Currency_Code
• Term_name
• Transaction_type
• Interface_line_attribute1-7
• Account_class
• Accounting Flexfields segments
1- AR Transaction Type Validation: Check if the Transaction type
provided in data file is defined in AR transaction types
(RA_CUST_TRX_TYPES_ALL)
2- Transaction Batch Source Validation: Check if the source provided in
data file is defined in AR transaction Batch source
(RA_BATCH_SOURCES_ALL).
3- Invoice Currency Validation: Check if the currency provided in data file is defined in AR Currency (FND_CURRENCIES).
4- Customer Validation: Check if the Bill to Customer Number, Ship to
Customer Number, Bill to Custom Location, Ship to Customer Location
provided in the data file is defined in AR Customer (RA_CUSTOMERS).
5- Primary Sales Representative Validation: Sales representative number to be hardcode to “-3” for “No Sales Credit.”
6- Term Name: Check if the Term name provided in the data file is defined in Payment terms (RA_TERMS)
7- Inventory Item Validation: Check if the Item provided in data file is defined in Inventory Items (MTL_SYSTEM_ITEMS).
8- Unit of Measurement validation: Check if the UOM provided is defined in MTL_UNITS_OF_MEASURE Table
9- Invoice Tax Code Validation: Check if the Tax Code provided in data file is defined in AR_VAT_TAX_ALL_B Table.
10- Invoice GL Date Validation: Check if the GL Data of provided invoices is in open period.
This sample code will call “Autoinvoice Import Program” (Program short name is “RAXTRX”) using FND_REQUEST.SUBMIT_REQUEST API
Autoinvoice Import Program takes following parameters :
argv[0] program name
argv[1] parallel module name [MAIN|PU?]
argv[2] running mode [V|T|P]
argv[3] batch source id
argv[4] batch source name
argv[5] default date
argv[6] concatenated transaction flexfield attribute value
argv[7] transaction type id
argv[8] low bill to customer number
argv[9] high bill to customer number
argv[10] low bill to customer name
argv[11] high bill to customer name
argv[12] low gl date
argv[13] high gl date
argv[14] low ship date
argv[15] high ship date
argv[16] low transaction number
argv[17] high transaction number
argv[18] low sales order
argv[19] high sales order
argv[20] low invoice date
argv[21] high invoice date
argv[22] low ship to customer number
argv[23] high ship to customer number
argv[24] low ship to customer name
argv[25] high ship to customer name
argv[26] Call RAXTRX from RAXMTR flag
argv[27] Base Due Date on invoice date flag
argv[28] Minimum Due Date offset from trx date
argv[29] Org_id
First find out user_id and RESPONSIBILITY_ID through which you will submit the program to set the context :
01 SELECTUSER_ID,RESPONSIBILITY_ID,RESPONSIBILITY_APPLICATION_ID,
02 SECURITY_GROUP_ID
03 FROMFND_USER_RESP_GROUPS
04 WHEREUSER_ID = (SELECTUSER_ID
05 FROMFND_USER
06 WHEREUSER_NAME = ‘&user_name’)
07 ANDRESPONSIBILITY_ID = (SELECTRESPONSIBILITY_ID
08 FROMFND_RESPONSIBILITY_VL
09 WHERERESPONSIBILITY_NAME = ‘&resp_name’);[sourcecode]</div>
10
11 Using above query toget UserID, Resp Id andApplication ID topass inbelow code,
12
13 [sourcecode language="sql"]
14 DECLARE
15 l_request_id NUMBER;
16 BEGIN
17 Fnd_Global.apps_initialize(userId,responsibilityId,applicationId)
18 — replace the following code with correct value as get from sql above
19 Fnd_Global.apps_initialize(1012178,50559,222);
20 l_request_id :=
21 fnd_request.submit_request
22 (application => ‘AR’,
23 program => ‘RAXTRX’,
24 description => NULL,
25 start_time => NULL,– To start immediately
26 sub_request => FALSE,
27 argument1 => ‘MAIN’,
28 argument2 => ‘T’,
29 argument3 => ’1228′,–batch_source_id
30 argument4 => ‘LEGACY’, –batch_source_name
31 argument5 => ’2010/06/11 00:00:00′, — should be in
format — RR-MON-DD
32 argument6 => ”,
33 argument7 => ”,
34 argument8 => ”,
35 argument9 => ”,
36 argument10 => ”,
37 argument11 => ”,
38 argument12 => ”,
39 argument13 => ”,
40 argument14 => ”,
41 argument15 => ”,
42 argument16 => ”,
43 argument17 => ”,
44 argument18 => ’63737′, –sales_order low
45 argument19 => ’63737′, –sales_order high
46 argument20 => ”,
47 argument21 => ”,
48 argument22 => ”,
49 argument23 => ”,
50 argument24 => ”,
51 argument25 => ”,
52 argument26 => ‘N’,
53 argument27 => ‘Y’,
54 argument28 => ”,
55 argument29 => ’204′, — org_id
56 argument30 => chr(0) — end with chr(0)as end of parameters
57 );
58 dbms_output.put_line(l_request_id);
59 END;
Creating Invoices using API’s
API – AR Invoice (Transaction) Creation
CREATE OR REPLACE procedure APPS.xx_ar_invoice_api
is
l_return_statusvarchar2(1);
l_msg_count number;
l_msg_datavarchar2(2000);
l_batch_source_recar_invoice_api_pub.batch_source_rec_type;
l_trx_header_tblar_invoice_api_pub.trx_header_tbl_type;
l_trx_lines_tblar_invoice_api_pub.trx_line_tbl_type;
l_trx_dist_tblar_invoice_api_pub.trx_dist_tbl_type;
l_trx_salescredits_tblar_invoice_api_pub.trx_salescredits_tbl_type;
l_cust_trx_id number;
BEGIN
begin
MO_GLOBAL.SET_POLICY_CONTEXT(‘S’,82);
end;
fnd_global.apps_initialize(1090,20678,222);
l_batch_source_rec.batch_source_id := 1001;
l_trx_header_tbl(1).trx_header_id := 9898;
l_trx_header_tbl(1).trx_date := sysdate;
l_trx_header_tbl(1).trx_currency := ‘AED’;
l_trx_header_tbl(1).cust_trx_type_id := 1000;
l_trx_header_tbl(1).bill_to_customer_id := 1139;
l_trx_header_tbl(1).term_id := 1000;
l_trx_header_tbl(1).finance_charges := ‘N’;
l_trx_header_tbl(1).status_trx := ‘OP’;
l_trx_header_tbl(1).printing_option := ‘NOT’;
–l_trx_header_tbl(1).reference_number := ’1111′;
l_trx_lines_tbl(1).trx_header_id := 9898;
l_trx_lines_tbl(1).trx_line_id := 101;
l_trx_lines_tbl(1).line_number := 1;
l_trx_lines_tbl(1).inventory_item_id := 1185;
– l_trx_lines_tbl(1).description := ‘CAST IRON GRILL-325*485MM’;
l_trx_lines_tbl(1).quantity_invoiced := 3;
l_trx_lines_tbl(1).unit_selling_price := 525; –Price
l_trx_lines_tbl(1).uom_code := ‘EAC’;
l_trx_lines_tbl(1).line_type := ‘LINE’;
l_trx_dist_tbl(1).trx_dist_id := 101;
l_trx_dist_tbl(1).trx_line_id := 101;
l_trx_dist_tbl(1).ACCOUNT_CLASS := ‘REV’;
l_trx_dist_tbl(1).percent := 100;
l_trx_dist_tbl(1).CODE_COMBINATION_ID := 1012;
–Here we call the API to create Invoice with the stored values
AR_INVOICE_API_PUB.create_invoice
(p_api_version => 1.0
–,p_commit => ‘T’
,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_return_status =>l_return_status
,x_msg_count =>l_msg_count
,x_msg_data =>l_msg_data
);
dbms_output.put_line(‘Created:’||l_msg_data||l_return_status);
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(l_return_status||’:'||sqlerrm);
Else
dbms_output.put_line(l_return_status||’:'||sqlerrm);
If (ar_invoice_api_pub.g_api_outputs.batch_id IS NOT NULL) Then
Dbms_output.put_line(‘Invoice(s) suceessfully created!’) ;
Dbms_output.put_line(‘Batch ID: ‘ || ar_invoice_api_pub.g_api_outputs.batch_id);
Dbms_output.put_line(‘customer_trx_id: ‘ || l_cust_trx_id);
Else
Dbms_output.put_line(sqlerrm);
End If;
end if;
commit;
End;
/
Comments
Post a Comment