| Case Number | 00154415 |
| Oracle Module | Accounts Payable (AP) |
| EBS Version | R12 |
| Functional Area | AP Invoice Cancellation / XLA Accounting / ZX Tax / AP Distributions |
| Related Patches | None |
temp_cancelled_amount is populated but cancelled_date is NULL on AP_INVOICES_ALL, meaning the cancellation process was interrupted before completion.During an AP invoice cancellation, the process failed mid-way, leaving the invoice with temp_cancelled_amount set but cancelled_date unset. The invoice distributions, tax tables (ZX), and reversal rows were left in a mixed state. The resolution requires using the Oracle Generic Data Fix (GDF) framework to undo existing XLA accounting entries for both payments and the invoice, cleaning up all corrupt data across AP and ZX tables, correcting distribution flags, and then allowing the standard AP cancellation to be re-applied manually through the application.
Run 01_setup_driver_tables.sql first. Creates (drops and recreates) XXRSI_AP_INV_DRIVER_154415 with columns: org_id, invoice_id, invoice_num, invoice_type_lookup_code, quick_credit, process_flag (default 'Y').
The active version targets a single hardcoded invoice: l_invoice_id = 28579511. A commented-out alternative SELECT identifies the general pattern (invoices where invoice_amount = 0 AND cancelled_date IS NULL AND temp_cancelled_amount IS NOT NULL) which can be activated if multiple invoices require repair.
Run 02_apply_data_fix.sql after Script 01. Uses v_user_id = -154415 as the update sentinel. Executes the following steps in sequence:
XXRSI_AP_PAY_UNDO_TBL_154415 (check_id, accounting_event_id, proposed_undo_date = sysdate, process_flag = 'Y') by selecting from AP_PAYMENT_HISTORY_ALL where posted_flag = 'Y' for checks linked to the driver invoice. Calls AP_ACCTG_DATA_FIX_PKG.Undo_Acctg_Entries with p_bug_no='154415', p_driver_table = pay_undo_tab, p_mode='UNDO_DEL_ADJ' to reverse and delete payment accounting entries.process_flag = 'E' in the driver table for any invoice where XLA headers still remain after payment undo (joined to AP_PAYMENT_HISTORY_ALL, XLA_EVENTS, XLA_AE_HEADERS where accounting_entry_status_code <> 'U' and upg_batch_id <> -9999).XXRSI_AP_INV_UNDO_TBL_154415 (invoice_id, event_id) from posted invoice distributions and XLA_EVENTS rows with event_status_code = 'P'. Calls AP_ACCTG_DATA_FIX_PKG.Undo_Acctg_Entries to undo invoice accounting entries.process_flag = 'D' for invoices where no posted or encumbered distributions remain; sets 'E' for others.CREATE TABLE AS SELECT:
XXRSI_AP_INV_DIST_154415 — from AP_INVOICE_DISTRIBUTIONS_ALLXXRSI_AP_HOLDS_154415 — from AP_HOLDS_ALLXXRSI_AP_INV_LINES_154415 — from AP_INVOICE_LINES_ALLXXRSI_AP_TAX_DIST_154415 — from AP_SELF_ASSESSED_TAX_DIST_ALLXXRSI_ZX_LINES_154415 — from ZX_LINESXXRSI_ZX_LINE_SUM_154415 — from ZX_LINES_SUMMARYXXRSI_ZX_REC_DIST_154415 — from ZX_REC_NREC_DISTXXRSI_ZX_DET_FACTORS_154415 — from ZX_LINES_DET_FACTORSZX_LINES_SUMMARY, ZX_REC_NREC_DIST, ZX_LINES, ZX_LINES_DET_FACTORS, and AP_SELF_ASSESSED_TAX_DIST_ALL for the affected invoice.reversal_flag = 'Y', parent_reversal_id IS NOT NULL) where amount does not match the parent or the parent row is missing. Then deletes remaining duplicate AWT reversal rows.line_type_lookup_code IN ('REC_TAX','NONREC_TAX','TIPV','TERV','TRV'). Then deletes 'IPV' and 'ERV' type distributions.AP_INVOICES_ALL setting exchange_rate = 1, exchange_rate_type = 'User' for invoices with NO RATE holds.AP_INVOICE_LINES_ALL rows with no remaining distributions.discarded_flag = NULL for PREPAY lines.amount to the sum of its distributions.cancelled_flag and discarded_flag for non-zero ITEM, FREIGHT, MISCELLANEOUS, and AWT lines.AP_INVOICES_ALL setting total_tax_amount = 0 for affected invoices.AP_INVOICE_DISTRIBUTIONS_ALL setting reversal_flag = 'N' and cancellation_flag = 'N' for non-discarded, non-cancelled lines that are not parent reversal rows.amount = -original.amount and base_amount = -original.base_amount.match_status_flag = 'N' via dynamic SQL for affected distributions.process_flag = 'P' in the driver table for processed invoices; commits.Script 03_cancel_invoice_fix.sql is a supplemental script from a related engagement (Case 88203) included with this case folder. It addresses a different problem: incorrect code_combination_id values on AP_LIABILITY_BALANCE and AP_AE_LINES_ALL rows for AP invoices.
Uses a pre-populated driver table RSI_AP_BAL_TMP_88203:
v_new_ccid from the credit row (inv_credit <> 0) in RSI_AP_BAL_TMP_88203.AP_LIABILITY_BALANCE to AP_AE_LINES_ALL for the invoice where code_combination_id <> v_new_ccid and LAST_UPDATED_BY <> -88203 (not already fixed).RSI_AP_AE_LINES_88203 and RSI_AP_LIA_BALANCE_88203.AP_LIABILITY_BALANCE.CODE_COMBINATION_ID = v_new_ccid.AP_AE_LINES_ALL.CODE_COMBINATION_ID = v_new_ccid.l_gl_transfer flag — currently set to FALSE): inserts correcting journal entries to GL_INTERFACE using RSI_DATAFIX_SEQ_ID_S.NEXTVAL and set_of_books_id=687.RSI_AP_TB_RECON_88203; tracks processing in RSI_DATAFIX_CONTROL_88203.RSI_AP_BAL_TMP_88203 must be pre-populated with the liability balance analysis before running Script 03. The GL_INTERFACE insertion path is inactive (l_gl_transfer = FALSE) and would require a code change to enable.
| File | Description |
|---|---|
| 01_setup_driver_tables.sql | Drops and recreates XXRSI_AP_INV_DRIVER_154415 for the target invoice (hardcoded invoice_id=28579511). Contains commented-out general pattern for invoices with invoice_amount=0, cancelled_date IS NULL, temp_cancelled_amount IS NOT NULL. |
| 02_apply_data_fix.sql | Main repair script: undoes payment and invoice XLA accounting via AP_ACCTG_DATA_FIX_PKG.Undo_Acctg_Entries (UNDO_DEL_ADJ mode); creates 8 backup tables; deletes ZX tax rows; removes invalid AWT/tax distributions; corrects invoice line amounts and flags; resets reversal and match flags. Requires manual re-cancellation through AP UI after script completes. |
| 03_cancel_invoice_fix.sql | Supplemental script from Case 88203: corrects incorrect code_combination_id on AP_LIABILITY_BALANCE and AP_AE_LINES_ALL for invoices with multiple liability balance entries. Driven by pre-populated RSI_AP_BAL_TMP_88203. GL_INTERFACE correction path inactive (l_gl_transfer=FALSE). |
| Table | Action |
|---|---|
| XLA_AE_HEADERS / XLA_AE_LINES / XLA_EVENTS | Accounting entries deleted/reversed via AP_ACCTG_DATA_FIX_PKG.Undo_Acctg_Entries for both payment and invoice events (Script 02) |
| AP_INVOICE_DISTRIBUTIONS_ALL | Delete tax/IPV/ERV/invalid AWT distributions; correct reversal_flag, cancellation_flag, match_status_flag (Script 02); backed up to XXRSI_AP_INV_DIST_154415 |
| AP_INVOICE_LINES_ALL | Delete lines with no distributions; correct amount, cancelled_flag, discarded_flag (Script 02); backed up to XXRSI_AP_INV_LINES_154415 |
| AP_INVOICES_ALL | Update exchange_rate, total_tax_amount; process_flag updated in driver (Script 02) |
| AP_HOLDS_ALL | Backed up to XXRSI_AP_HOLDS_154415 (Script 02) |
| ZX_LINES | Delete tax lines for affected invoice (Script 02); backed up to XXRSI_ZX_LINES_154415 |
| ZX_LINES_SUMMARY | Delete tax summary rows (Script 02); backed up to XXRSI_ZX_LINE_SUM_154415 |
| ZX_REC_NREC_DIST | Delete recoverable/non-recoverable tax distributions (Script 02); backed up to XXRSI_ZX_REC_DIST_154415 |
| ZX_LINES_DET_FACTORS | Delete tax determination factor rows (Script 02); backed up to XXRSI_ZX_DET_FACTORS_154415 |
| AP_SELF_ASSESSED_TAX_DIST_ALL | Delete self-assessed tax distributions (Script 02); backed up to XXRSI_AP_TAX_DIST_154415 |
| AP_LIABILITY_BALANCE | Update CODE_COMBINATION_ID to corrected CCID (Script 03 — Case 88203 supplemental) |
| AP_AE_LINES_ALL | Update CODE_COMBINATION_ID to corrected CCID (Script 03 — Case 88203 supplemental) |