| Case Number | 00080896 |
| Oracle Module | Accounts Payable (AP) |
| EBS Version | R12 |
| Functional Area | AP Invoice Distributions / AP Invoice Payments / AP Payment History / XLA Subledger Accounting |
| Related Patches | None |
accounting_date stored on AP_INVOICE_DISTRIBUTIONS_ALL, AP_INVOICE_PAYMENTS_ALL, and/or AP_PAYMENT_HISTORY_ALL does not match the event_date on the corresponding XLA_EVENTS row (joined via accounting_event_id).period_name also differs from the period implied by the XLA event date, causing discrepancies between AP subledger reporting and the GL.XLA_EVENTS on accounting_event_id and to GL_PERIOD_STATUSES to derive the correct period name corresponding to the event date.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.
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):
RSI_AP_INV_DIST_80896 — identifies AP_INVOICE_DISTRIBUTIONS_ALL rows where accounting_date <> XLA_EVENTS.event_date. Columns: invoice_num, invoice_id, aid_accounting_date, invoice_distribution_id, aid_period_name, XE_ACCOUNTING_DATE, xe_accounting_event_id, xe_period_name. Joins: AP_INVOICE_DISTRIBUTIONS_ALL → XLA_EVENTS (via accounting_event_id) → AP_INVOICES_ALL → GL_PERIOD_STATUSES (to derive xe_period_name) → AP_SYSTEM_PARAMETERS_ALL.RSI_AP_INV_PAY_80896 — same pattern for AP_INVOICE_PAYMENTS_ALL where accounting_date <> event_date. Same column set as the distributions driver.RSI_AP_INV_PAY_HIST_80896 — same pattern for AP_PAYMENT_HISTORY_ALL where accounting_date <> event_date. Columns: payment_history_id, check_number, check_id, aph_accounting_date, XE_ACCOUNTING_DATE, xe_accounting_event_id, xe_period_name. Note: no period_name column captured for payment history (only the date is corrected in the fix script).Backup tables (created as empty shells via WHERE 1=2):
RSI_AP_INV_DIST_BKUP_80896 — columns: INVOICE_DISTRIBUTION_ID, ACCOUNTING_DATE, PERIOD_NAME.RSI_AP_INV_PAY_BKUP_80896 — columns: INVOICE_PAYMENT_ID, ACCOUNTING_DATE, PERIOD_NAME.RSI_AP_INV_PAY_HIST_BKUP_80896 — columns: payment_history_id, ACCOUNTING_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.
RSI_AP_INV_DIST_80896. For each row, updates AP_INVOICE_DISTRIBUTIONS_ALL:
accounting_date = XE_ACCOUNTING_DATEperiod_name = xe_period_nameINVOICE_DISTRIBUTION_IDRSI_AP_INV_PAY_80896. For each row, updates AP_INVOICE_PAYMENTS_ALL:
accounting_date = XE_ACCOUNTING_DATEperiod_name = xe_period_nameINVOICE_PAYMENT_IDRSI_AP_INV_PAY_HIST_80896. For each row, updates AP_PAYMENT_HISTORY_ALL:
accounting_date = XE_ACCOUNTING_DATEperiod_name is not updated for payment history rows (no period_name column was captured in the driver table for this source).payment_history_idTransaction 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.
| File | Description |
|---|---|
| 01_setup_objects.sql | Creates 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.sql | Updates 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. |
| Table | Action |
|---|---|
| AP_INVOICE_DISTRIBUTIONS_ALL | Update accounting_date and period_name to XLA event_date and derived period |
| AP_INVOICE_PAYMENTS_ALL | Update accounting_date and period_name to XLA event_date and derived period |
| AP_PAYMENT_HISTORY_ALL | Update accounting_date to XLA event_date (period_name not updated) |
| XLA_EVENTS | Read-only — source of correct event_date (joined via accounting_event_id) |
| GL_PERIOD_STATUSES | Read-only — used to derive period_name from event_date during driver table population |
| RSI_AP_INV_DIST_80896 | Driver table — invoice distribution rows with accounting_date mismatch |
| RSI_AP_INV_PAY_80896 | Driver table — invoice payment rows with accounting_date mismatch |
| RSI_AP_INV_PAY_HIST_80896 | Driver table — payment history rows with accounting_date mismatch |
| RSI_AP_INV_DIST_BKUP_80896 | Empty backup shell for invoice distribution pre-fix values (manual population) |
| RSI_AP_INV_PAY_BKUP_80896 | Empty backup shell for invoice payment pre-fix values (manual population) |
| RSI_AP_INV_PAY_HIST_BKUP_80896 | Empty backup shell for payment history pre-fix values (manual population) |