← Back to Cases
AP Invoice Stuck with DIST VARIANCE and LINE VARIANCE Holds
Case Number00030933
Oracle ModuleAccounts Payable (AP) / eBusiness Tax (ZX)
EBS VersionR12
Functional AreaInvoice Validation / Tax Processing / Holds
Related PatchesNone

Symptoms

Root Cause

A failed or partial accounting run created an orphaned XLA event linked to specific AP invoice distributions. The associated ZX tax records (ZX_REC_NREC_DIST, ZX_LINES, ZX_LINES_SUMMARY, ZX_LINES_DET_FACTORS) and AP invoice lines/distributions retained stale data from the failed event. The line-level amount mismatches caused repeated DIST VARIANCE and LINE VARIANCE holds on validation. The fix removes the orphaned event and tax data, corrects line amounts, and releases the holds.

Identification

Query to identify the orphaned accounting event and affected distributions:

SELECT aid.invoice_id, aid.accounting_event_id, aid.invoice_distribution_id
  FROM ap_invoice_distributions_all aid
 WHERE aid.accounting_event_id = <event_id>
 UNION
SELECT ah.invoice_id, ah.hold_lookup_code, ah.status_flag
  FROM ap_holds_all ah
 WHERE ah.invoice_id = <invoice_id>
   AND ah.hold_lookup_code IN ('DIST VARIANCE','LINE VARIANCE')
   AND NVL(ah.status_flag,'x') <> 'R';

Resolution

Step 1 – Create backup tables

Run data_fix.sql. The following backup tables are created automatically:

Step 2 – Delete orphaned XLA event

Delete the orphaned row from XLA_EVENTS by the affected event ID.

Step 3 – Delete orphaned ZX records

Delete in order: ZX_REC_NREC_DISTZX_LINESZX_LINES_SUMMARYZX_LINES_DET_FACTORS, filtering on the affected invoice and event combination.

Step 4 – Delete orphaned AP distributions and lines

Delete from AP_INVOICE_DISTRIBUTIONS_ALL for the orphaned accounting event. Delete from AP_INVOICE_LINES_ALL for the affected line numbers.

Step 5 – Correct invoice line amounts and flags

Update AP_INVOICE_LINES_ALL to set correct amounts and clear discarded_flag/cancelled_flag for remaining lines.

Step 6 – Release variance holds

Update AP_HOLDS_ALL to set release_lookup_code = 'VARIANCE OVERRIDE' and status_flag = 'R' for all DIST VARIANCE and LINE VARIANCE holds on the affected invoice.

Step 7 – Commit and revalidate

Issue COMMIT. Re-run AP Invoice Validation to confirm the invoice passes without holds.

Note: The script includes commented-out DROP TABLE statements at the top for use if re-running in a second environment. Run the corresponding restoration script before re-running in any environment where the data fix was previously applied.

Script Inventory

FileDescription
data_fix.sqlCreates backup tables; deletes orphaned XLA event, ZX tax records, AP distributions, and invoice lines; corrects line amounts and flags; releases DIST VARIANCE and LINE VARIANCE holds.

Key Tables Affected

TableAction
XLA_EVENTSDelete orphaned event
ZX_REC_NREC_DISTDelete orphaned records
ZX_LINESDelete orphaned records
ZX_LINES_SUMMARYDelete orphaned records
ZX_LINES_DET_FACTORSDelete orphaned records
AP_INVOICE_DISTRIBUTIONS_ALLDelete for orphaned event
AP_INVOICE_LINES_ALLDelete affected lines; correct amounts and flags
AP_HOLDS_ALLRelease DIST VARIANCE and LINE VARIANCE holds