← Back to Cases
AP Invoices Stuck in Error: Frozen Tax Distributions (Missing ZX Records)
Case Number00026036
ModuleOracle Payables (AP) / Oracle eBusiness Tax (ZX)
VersionOracle E-Business Suite R12
AreaInvoice Accounting / Subledger Accounting (XLA)
Related Patches9774707, 12909730, 14082924, 16090199

Symptoms


Root Cause

A data inconsistency exists between the AP invoice distribution tables and the eBusiness Tax (ZX) tables. Records in AP_INVOICE_DISTRIBUTIONS_ALL or AP_SELF_ASSESSED_TAX_DIST_ALL have SUMMARY_TAX_LINE_ID and DETAIL_TAX_DIST_ID populated — meaning they reference tax distribution records in ZX_REC_NREC_DIST — but those corresponding records do not exist in ZX_REC_NREC_DIST. The ASSOCIATED_CHILD_FROZEN_FLAG on the associated ZX_LINES records is set to 'Y', confirming the distributions are in a frozen state.

When the Subledger Accounting (XLA) engine processes these invoices it cannot resolve the tax distribution pointers, causing accounting to fail.

Known trigger scenario (Oracle Bug 9774707): Tax distributions for Prepayment Application/Unapplication lines were generated after the parent distribution had already been stamped with an accounting event. When AP Validation was rerun, it could not stamp the new tax distribution with an accounting event because the architecture requires all prepayment application taxes to share the same event as their parent. The result is tax distributions permanently stuck in an unaccounted state.

Identification Query — finds all affected invoices across the instance

SELECT DISTINCT org_id, invoice_id, invoice_date
  FROM ap_invoices_all ai
 WHERE ai.invoice_id IN (
   -- Tax distributions in AP with no matching record in ZX
   SELECT dist.invoice_id
     FROM ap_invoice_distributions_all dist
    WHERE NVL(dist.historical_flag,'N') <> 'Y'
      AND dist.summary_tax_line_id IS NOT NULL
      AND dist.detail_tax_dist_id IS NOT NULL
      AND NOT EXISTS (
            SELECT 1 FROM zx_rec_nrec_dist zd
             WHERE zd.rec_nrec_tax_dist_id = dist.detail_tax_dist_id
               AND zd.summary_tax_line_id = dist.summary_tax_line_id)
   UNION
   -- Same check for self-assessed tax distributions
   SELECT sa_dist.invoice_id
     FROM ap_self_assessed_tax_dist_all sa_dist
    WHERE sa_dist.summary_tax_line_id IS NOT NULL
      AND sa_dist.detail_tax_dist_id IS NOT NULL
      AND NOT EXISTS (
            SELECT 1 FROM zx_rec_nrec_dist zd
             WHERE zd.rec_nrec_tax_dist_id = sa_dist.detail_tax_dist_id
               AND zd.summary_tax_line_id = sa_dist.summary_tax_line_id))
   AND ai.cancelled_date IS NULL;

Resolution

The fix is a structured, multi-step process executed from SQL*Plus against the APPS schema. A driver/logging framework is created in Step 1 so all activity is fully auditable and each invoice is processed within a SAVEPOINT, allowing per-invoice rollback on error.

Important: Always run all steps in a test instance first and verify results before applying to production.
Step 1 — Create Working Tables and Logging Framework

Run: 01_setup_tables.sql

Creates the following objects in the APPS schema:

ObjectTypePurpose
ZX_MISSING_DIST_INVOICESDriver tableHolds all affected invoice IDs with processing flags
AP_UNDO_INVOICESWork tableInvoice accounting events requiring undo
AP_UNDO_CHECKSWork tablePayment accounting events requiring undo
AP_INV_DIST_FD_BKUPBackup tablePre-fix copy of AP_INVOICE_DISTRIBUTIONS_ALL rows
AP_ASSESSED_DIST_FD_BKUPBackup tablePre-fix copy of AP_SELF_ASSESSED_TAX_DIST_ALL rows
ZX_DIST_FD_BKUPBackup tablePre-fix copy of ZX_REC_NREC_DIST rows
ZX_FD_DFIX_LOG_MESSAGESLog tableStep-by-step execution log
ZX_FD_DFIX_LOG_SEQSequenceLog sequence generator
ZX_FD_DFIX_LOGPL/SQL packageAutonomous-transaction logging procedure (CAPTURE)
Step 2 — Populate the Driver Table

Run: 02_identify_invoices.sql

Populates ZX_MISSING_DIST_INVOICES using the identification query above and sets three processing flags per invoice:

Step 3 — Determine if Undo Accounting is Required
SELECT COUNT(invoice_id)
  FROM zx_missing_dist_invoices
 WHERE posted_encumbered_flag = 'Y'
    OR payment_posted_flag = 'Y';

If result > 0, proceed to Steps 4–5. Otherwise skip to Step 6.

Step 4 — Populate Undo Work Tables

Run: 03_populate_undo_tables.sql

Populates AP_UNDO_INVOICES with accounting events for all invoices where POSTED_ENCUMBERED_FLAG = 'Y', and AP_UNDO_CHECKS with payment events where PAYMENT_POSTED_FLAG = 'Y'.

Requires PROPOSED_UNDO_DATE as input — must be a date in an open GL period to receive the reversal entries.

Before running Step 5, enable FND debug logging for the executing user:

FND: Debug Log Enabled    → Yes
FND: Debug Log Level      → Statement
FND: Debug Log Module     → %

Record MAX(LOG_SEQUENCE) from FND_LOG_MESSAGES before and after execution to extract the debug log afterward:

SELECT MAX(log_sequence) FROM fnd_log_messages;  -- capture as LOG_SEQ1 before run
                                                 -- capture as LOG_SEQ2 after run

-- Retrieve debug log:
SELECT module, message_text
  FROM fnd_log_messages
 WHERE log_sequence BETWEEN &LOG_SEQ1 AND &LOG_SEQ2
 ORDER BY log_sequence;
Step 5 — Execute Undo Accounting

Run: 04_execute_undo_accounting.sql

Accepts two input parameters:

Calls AP_ACCTG_DATA_FIX_PKG.Undo_Accounting, which creates reversal journal entries in XLA/SLA for each invoice and payment event identified in Step 4. On success the script resets POSTED_ENCUMBERED_FLAG and PAYMENT_POSTED_FLAG to 'N' in the driver table for all successfully processed invoices.

Retain the FND debug log output for audit purposes.
Step 6 — Execute the Data Fix

Run: 05_apply_data_fix.sql

Processes every invoice in the driver table where all flags are 'N' and PROCESS_FLAG = 'Y'. Each invoice is wrapped in a SAVEPOINT so a failure on one invoice rolls back only that invoice without affecting others.

For each invoice the script performs the following in sequence:

6a. Backup

Inserts pre-fix rows into the three backup tables:

6b. Delete Orphaned AP Tax Distributions

Deletes from AP_INVOICE_DISTRIBUTIONS_ALL and AP_SELF_ASSESSED_TAX_DIST_ALL all tax-type lines: REC_TAX, NONREC_TAX, TRV, TIPV, TERV.

6c. Delete Orphaned ZX Distributions

Deletes matching records from ZX_REC_NREC_DIST.

6d. Reset ITEM Distribution Tax Flag

Clears TAX_ALREADY_DISTRIBUTED_FLAG on non-reversed ITEM distributions in AP_INVOICE_DISTRIBUTIONS_ALL so tax will be redistributed on revalidation.

6e. Reset ZX_LINES Flags

On matching records in ZX_LINES:

6f. Release Holds

Deletes any DIST VARIANCE or LINE VARIANCE holds from AP_HOLDS_ALL.

6g. Mark Complete

Sets PROCESS_FLAG = 'D' in the driver table for the successfully fixed invoice.

Step 7 — Revalidate and Re-Account

Re-run AP Validation for all affected invoices. This triggers eBusiness Tax to recalculate and fully repopulate all ZX tables with correct distributions. Then re-run the Payables Accounting Process. Invoices should account successfully and transfer to GL.

Step 8 — Verify Completion
-- All PROCESS_FLAG values should = 'D'
SELECT * FROM zx_missing_dist_invoices;
SELECT * FROM ap_undo_invoices;
SELECT * FROM ap_undo_checks;
SELECT * FROM zx_fd_dfix_log_messages ORDER BY log_sequence;

Re-run the identification query from the Root Cause section — it should return zero rows.


Script Inventory

FileStepPurpose
00_identify_affected_invoices.sqlPre-checkStandalone query to identify all affected invoices before beginning the fix
01_setup_tables.sql1Creates driver, backup, and logging objects
02_identify_invoices.sql2Populates driver table; sets accounting and payment flags per invoice
03_populate_undo_tables.sql4Populates undo work tables with accounting events to be reversed
04_execute_undo_accounting.sql5Calls AP_ACCTG_DATA_FIX_PKG.Undo_Accounting to reverse prior journal entries
05_apply_data_fix.sql6Main fix — deletes orphaned tax data, resets flags, releases holds, logs all activity

Related Oracle Patches

PatchDescription
9774707Data fix for prepayment tax distributions missing accounting event after parent already stamped. Addresses the core bug that causes this condition.
12909730AP / IBY / XLA fix bundle
14082924FUN / XLA intercompany and SLA fix bundle
16090199AP / AR / FUN / XLA fix bundle