← Back to Cases
AR Transaction Archive Eligibility Correction — posting_control_id Reset to -9999
Case Number00068994
Oracle ModuleAccounts Receivable (AR)
EBS Version11i (11.5.10.2)
Functional AreaAR Transaction Archiving / Receipt History / Receivable Applications / Adjustments
Related PatchesNone

Symptoms

Root Cause

In Oracle 11i AR, the archiving mechanism uses posting_control_id = -9999 as an eligibility flag across multiple AR tables. Transactions that were closed prior to 01-JAN-1998 but were never stamped with this value — due to data migration gaps, prior incomplete archive runs, or manual posting corrections — remain ineligible for archiving. The fix directly sets posting_control_id = -9999 on all relevant AR tables after backing up the current values, enabling the standard archive program to process these transactions.

The solution is delivered in four phases with increasing scope:


Resolution — Script 01: Create Backup and Error Tables

Pre-requisite — Create backup tables and error log

Run 01_setup_objects.sql first. Creates all backup and error tables idempotently (ORA-955 handler skips creation if already present):


Resolution — Script 02: Create Driver View

Create RSI_DriverView_68994_V — archive eligibility driver

Run 02_setup_driver_table.sql to create the view RSI_DriverView_68994_V. This view identifies AR transactions eligible for archive (closed prior to 01-JAN-1998, up to 500 rows per component). It is a 7-part UNION covering:

  1. Invoice transactions — from RA_CUSTOMER_TRX_ALL joined to RA_CUSTOMER_TRX_LINES_ALL, lookups, tax, rules, and AR_DEFERRED_LINES_ALL where gl_date_closed < 01/01/1998.
  2. Transaction GL distributions — from RA_CUST_TRX_LINE_GL_DIST_ALL where account_set_flag <> 'Y' and latest_rec_flag = 'Y'.
  3. Adjustments — from AR_ADJUSTMENTS_ALL.
  4. Contingencies — from AR_LINE_CONTS_ALL.
  5. Cash receipts — from AR_CASH_RECEIPT_HISTORY_ALL joined to AR_CASH_RECEIPTS_ALL where nvl(current_record_flag,'N') = 'Y'; excludes receipts already present in AR_ARCHIVE_DETAIL.
  6. Receipt applications to invoices — from AR_RECEIVABLE_APPLICATIONS_ALL joined to AR_CASH_RECEIPTS_ALL.
  7. Credit memo applications — from AR_RECEIVABLE_APPLICATIONS_ALL joining both CM and invoice RA_CUSTOMER_TRX_ALL rows.

The view exposes trx_id and related_trx_id columns used by Phases D, E, and F to drive processing.


Resolution — Script 03: Single-Transaction Fix (Phase B)

Hardcoded fix for customer_trx_id = 110653 — validation test

Cursor selects customer_trx_id from RA_CUSTOMER_TRX_ALL where customer_trx_id = 110653 (commented alternative: trx_date < 01/01/1998). Intended as a proof-of-concept run before broader execution.

For each record:

  1. Backs up posting_control_id and customer_trx_id from RA_CUSTOMER_TRX_ALL into RSI_CUST_TRX_68994 (DUP_VAL_ON_INDEX protected).
  2. Backs up posting_control_id and customer_trx_id from RA_CUST_TRX_LINE_GL_DIST_ALL into RSI_CUST_TRX_DIST_68994.
  3. Backs up posting_control_id and receivable_application_id from AR_RECEIVABLE_APPLICATIONS_ALL (via applied_customer_trx_idcash_receipt_id subquery) into RSI_REC_APP_68994.
  4. Backs up posting_control_id and cash_receipt_history_id from AR_CASH_RECEIPT_HISTORY_ALL (same cash_receipt_id subquery) into RSI_CASH_REC_HIST_68994.
  5. Updates RA_CUSTOMER_TRX_ALL.posting_control_id = -9999.
  6. Updates RA_CUST_TRX_LINE_GL_DIST_ALL.posting_control_id = -9999.
  7. Updates AR_RECEIVABLE_APPLICATIONS_ALL.posting_control_id = -9999 (via cash_receipt_id subquery).
  8. Updates AR_CASH_RECEIPT_HISTORY_ALL.posting_control_id = -9999 (via cash_receipt_id subquery).
  9. Commits per record. Errors logged to RSI_DATAFIX_68994_ERRORS with rollback per transaction.

Note: Phase B does not update AR_ADJUSTMENTS_ALL and does not set LAST_UPDATE_DATE or LAST_UPDATED_BY audit columns.


Resolution — Script 04: Date-Filtered Batch Fix (Phase C)

Batch fix for transactions with trx_date before 01-JAN-1998 (up to 1,000 per run)

Cursor selects customer_trx_id from RA_CUSTOMER_TRX_ALL where trx_date < to_date('01/01/98','MM/DD/YY') and rownum < 1001. Processes up to 1,000 records per execution.

Logic per record is identical to Phase B: backs up and updates posting_control_id = -9999 on the same 4 tables (RA_CUSTOMER_TRX_ALL, RA_CUST_TRX_LINE_GL_DIST_ALL, AR_RECEIVABLE_APPLICATIONS_ALL, AR_CASH_RECEIPT_HISTORY_ALL). The initial cleanup block deletes from 4 backup tables (not RSI_AR_ADJUSTMENTS_68994, confirming adjustments are out of scope for Phase C). Commits per record; errors logged to RSI_DATAFIX_68994_ERRORS.


Resolution — Scripts 05–07: View-Driven Full Batch Fix (Phases D, E, F)

Full batch fix driven by RSI_DriverView_68994_V — 5-table scope with audit stamping

Cursor selects UNIQUE trx_id from the UNION of trx_id and related_trx_id columns from RSI_DriverView_68994_V, capturing both primary and related transactions identified by the driver view. Scripts 05, 06, and 07 contain identical logic and are intended for repeated execution as the driver view is refreshed between runs.

Per-record processing expands on Phase C:

  1. Backs up all 5 tables: RSI_CUST_TRX_68994, RSI_CUST_TRX_DIST_68994, RSI_AR_ADJUSTMENTS_68994, RSI_REC_APP_68994, RSI_CASH_REC_HIST_68994 (all DUP_VAL_ON_INDEX protected).
  2. Updates RA_CUSTOMER_TRX_ALL: sets POSTING_CONTROL_ID = -9999, LAST_UPDATE_DATE = TRUNC(SYSDATE), LAST_UPDATED_BY = -9999.
  3. Updates RA_CUST_TRX_LINE_GL_DIST_ALL: same 3-column update.
  4. Updates AR_ADJUSTMENTS_ALL: same 3-column update (added in Phase D — not present in Phases B and C).
  5. Updates AR_RECEIVABLE_APPLICATIONS_ALL: same 3-column update via cash_receipt_id subquery on applied_customer_trx_id.
  6. Updates AR_CASH_RECEIPT_HISTORY_ALL: same 3-column update via cash_receipt_id subquery.
  7. Commits per record. Errors logged to RSI_DATAFIX_68994_ERRORS with rollback per transaction.
Note: The correct execution sequence is: Script 01 (create tables) → Script 02 (create driver view) → Script 03 (Phase B, single-transaction validation) → Script 04 (Phase C, date-filtered batch) → Scripts 05–07 (Phases D–F, view-driven batches). Phases D, E, and F contain identical code and are run sequentially after refreshing or narrowing the driver view between executions. Phase B and C do not stamp LAST_UPDATE_DATE / LAST_UPDATED_BY on updated rows; Phase D onward adds full audit stamping with LAST_UPDATED_BY = -9999. Only Phases D–F include AR_ADJUSTMENTS_ALL in the update scope. Check RSI_DATAFIX_68994_ERRORS after each phase for per-transaction failures. The driver view excludes transactions already present in AR_ARCHIVE_DETAIL to avoid reprocessing already-archived receipts.

Script Inventory

FileDescription
01_setup_objects.sqlCreates 5 backup tables (RSI_CUST_TRX_68994, RSI_CUST_TRX_DIST_68994, RSI_REC_APP_68994, RSI_CASH_REC_HIST_68994, RSI_AR_ADJUSTMENTS_68994) with unique indexes, and error table RSI_DATAFIX_68994_ERRORS. Idempotent (ORA-955 handler). Must be run first.
02_setup_driver_table.sqlCreates view RSI_DriverView_68994_V — 7-part UNION identifying AR transactions with gl_date_closed before 01-JAN-1998 eligible for archive, across invoices, distributions, adjustments, contingencies, cash receipts, receipt applications, and CM applications. Excludes already-archived receipts (AR_ARCHIVE_DETAIL). Up to 500 rows per UNION component.
03_data_fix_phase_b.sqlPhase B: Hardcoded fix for customer_trx_id=110653. Backs up and sets posting_control_id=-9999 on RA_CUSTOMER_TRX_ALL, RA_CUST_TRX_LINE_GL_DIST_ALL, AR_RECEIVABLE_APPLICATIONS_ALL, AR_CASH_RECEIPT_HISTORY_ALL. No AR_ADJUSTMENTS_ALL. No audit stamping. Validation/test run.
04_data_fix_phase_c.sqlPhase C: Batch fix for RA_CUSTOMER_TRX_ALL rows where trx_date < 01-JAN-1998 (up to 1,000 per run). Same 4-table backup and update scope as Phase B. No audit stamping.
05_data_fix_phase_d.sqlPhase D: Full view-driven batch fix. Cursor selects distinct trx_id and related_trx_id from RSI_DriverView_68994_V. Backs up and sets posting_control_id=-9999 with LAST_UPDATE_DATE=TRUNC(SYSDATE), LAST_UPDATED_BY=-9999 on all 5 tables including AR_ADJUSTMENTS_ALL.
06_data_fix_phase_e.sqlPhase E: Identical logic to Phase D. Used for subsequent view-driven batch runs.
07_data_fix_phase_f.sqlPhase F: Identical logic to Phase D. Used for further subsequent view-driven batch runs.

Key Tables Affected

TableAction
RA_CUSTOMER_TRX_ALLUpdate posting_control_id=-9999 (all phases). Phases D–F also set LAST_UPDATE_DATE=TRUNC(SYSDATE), LAST_UPDATED_BY=-9999.
RA_CUST_TRX_LINE_GL_DIST_ALLUpdate posting_control_id=-9999 (all phases). Phases D–F also set LAST_UPDATE_DATE=TRUNC(SYSDATE), LAST_UPDATED_BY=-9999.
AR_RECEIVABLE_APPLICATIONS_ALLUpdate posting_control_id=-9999 via cash_receipt_id subquery on applied_customer_trx_id (all phases). Phases D–F also set LAST_UPDATE_DATE=TRUNC(SYSDATE), LAST_UPDATED_BY=-9999.
AR_CASH_RECEIPT_HISTORY_ALLUpdate posting_control_id=-9999 via cash_receipt_id subquery (all phases). Phases D–F also set LAST_UPDATE_DATE=TRUNC(SYSDATE), LAST_UPDATED_BY=-9999.
AR_ADJUSTMENTS_ALLUpdate posting_control_id=-9999, LAST_UPDATE_DATE, LAST_UPDATED_BY=-9999 (Phases D, E, F only).
RSI_CUST_TRX_68994Backup of posting_control_id from RA_CUSTOMER_TRX_ALL before update (all phases).
RSI_CUST_TRX_DIST_68994Backup of posting_control_id from RA_CUST_TRX_LINE_GL_DIST_ALL before update (all phases).
RSI_REC_APP_68994Backup of posting_control_id from AR_RECEIVABLE_APPLICATIONS_ALL before update (all phases).
RSI_CASH_REC_HIST_68994Backup of posting_control_id from AR_CASH_RECEIPT_HISTORY_ALL before update (all phases).
RSI_AR_ADJUSTMENTS_68994Backup of posting_control_id from AR_ADJUSTMENTS_ALL before update (Phases D–F only).
RSI_DATAFIX_68994_ERRORSError log for per-transaction processing failures across all phases.
RSI_DriverView_68994_VRead-only driver view; identifies eligible transactions for Phases D–F.