← Back to Cases
AP Accounting Date Mismatch Correction — Sync to XLA Event Date
Case Number00080896
Oracle ModuleAccounts Payable (AP)
EBS VersionR12
Functional AreaAP Invoice Distributions / AP Invoice Payments / AP Payment History / XLA Subledger Accounting
Related PatchesNone

Symptoms

Root Cause

In Oracle R12 AP, the accounting_date on AP invoice distributions, payments, and payment history records must match the event_date on the associated XLA_EVENTS row. When these dates diverge — due to data corruption, manual adjustments, or interface issues — the AP subledger and GL show inconsistent periods. The fix re-synchronises accounting_date (and period_name where applicable) on the AP tables to match the XLA event date and period.


Resolution — Script 01: Create Driver and Backup Tables

Create driver tables identifying mismatched records, and empty backup shells

Run 01_setup_objects.sql first. All table creation statements are executed via EXECUTE IMMEDIATE with an ORA-955 (table already exists) handler to allow safe re-runs. Creates three driver tables and three backup tables:

Driver tables (created as CREATE TABLE AS SELECT):

Backup tables (created as empty shells via WHERE 1=2):

Note: The backup tables are created as empty shells by Script 01. Script 02 does not insert into these tables before performing updates — the backup tables are available for manual pre-fix population if needed but are not populated automatically by the fix script.

Resolution — Script 02: Apply Accounting Date Correction

Update accounting_date and period_name to match XLA event date

Run 02_apply_data_fix.sql after Script 01. Processes three sequential cursor loops driven by the driver tables created in Script 01. No per-record backup is performed within the fix script.

  1. c1 loop — Invoice Distributions: Iterates over all rows in RSI_AP_INV_DIST_80896. For each row, updates AP_INVOICE_DISTRIBUTIONS_ALL:
  2. c2 loop — Invoice Payments: Iterates over all rows in RSI_AP_INV_PAY_80896. For each row, updates AP_INVOICE_PAYMENTS_ALL:
  3. c3 loop — Payment History: Iterates over all rows in RSI_AP_INV_PAY_HIST_80896. For each row, updates AP_PAYMENT_HISTORY_ALL:

Transaction control: Each loop rolls back individually on error (per-record exception handling); a single COMMIT is issued at the end of the entire block after all three loops complete. No separate error table is used — errors surface via exception propagation.

Note: Script 01 must be run before Script 02 to create the driver tables. The driver tables identify all mismatched records at the time of Script 01 execution — if additional mismatches arise after Script 01 is run, Script 01 should be re-run (the ORA-955 handler drops and recreates) before applying the fix. The backup tables created by Script 01 are empty shells and must be populated manually before applying fixes if a pre-fix snapshot is required.

Script Inventory

FileDescription
01_setup_objects.sqlCreates three driver tables (RSI_AP_INV_DIST_80896, RSI_AP_INV_PAY_80896, RSI_AP_INV_PAY_HIST_80896) identifying AP records where accounting_date <> XLA event_date. Creates three empty backup shells (RSI_AP_INV_DIST_BKUP_80896, RSI_AP_INV_PAY_BKUP_80896, RSI_AP_INV_PAY_HIST_BKUP_80896). All via EXECUTE IMMEDIATE with ORA-955 handler.
02_apply_data_fix.sqlUpdates accounting_date (and period_name for distributions and payments) on AP_INVOICE_DISTRIBUTIONS_ALL, AP_INVOICE_PAYMENTS_ALL, and AP_PAYMENT_HISTORY_ALL to match the corresponding XLA_EVENTS.event_date and derived GL period. Driven by the three driver tables from Script 01. Single COMMIT at end of block.

Key Tables Affected

TableAction
AP_INVOICE_DISTRIBUTIONS_ALLUpdate accounting_date and period_name to XLA event_date and derived period
AP_INVOICE_PAYMENTS_ALLUpdate accounting_date and period_name to XLA event_date and derived period
AP_PAYMENT_HISTORY_ALLUpdate accounting_date to XLA event_date (period_name not updated)
XLA_EVENTSRead-only — source of correct event_date (joined via accounting_event_id)
GL_PERIOD_STATUSESRead-only — used to derive period_name from event_date during driver table population
RSI_AP_INV_DIST_80896Driver table — invoice distribution rows with accounting_date mismatch
RSI_AP_INV_PAY_80896Driver table — invoice payment rows with accounting_date mismatch
RSI_AP_INV_PAY_HIST_80896Driver table — payment history rows with accounting_date mismatch
RSI_AP_INV_DIST_BKUP_80896Empty backup shell for invoice distribution pre-fix values (manual population)
RSI_AP_INV_PAY_BKUP_80896Empty backup shell for invoice payment pre-fix values (manual population)
RSI_AP_INV_PAY_HIST_BKUP_80896Empty backup shell for payment history pre-fix values (manual population)