Documente Academic
Documente Profesional
Documente Cultură
CONTENTS:
AP Invoice Interface: ..3 Pre-Requisites: 3
Interface table for AP Invoices : .3 AP Base tables: ..3 Mandatory columns 4 AP_invoices_interface: .4 AP_invoice_lines_interface: .4 Validations: ..5 Concurrent program: .15 Payables open interface import: 15 API for concurrent program: .18 How to register stored procedure in apps20 Setups in AP invoice interface : ..24 How to handle the error ?: 25 2
References .27
AP INVOICE INTERFACE
This interface helps us to import vendor invoices into Oracle applications from external systems into Oracle Applications. Data in the AP_INVOICES_INTERFACE table used in conjunction with AP_INVOICE_LINES_INTERFACE table to create Payables Invoice, Invoice lines, Distributions and Schedule payments. Data in this table can be viewed and edited using Open Interface Invoices window. The Payables Open Interface program validates each record in this interface table selected for import, and if the record contains valid data then the program creates a Payables Invoice.
PRE-REQUISITES:
Set of Books Code combinations Employees Lookups
AP BASE TABLES:
AP_INVOICES_ALL (Header information) AP_INVOICE_DISTRIBUTIONS_ALL( Lines information)
MANDATORY COLUMNS
Some important columns that need to be populated in the interface tables:
AP_INVOICES_INTERFACE:
This is the open interface table for importing AP Invoices from external sources and stores header information about invoices.
Important columns:
INVOICE_ID (Required) (Unique identifier for this invoice within this batch. Same value should be populated in invoices lines in the AP_INVOICE_LINES_INTERFACE table to identify the data as belonging to the same invoice.) INVOICE_NUM (Required) (Enter the invoice number that needs to be assigned to the invoice created in Payables from this record.) INVOICE_TYPE_LOOKUP_CODE (OPTIONAL) INVOICE_DATE (OPTIONAL) VENDOR_NUM AND VENDOR_NAME (Optional) VENDOR_ID & VENDOR_SITE_ID (Required) : VENDOR_ID is unique identifier for a supplier and VENDOR_SITE_ID is Internal supplier site identifier. INVOICE_AMOUNT (Required) : Amount of the invoice. INVOICE_CURRENCY_CODE (Optional)
4
EXCHANGE_RATE (Optional) EXCHANGE_RATE_TYPE (Optional) EXCHANGE_DATE (Optional) DESCRIPTION (Optional) SOURCE (Required) (source of the invoice data) PO_NUMBER (OPTIONAL) PAYMENT_METHOD_LOOKUP_CODE PAY_GROUP_LOOKUP_CODE ATTRIBUTE1 TO 15 ORG_ID
AP_INVOICE_LINES_INTERFACE:
This is the lines interface table for the AP Invoice Open Interface and it is used in conjunction with AP_INVOICE_INTERFACE table. AP_INVOICE_LINES_INTERFACE stores information used to create one or more invoice distributions. Note that one row in this table may create, during the import process, more than one invoice distribution.
Important columns:
INVOICE_ID (Required) :Enter the INVOICE_ID of the corresponding invoice in the AP_INVOICES_INTERFACE table. INVOICE_NUM INVOICE_LINE_ID (Optional): You can enter a unique number for each invoice line of an invoice. LINE_TYPE_LOOKUP_CODE (Required) Enter the lookup code for the type of invoice distribution that you want Payables Open Interface Import to create from this record. The code you enter must be ITEM, TAX, MISCELLANEOUS, or FREIGHT. These lookup codes are stored in the AP_LOOKUP_CODES table. AMOUNT (Required) : The invoice distribution amount. If you are matching to a purchase order, the AMOUNT = QUANTITY_INVOICED x UNIT PRICE. If the total
5
amount of all the invoice distributions does not equal the amount of the invoice that has the same INVOICE_ID, then Payables Open Interface Import will reject the invoice.
DESCRIPTION TAX_CODE PO_NUMBER PO_LINE_NUMBER PO_SHIPMENT_NUM PO_DISTRIBUTION_NUM PO_UNIT_OF_MEASURE QUANTITY_INVOICED DIST_CODE_CONCATENATED DIST_CODE_COMBINATION_ID ATTRIBUTE1 to 5 ORG_ID
|| ' ' || i.supplier_number || ' ' || 'is not found' ); v_status := FALSE; v_error_flag := 1; END; ELSE fnd_file.put_line (fnd_file.output, 'Vendor Number cannot be null for invoice number :' || ' ' || i.invoice_number ); v_status := FALSE; v_error_flag :=1; END IF; END;
'Vendor site cannot be null for invoice number :' || ' ' || i.invoice_number ); v_status := FALSE; END IF; END;
BEGIN IF i.invoice_number IS NOT NULL and v_status = TRUE THEN SELECT COUNT (1) INTO v_invoice_count FROM ap_invoices_all WHERE invoice_num = i.invoice_number AND org_id = i.org_id AND vendor_id = v_vendor_id AND vendor_site_id = v_vendor_site_id; IF v_invoice_count = 0 THEN v_status := TRUE; ELSE v_status := FALSE; fnd_file.put_line (fnd_file.output, 'Invoice no.' || ' ' || i.invoice_number || ' already exist in system for this supplier' ); END IF; END IF; END; END IF;
END;
fnd_file.put_line (fnd_file.output, 'Invoice Type Code is wrong for invoice no.' || i.invoice_number ); -- ELSE -- V_STATUS := TRUE; END IF; END IF; END;
BEGIN
10
IF i.SOURCE IS NOT NULL and v_status = TRUE THEN SELECT COUNT (1) INTO v_source_count FROM fnd_lookup_values WHERE lookup_type = 'SOURCE' AND lookup_code = TRIM (UPPER (i.SOURCE)) AND enabled_flag = 'Y'; IF v_source_count = 0 THEN v_status := FALSE; fnd_file.put_line (fnd_file.output, 'Invoice Source Code is wrong for invoice no.' || i.invoice_number ); -- ELSE -- V_STATUS := TRUE; END IF; ELSE fnd_file.put_line (fnd_file.output, 'Invoice Source Code cannot be null invoice no.' || i.invoice_number ); END IF; END;
11
'Unable to find basic currency' ); END; IF v_currency_code <> TRIM (i.invoice_currency) and v_status = TRUE AND i.exchange_rate_type <> 'User' THEN BEGIN SELECT COUNT (1), conversion_type, user_conversion_type INTO v_ext_rate_type_count, v_ext_rate_type_code, v_user_con_type FROM gl_daily_conversion_types WHERE user_conversion_type <> 'User' AND user_conversion_type = TRIM (i.exchange_rate_type) GROUP BY conversion_type, user_conversion_type; IF v_ext_rate_type_count <> 0 THEN IF v_ext_rate_type_code <> 'User' THEN BEGIN SELECT gdr.conversion_rate INTO v_conversion_rate FROM gl_daily_rates gdr WHERE gdr.from_currency = i.invoice_currency AND gdr.to_currency = v_currency_code AND gdr.conversion_date = TO_DATE (i.exchange_rate_date, 'DD-Mon-YY') AND gdr.conversion_type = v_ext_rate_type_code AND gdr.conversion_type <> 'User' AND gdr.status_code = 'C'; EXCEPTION WHEN NO_DATA_FOUND THEN fnd_file.put_line (fnd_file.output, 'Conversion rate not define for Invoice no.' || i.invoice_number ); v_status := FALSE; END; ELSE v_conversion_rate := i.exchange_rate; END IF; END IF; EXCEPTION WHEN NO_DATA_FOUND THEN fnd_file.put_line (fnd_file.output, 'Invoice Exchange rate type is wrong for Invoice No.' || i.invoice_number ); v_status := FALSE; END; END IF; END;
12
BEGIN IF i.payment_terms IS NOT NULL and v_status = TRUE THEN BEGIN SELECT a.term_id INTO v_term_id FROM ap_terms a WHERE a.NAME = TRIM (i.payment_terms) AND a.enabled_flag = 'Y'; EXCEPTION WHEN NO_DATA_FOUND THEN fnd_file.put_line (fnd_file.output, 'Payment term is not defined in system for invoice no. ' || i.invoice_number ); v_status := FALSE; END; ELSE fnd_file.put_line (fnd_file.output, 'Payment term cannot be null for invoice no. ' || i.invoice_number ); END IF; END;
13
SELECT doc_category_code INTO v_doc_cat_code FROM fnd_doc_seq_categories_ap_v WHERE table_name IN ('AP_INVOICES', 'AP_INVOICES_ALL') AND UPPER (doc_category_code) LIKE TRIM (UPPER (i.doc_category_code)); EXCEPTION WHEN NO_DATA_FOUND THEN fnd_file.put_line (fnd_file.output, 'Doc Category Code is not defined in system for invoice no. ' || i.invoice_number ); v_status := FALSE; END; ELSE fnd_file.put_line (fnd_file.output, 'Doc Category Code cannot be null for invoice no. ' || i.invoice_number ); END IF; END;
IF j.tax_code IS NOT NULL THEN BEGIN SELECT NAME INTO v_tax_code FROM ap_tax_codes_all WHERE TRIM (NAME) = TRIM (j.tax_code) AND NVL (inactive_date, SYSDATE) >= SYSDATE AND set_of_books_id = fnd_profile.VALUE ('GL_SET_OF_BKS_ID') AND org_id = j.org_id; EXCEPTION WHEN OTHERS THEN fnd_file.put_line (fnd_file.output, 'Tax Code is wrong, Plz define tax code for invoice no. ' || i.invoice_number ); v_status := FALSE; END; END IF;
IF j.dist_account IS NOT NULL THEN BEGIN SELECT DISTINCT ood.chart_of_accounts_id INTO v_ccid FROM org_organization_definitions ood WHERE ood.operating_unit = p_org_id; EXCEPTION WHEN NO_DATA_FOUND THEN
15
fnd_file.put_line (fnd_file.output, 'Chart of account ID not found for org id : ' || j.org_id ); END; v_code_id := fnd_flex_ext.get_ccid (application_short_name => 'SQLGL', key_flex_code => 'GL#', structure_number => v_ccid, validation_date => TRUNC (SYSDATE ), concatenated_segments => j.dist_account ); --COMMIT; -- if combination is not exist; ELSE fnd_file.put_line (fnd_file.output, 'Distribution Cannot be not for invoice no. ' || i.invoice_number ); v_status := FALSE; END IF;
CONCURRENT PROGRAM:
You can run Concurrent program either through frontend by calling the Open Interface concurrent program or by backend by dynamically passing the API(Application Programming Interface)
Parameters:
Source: Choose the source of the invoices from the list of values.
16
Group: To limit the import to invoices with a particular Group ID, enter the Group ID. The Group must exactly match the GROUP_ID in the Payables Open Interface tables. Batch Name: Payables groups the invoices created from the invoices you import and creates an invoice batch with the batch name you enter. You can enter a batch name only if you have enabled the Use Batch Control Payables option, and if you have enabled the Use Batch Control Payables option, you must enter a batch name. If you use a batch name and some invoices are rejected during the import process, you can import the corrected invoices into the same batch if you enter the exact batch name during the subsequent import. Hold Name: If you want to place all invoices on hold at the time of import, enter an Invoice Hold Reason. You can define your own hold reasons in the Invoice Approvals window. Hold Reason: Payables displays the Invoice Hold Reason Description. GL Date: If you want to assign a specific GL Date to all invoices, enter a GL Date. If you do not enter a value here, the system will assign a GL Date based on the GL Date Payables option. Purge: Enter Yes if you want Payables to delete all successfully imported invoice records that match the Source and Group ID of this import. Payables does not delete any invoice data for which it has not yet created invoices. If you want to purge later, you can use the Payables Open Interface Purge Program.
STEPS:
1. Get a unique number to be used as INVOICE_ID to the invoice to be imported.
2. Create records in the Invoice Open Interface tables through SQL queries.
IF v_status = TRUE THEN BEGIN --V_RECORD_INSERTED := 1; INSERT INTO ap_invoices_interface aii (aii.invoice_id, aii.invoice_num, aii.creation_date, aii.created_by, aii.last_update_date, aii.last_updated_by, aii.invoice_type_lookup_code, aii.invoice_date, aii.vendor_id, -- AII.VENDOR_NUM,
17
-- AII.VENDOR_NAME, -- AII.VENDOR_SITE_CODE, aii.vendor_site_id, aii.invoice_amount, aii.invoice_currency_code, -- AII.PAYMENT_CURRENCY_CODE, aii.exchange_rate, aii.exchange_date, aii.exchange_rate_type, aii.terms_id, -- AII.TERMS_NAME, aii.terms_date, aii.description, aii.SOURCE, aii.org_id, aii.gl_date, aii.doc_category_code, aii.pay_group_lookup_code ) --------/*BY SARATH*/ VALUES (v_invoice_id, i.invoice_number, m_creation_date, m_created_by, m_last_updated_date, m_last_updated_by, i.invoice_type, i.invoice_date, v_vendor_id, -- '20TH CENTURY GEMS PVT LTD', -- 'JMU01', v_vendor_site_id, DECODE (i.invoice_type, 'STANDARD', i.invoice_amount, i.invoice_amount * -1 ), i.invoice_currency, --I.PAYMENT_CURRENCY, DECODE (i.exchange_rate_type, v_user_con_type, NULL, 'User', i.exchange_rate, 1 ), DECODE (i.exchange_rate, NULL, NULL, i.exchange_rate_date ), DECODE (i.exchange_rate_type, 'User', 'User', v_user_con_type, v_ext_rate_type_code, NULL ), v_term_id, -- 'Immediate', i.invoice_date, i.inv_description, -------------/*SARATH*/ --'Data Imported from Legacy System', i.SOURCE, i.org_id, i.invoice_date, i.doc_category_code, ----------/*BY SARATH*/ 'LORRYHIRE' ); EXCEPTION WHEN OTHERS THEN fnd_file.put_line (fnd_file.output, 'Error in Loading Data for invoice no.' || i.invoice_number );
18
v_status := FALSE; UPDATE sfx_ext_ap_invoice_temp_tbl xep SET xep.status_flag = 'E' WHERE xep.invoice_number = i.invoice_number AND xep.org_id = i.org_id; END; END IF; /* End of Inserting data in Ap_invoices_interface table*/ IF v_status = TRUE THEN FOR j IN cur_invoice_line (i.invoice_number, i.supplier_number, i.supp_site ) LOOP
3. Go to Payables > Invoices > Entry > Open Interface Invoices to check the details of Invoice and Invoice Lines from the front end. 4. Run the concurrent program Payables Open Interface Import to submit a request for Invoice Import.
CASE :
IF v_record_inserted > 0 THEN fnd_global.apps_initialize (user_id => fnd_profile.VALUE ('USER_ID'), resp_id => fnd_profile.VALUE ('RESP_ID'), resp_appl_id => fnd_profile.VALUE ('resp_appl_id') ); v_conc_request_id := fnd_request.submit_request ('SQLAP', 'APXIIMPT', '', '', FALSE, 'PROPEL', NULL, 'PROPEL_OPS-' || TO_CHAR (SYSDATE, 'DD-MON-YYYY'), '', -- Hold Name '', --Hold Reason '', -- GL DATE '', -- Purgae '', -- Trace Switch '', -- Debug Switch '', -- Summarize Report '', --Commit Batch Size '', --User ID '', -- Login ID '', '', '', '', '', '', '', '', '', '', '', '', '', '' ); COMMIT; IF (v_conc_request_id = 0) THEN fnd_file.put_line
20
(fnd_file.output, 'NOT Able TO Submit the Payable Interface Import Program' ); retcode := 3; erebuf := 'NOT Able TO Submit the Payable Interface Import Program'; END IF; END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line (fnd_file.output, 'Unable to insert Data');
HOW TO REGISTER STORED PROCEDURE IN APPS STEP1: Define Executable with executable file name same as of validated procedure in System Administrator Resp. (SFX_AP_INVOICE_IMPORT)
21
22
STEP 4: Define the executable with main procedure name as executable file name in System Administrator Resp. (sfx_ap_staging_dump)
23
24
STEP 7: Run the concurrent program of the main procedure in Payables Vision Operation Resp.
25
DOCUMENT SEQUENCING
1. Create sequence to generate voucher no. Define Document Sequencing Go to SYSTEM ADMINISTRATOR RESP. -> APPLICATION -> DOCUMENT -> DEFINE 2. Define Document Categories DOCUMENT -> CATEGORIES 3. Assign Document with Category Name and Sequence DOCUMENT -> ASSIGN
SEQUENTIAL NUMBERING
Go to SYSTEM ADMINISTRATOR RESP.-> PROFILE ->SYSTEM RESP: PAYABLES VISION OPERATION PROFILES: Sequential Numbering (Partially Used)
Go in PAYABLES VISION OPERATION RESP CHECK SETUP->OPTIONS-
DEFINE PAYGROUP
Go in PAYABLES VISION OPERATION RESP-> SETUP ->LOOKUP-> PURCHASING -> DEFINE PAYGROUP
26
BATCH NUMBERING
Enable the batch control sequence in the system ADMINISTRATOR RESP -> SYSTEM -> PROFILE : PAYABLE VISION OPERATION
DATABASE LINK
Create Database Link : DATABASE -> CREATE DB LINK To connect one database to other oracle database: TABLENAME@DBLINK
SOURCE SETUP
Go in PAYABLES VISION OPERATION RESP. ->SETUP ->LOOKUP ->PAYABLES Search Source Add new source in this setup.
AP_INTERFACE_REJECTIONS
27
PARENT_TABLE : Reference to table in which the rejection occurred (AP_INVOICES_INTERFACE or AP_INVOICE_LINES_INTERFACE) PARENT_ID NUMBER : Reference to invoice or invoice line identifier which was rejected (INVOICE_ID or INVOICE_LINE_ID) REJECT_LOOKUP_CODE : Invoice rejection reason Description: AP_INTERFACE_REJECTIONS stores information about invoice data from the AP_INVOICES_INTERFACE and AP_INVOICE_LINES_INTERFACE tables which could not be processed by Payables Open Interface Import.
If you use Oracle e-Commerce Gateway, you can pass information from this table to your suppliers by submitting the Payables Open Interface Outbound Advice for rejected data.
You can purge data in this table by using the Payables Open Interface Purge. Check the status of error in table:
REFERENCES
Main-Procedure
28
Main-Procedure.txt
Scott_table_creation_script
Scott_table_creation _script.txt
Staging_table_script
Staging_table_script. txt
Steps
Steps.txt
Validation Procedure
Validation Procedure.txt
29