← Back to Cases
AP XLA Subledger GL Transfer Re-processing — Delete Orphaned Accounting Entries and Reset for Re-transfer
Case Number00166693
Oracle ModuleAccounts Payable (AP) / Subledger Accounting (XLA)
EBS VersionR12
Functional AreaXLA Subledger Accounting / GL Transfer / AP Invoice Distributions / AP Liability Balance
Related PatchesNone

Symptoms

Root Cause

The XLA accounting entry creation and GL transfer process completed for a set of AP invoice headers but the corresponding GL_IMPORT_REFERENCES rows (which link XLA subledger lines to GL journal lines) were never created — or were deleted after transfer. The headers are stuck in a state that prevents normal re-transfer. The resolution is to delete the orphaned XLA accounting structures (headers, lines, and distribution links), reset the associated XLA events to unprocessed, and reset the AP invoice distributions to unposted so the full Create Accounting → Transfer to GL sequence can be repeated.


Resolution — Script 01: Driver Table Setup (Case 158080 — Supplemental)

Driver table creation for AP Liability Balance CCID correction (filed from Case 158080)

Script 01_setup_driver_tables.sql is labeled for Case 158080 and addresses a related but separate AP Liability Balance CCID problem included with this engagement. It uses EXECUTE IMMEDIATE to create a driver table named RSI_AP_DRIVER_TABLE_158080.

Code defect note: The EXECUTE IMMEDIATE statement for creating RSI_AP_DRIVER_TABLE_158080 contains only a bare SELECT statement rather than a CREATE TABLE AS SELECT statement. As written, the dynamic SQL executes a query and discards the result set — it does not create the table. The SELECT identifies XLA_AE_HEADERS rows (application_id=200, AP_INVOICES entity, February 2019, ledger_id=7244, gl_transfer_status_code='Y', accounting_entry_status_code='F') that have a gl_sl_link_id but no corresponding GL_IMPORT_REFERENCES entry, grouped by invoice_id, event_id, ae_header_id, ledger_id, period_name, group_id, and account. The table must be created manually by prepending CREATE TABLE RSI_AP_DRIVER_TABLE_158080 AS to the SELECT before execution.

Resolution — Script 02: AP Liability Balance CCID Fix (Case 158080 — Supplemental)

Correct code_combination_id on AP_LIABILITY_BALANCE and AP_AE_LINES_ALL (Case 158080)

Script 02_apply_data_fix.sql is also labeled for Case 158080 and corrects incorrect code_combination_id values on AP_LIABILITY_BALANCE and AP_AE_LINES_ALL. Logic is identical to the Case 88203 liability balance fix pattern:

  1. Selects invoices with 2+ liability balance entries from pre-populated driver table RSI_AP_DRIVER_TABLE_158080.
  2. For each invoice: retrieves the correct CCID from the credit row (inv_credit <> 0) in the driver.
  3. Joins AP_LIABILITY_BALANCE to AP_AE_LINES_ALL where code_combination_id <> v_new_ccid and LAST_UPDATED_BY <> -158080.
  4. Backs up rows to RSI_AP_AE_LINES_158080 and RSI_AP_LIA_BALANCE_158080.
  5. Updates AP_LIABILITY_BALANCE.CODE_COMBINATION_ID and AP_AE_LINES_ALL.CODE_COMBINATION_ID to the correct value.
  6. Optional GL_INTERFACE journal entry insertion (controlled by l_gl_transfer flag — currently FALSE). Uses RSI_GL_INTERFACE_158080 as the GL interface staging table.
  7. Logs errors to RSI_AP_TB_RECON_158080.

Resolution — Script 03: Operational XLA Re-processing Fix

Delete orphaned XLA accounting entries and reset for GL re-transfer

Script 03_supplemental_fix.sql is the primary operational fix for Case 00166693. It is plain SQL (no PL/SQL wrapper) and executes the following steps:

  1. Create Driver Table:
    CREATE TABLE rsi_ap_driver_table_166693A AS
    SELECT ... FROM XLA_AE_HEADERS xah
    JOIN XLA_TRANSACTION_ENTITIES xte ON ...
    WHERE xah.application_id = 200
      AND xte.entity_code = 'AP_INVOICES'
      AND xah.period_name LIKE '%FEB-19%'
      AND xah.ledger_id = 7244
      AND xah.gl_transfer_status_code = 'Y'
      AND xah.accounting_entry_status_code = 'F'
      AND NOT EXISTS (SELECT 1 FROM GL_IMPORT_REFERENCES gir
                      WHERE gir.gl_sl_link_id = xah.gl_sl_link_id)
    GROUP BY invoice_id, event_id, ae_header_id, ledger_id,
             period_name, group_id, account
    Creates three indexes on the driver: RSI_AP_DRIVER_IDX1_166693 (INVOICE_ID), RSI_AP_DRIVER_IDX2_166693 (EVENT_ID), RSI_AP_DRIVER_IDX3_166693 (AE_HEADER_ID).
  2. Create Backup Tables: Five snapshot backups before any changes:
  3. Delete XLA Accounting Structures: Removes the orphaned accounting rows keyed by AE_HEADER_ID from the driver:
  4. Reset XLA Events:
    UPDATE XLA_EVENTS
    SET event_status_code = 'U',
        process_status_code = 'U'
    WHERE event_id IN (SELECT event_id FROM rsi_ap_driver_table_166693A)
    Resets affected events to unprocessed so Create Accounting can re-run.
  5. Reset AP Invoice Distributions:
    UPDATE AP_INVOICE_DISTRIBUTIONS_ALL
    SET POSTED_FLAG = 'N',
        ACCRUAL_POSTED_FLAG = 'N'
    WHERE invoice_id IN (SELECT invoice_id FROM rsi_ap_driver_table_166693A)
    Resets distributions to unposted so the GL transfer can re-process them.
  6. COMMIT.

After Script 03 completes, the standard AP Create Accounting concurrent program and Transfer Journal Entries to GL process can be re-run for the affected invoices.

Note: Scripts 01 and 02 are supplemental Case 158080 scripts included with this engagement — they address a separate AP Liability Balance CCID problem and are not the primary fix for Case 00166693. Script 03 is the operational fix. Script 01 contains a code defect (bare SELECT inside EXECUTE IMMEDIATE instead of CREATE TABLE AS SELECT) — the table must be created manually. The driver table in Script 03 (rsi_ap_driver_table_166693A) is specific to February 2019 transactions on ledger_id=7244; adjust the period and ledger filters for different engagements.

Script Inventory

FileDescription
01_setup_driver_tables.sqlCase 158080 supplemental: Attempts to create RSI_AP_DRIVER_TABLE_158080 via EXECUTE IMMEDIATE. Contains code defect — the dynamic SQL is a bare SELECT (not CREATE TABLE AS SELECT) and will not create the table as written. The SELECT identifies XLA_AE_HEADERS for AP invoices in Feb 2019 on ledger 7244 with gl_transfer_status_code='Y' but no GL_IMPORT_REFERENCES match.
02_apply_data_fix.sqlCase 158080 supplemental: Corrects incorrect code_combination_id on AP_LIABILITY_BALANCE and AP_AE_LINES_ALL for invoices with multiple liability balance entries. Driven by RSI_AP_DRIVER_TABLE_158080. Backs up to RSI_AP_AE_LINES_158080 and RSI_AP_LIA_BALANCE_158080. GL_INTERFACE path inactive (l_gl_transfer=FALSE).
03_supplemental_fix.sqlPrimary operational fix for Case 00166693: creates driver table rsi_ap_driver_table_166693A (Feb 2019, ledger_id=7244, AP invoices with XLA headers flagged as transferred but missing GL_IMPORT_REFERENCES); creates 5 backup tables; deletes XLA_AE_HEADERS, XLA_AE_LINES, XLA_DISTRIBUTION_LINKS; resets XLA_EVENTS to event_status_code='U'; resets AP_INVOICE_DISTRIBUTIONS_ALL POSTED_FLAG='N'. Enables re-run of Create Accounting and Transfer to GL.

Key Tables Affected

TableAction
XLA_AE_HEADERSDelete orphaned accounting headers with no GL_IMPORT_REFERENCES (Script 03); backed up to rsi_xla_headers_166693A
XLA_AE_LINESDelete accounting lines for orphaned headers (Script 03); backed up to rsi_xla_lines_166693A
XLA_DISTRIBUTION_LINKSDelete distribution links for orphaned headers (Script 03); backed up to rsi_xla_dist_links_166693A
XLA_EVENTSReset event_status_code='U', process_status_code='U' for affected events (Script 03); backed up to rsi_xla_events_166693A
AP_INVOICE_DISTRIBUTIONS_ALLReset POSTED_FLAG='N', ACCRUAL_POSTED_FLAG='N' (Script 03); backed up to rsi_ap_inv_dist__166693A
GL_IMPORT_REFERENCESRead-only — used in driver query to identify orphaned headers with no GL journal link
AP_LIABILITY_BALANCEUpdate CODE_COMBINATION_ID (Script 02 — Case 158080 supplemental); backed up to RSI_AP_LIA_BALANCE_158080
AP_AE_LINES_ALLUpdate CODE_COMBINATION_ID (Script 02 — Case 158080 supplemental); backed up to RSI_AP_AE_LINES_158080
rsi_ap_driver_table_166693ADriver table — AP invoice XLA headers with gl_transfer_status_code='Y' but missing GL_IMPORT_REFERENCES (Feb 2019, ledger_id=7244)