This article illustrates how to populate the Invoice interface tables and invoke Autoinvoice for importing customer invoices into Oracle Apps.
Tables used
ra_interface_lines_all
ra_customers
hz_customers_profiles
hz_party_sites
ra_cust_trx_types_all
ra_terms_tl
fnd_user
ra_addresses_all
gl_sets_of_books
Steps to run autoinvoce
- Populate the table ra_interface_lines with data as per script given elsewhere in this document
- In the interface option choose autoinvoice
- From auto invoice choose autoinvoice master program.
- No. of instances =1
- Invoice source = Batch source name
- Default date: Current date may be entered
One request id is generated and the request is executed. Check the report for any errors.
Query in the transaction options to ensure invoice has been entered
Navigation: Transactions > Transactions
Click on Line Items button
Close this screen to go back to the Transaction form. Click on Distributions button
2) The setup steps for AutoInvoice process is given in this article.
4) Check column user_id in the table FND_USER for created_by and last_updated_by fields.
Query for retrieving data from the back end regarding customer number, id, etc.
SELECT ra_customers.party_id, ra_customers.customer_name, ra_customers.customer_number, hz_party_sites.party_site_number, ra_customers.customer_id, ra_addresses_all.address_id, ra_addresses_all.address1, ra_addresses_all.address2, ra_addresses_all.address3, ra_addresses_all.city, ra_addresses_all.postal_code, ra_addresses_all.state FROM ra_customers, hz_party_sites, ra_addresses_all WHERE ra_customers.party_id = hz_party_sites.party_id AND ra_addresses_all.party_location_id = hz_party_sites.location_id AND ra_addresses_all.org_id = 141 ORDER BY ra_customers.customer_number, ra_customers.customer_id, ra_customers.party_id, hz_party_sites.party_site_number
Insert script
The following fields should be populated by the script.
INSERT INTO ra_interface_lines_all (amount, batch_source_name, conversion_date, conversion_rate, conversion_type, currency_code, cust_trx_type_id, description, interface_line_attribute1, interface_line_context, line_type, orig_system_bill_address_id, --PARTY SITE ID orig_system_bill_customer_id, --CUSTOMER ID term_id, trx_date, gl_date, created_by, creation_date, last_update_date, last_updated_by, trx_number, set_of_books_id ) VALUES (20000, 'Intercompany', TO_DATE ('06-SEP-06', 'DD-MON-RR'), 1, 'Corporate', 'INR', 1, 'Invoice number', 'Invoice number', 'DFF name', 'Line ', 1124, 7045, 1001, 4, TO_DATE ('30-JUN-06', 'DD-MON-RR'), TO_DATE ('30-JUN-06', 'DD-MON-RR'), 0, TO_DATE ('06-SEP-06', 'DD-MON-RR'), TO_DATE ('06-SEP-06', 'DD-MON-RR'), 0, 'Invoice number', 1001 );
A sample interface program is given below
DECLARE /****************************************************************************** Note: To Import Customer Open Balances follow this steps:- 1.Create a DFF in the descriptive Segments 'Line Transaction Flexfield', set context as 'TEST' ,also select INTERFACE_LINE_ATTRIBUTE1 for pass the reference number. For that pass the 'TEST' value in the INTERFACE_LINE_CONTEXT and reference number in the INTERFACE_LINE_ATTRIBUTE1.This is mendatory because grouping rules. 2.Create a Source(AR->SETUP>TRANSACTIONS->SOURCES), 'PROJECTS INOVOICE', type should be 'IMPORTED' 3.Create a Transaction Types(AR->SETUP>TRANSACTIONS->TRANSACION TYPES), 'OPEN INVOICE'' attach receivable and revenue account. Then attch this Transaction types in the Source.' Run the Auto Invoice Master Program which call the Auto Invoice Import and after both successfull request it send the data. *******************************************************************************/ CURSOR c1 IS SELECT customer_name, customer_number, bill_no, bill_date, bill_amt, description, rate, revenue_account, rev_ccid, receivable_account, rec_ccid FROM xx_cust_open_inv WHERE status IS NULL; p_error NUMBER; p_err_msg VARCHAR2 (200); p_amount NUMBER := 0; i NUMBER := 1; --used as a counter p_interface_line_context VARCHAR2 (100); p_interface_line_attribute8 VARCHAR2 (100); --used as a grouping rule p_interface_line_attribute9 VARCHAR2 (100); --used as a grouping rule p_party_id NUMBER; p_cust_account_id NUMBER; p_bill_to_address VARCHAR2 (200); p_ship_to_address VARCHAR2 (200); p_bill_to_address_id NUMBER; p_ship_to_address_id NUMBER; RESULT BOOLEAN; p_item_id NUMBER; p_uom_code VARCHAR2 (150); p_unit_of_measure VARCHAR2 (150); p_item_description VARCHAR2 (240); v_seq NUMBER; p_party_name VARCHAR2 (240); p_message1 VARCHAR2 (20); p_message VARCHAR2 (200); BEGIN FOR c1_rec IN c1 LOOP p_error := 0; BEGIN p_message1 := 'CUSTOMER ERROR'; SELECT party_id INTO p_party_id FROM hz_parties WHERE UPPER (party_name) = UPPER (c1_rec.customer_name); p_message1 := 'CUST ACCOUNT ERROR'; SELECT cust_account_id INTO p_cust_account_id FROM hz_cust_accounts WHERE party_id = p_party_id; p_message1 := 'BILL REF ERROR'; SELECT orig_system_reference, cust_acct_site_id INTO p_bill_to_address, p_bill_to_address_id FROM hz_cust_acct_sites_all WHERE cust_account_id = p_cust_account_id AND bill_to_flag = 'P'; p_message1 := 'SHIP REF ERROR'; SELECT orig_system_reference INTO p_ship_to_address FROM hz_cust_acct_sites_all WHERE cust_account_id = p_cust_account_id AND ship_to_flag = 'P'; EXCEPTION WHEN OTHERS THEN p_message := SUBSTR (SQLERRM, 1, 180 ); UPDATE xx_cust_open_inv SET status = 'N', error_meggage = p_message1 || p_message WHERE bill_no = c1_rec.bill_no; p_error := 1; END; -- The specific record is left out and looped into the next record p_item_description := 'OPEN INVOICE'; BEGIN p_message1 := 'HEADER ERROR'; INSERT INTO ra_interface_lines_all (interface_line_id, description, interface_line_context, interface_line_attribute1, interface_line_attribute2, interface_line_attribute3, interface_line_attribute4, interface_line_attribute5, interface_line_attribute6, interface_line_attribute7, interface_line_attribute8, batch_source_name, set_of_books_id, line_type, currency_code, amount, cust_trx_type_id, term_id, orig_system_bill_customer_id, orig_system_bill_address_id, orig_system_bill_address_ref, orig_system_ship_address_id, orig_system_ship_customer_id, conversion_type, conversion_rate, trx_date, gl_date, quantity, unit_selling_price, acctd_amount, interface_line_attribute9, line_number, comments, created_by, creation_date, last_updated_by, last_update_date, last_update_login, org_id ) VALUES (ra_customer_trx_lines_s.NEXTVAL, p_item_description, 'TEST', xx_open_cust_invoice_num.NEXTVAL, --project number, 'DRAFT', -- Draft Invoice Number 'AGREEMENT', -- Agreement Number 'ORG', -- Project Organization Number 'ABCD', -- Project Manager v_counter, -- Line Number 'Type', -- Type 'Line', -- Line Type 'PROJECTS INVOICE', -- Transaction Source Name 3004, -- GL Set Of Books Id 'LINE', 'INR', c1_rec.bill_amt, 1300, -- Transaction Type Id 5, -- Payment Terms Id p_cust_account_id, p_bill_to_address_id, p_bill_to_address, p_bill_to_address_id, p_cust_account_id, 'User', -- Exchange Rate Type 1, -- Exchange Rate SYSDATE, -- Transaction Date SYSDATE, -- GL Date 1, c1_rec.rate, c1_rec.bill_amt, c1_rec.bill_no, 1, 'INVOICES', -- Comments Line-- 0, SYSDATE, 0, SYSDATE, -1, 123 -- Operating Unit Id ); p_message1 := 'REV ERROR'; INSERT INTO ra_interface_distributions_all (interface_distribution_id, interface_line_id, interface_line_context, account_class, amount, code_combination_id, acctd_amount, interface_line_attribute9, interface_line_attribute10, created_by, creation_date, last_update_date, last_updated_by, last_update_login, org_id ) VALUES (ra_cust_trx_line_gl_dist_s.NEXTVAL, ra_customer_trx_lines_s.CURRVAL, 'Test', -- Used as a grouping rule 'REV', c1_rec.bill_amt, c1_rec.rev_ccid, c1_rec.bill_amt, c1_rec.bill_no, 234, 0, SYSDATE, SYSDATE, 0, -1, 123 -- Operating Unit Id ); p_message1 := 'REC ERROR'; INSERT INTO ra_interface_distributions_all (interface_distribution_id, interface_line_id, interface_line_context, account_class, amount, PERCENT, code_combination_id, acctd_amount, interface_line_attribute9, interface_line_attribute10, created_by, creation_date, last_update_date, last_updated_by, last_update_login, org_id ) VALUES (ra_cust_trx_line_gl_dist_s.NEXTVAL, ra_customer_trx_lines_s.CURRVAL, 'Test', 'REC', c1_rec.bill_amt, 100, c1_rec.rec_ccid, c1_rec.bill_amt, c1_rec.bill_no, 234, -- User Id 0, SYSDATE, SYSDATE, 0, -1, 123 ); EXCEPTION WHEN OTHERS THEN p_message := SUBSTR (SQLERRM, 1, 180 ); UPDATE xx_cust_open_inv SET status = 'N', error_meggage = p_message1 || p_message WHERE bill_no = c1_rec.bill_no; END; fnd_global.apps_initialize (user_id => 234, resp_id => 50237, resp_appl_id => 222 ); -- Execute the Invoice import program reqno := fnd_request.submit_request (application => 'SQLAR', program => 'RAXMTR', start_time => SYSDATE, argument1 => '1', argument2 => 'TESTSCP', argument3 => '30-Sep-2005' ); END LOOP; END;
Cheers!
Related articles
- Supplier & Supplier Sites Interface/Conversion (oraclemaniac.com)
- Batch Element Entry interface automation (oraclemaniac.com)
- How to administer folders in Oracle Apps (oraclemaniac.com)
- SQL to get the status of all expense reports (oraclemaniac.com)
- Procure To Pay (P2P) Process flow (oraclemaniac.com)
- Document Sequence Numbering (oraclemaniac.com)
- Transaction to Receipt flow in Oracle Receivables (oraclemaniac.com)
- How to enable Record History for a custom form (oraclemaniac.com)
- Customized process to convert Internal Requisitions to Move Orders (oraclemaniac.com)
- Oracle iExpenses flow (oraclemaniac.com)
