Vous êtes sur la page 1sur 10

9/4/2017 Document Display

How do you undo accounting in R12? (Doc ID 753695.1)

In this Document

Goal
Solution
References

APPLIES TO:

Oracle Payables - Version 12.0.0 to 12.2.4 [Release 12.0 to 12.2]


Information in this document applies to any platform.

GOAL

The purpose of this document is to explain how the undo data fix works and how to trouble shoot when it doesn't.

SOLUTION

IMPORTANT: The undo data fix should only be run when called by a Generic Data Fix or by instruction from Oracle
Support/Development. The undo data fix is NOT intended to be used by customers to fix user errors (i.e., user entry or
coding error, setup changes, etc) as it is out of scope for Support and development. See Doc Id 468481.1 Oracle Support's
Data Fix Policy For Accounts Payable Product(s).

R12 does not have any standard functionality to undo accounting. If you find accounting that is incorrect due to a bug, a datafix
bug will need to be logged or a Generic Data fix patch will need to be applied, to provide you a script to undo accounting.

How undo in R12 works

====================================

If the accounting is transferred, the procedure will create a manual entry with a NEW event id that reverses the original entry,
change the original entry to a manual entry with a NEW event id, reset the status of the original event to unprocessed and also
reset the posted flags for transactions assigned the original event id. The original event id, the reversed event id and the new
event id are stored in the backup table created , namely AP_undo_event_log. If the accounting is NOT transferred, the
procedure will delete the accounting and reset the original event to be accounted again, but it will not create a reversing
entry.

Example of undo for transferred accounting:

Before Undo
=========

1 Event:

Event_id = 123456, Event Type = Invoice Validated, Event Status = P

After Undo
=========

3 Events:

Event_id = 123456, Event Type = Invoice Validated, Event Status = U -- The original event id remains associated with the
transaction data and the accounting status is reset to allow the new/corrected accounting to be created.

https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 1/10
9/4/2017 Document Display
Event_id = 234567, Event Type = Manual, Event Status = P -- New event id created for the reversal of the original accounting
header and lines.

Event_id = 234568, Event Type = Manual, Event Status = P -- New event id assigned to the original accounting header and
lines.

Behavior of undo GL date for Single and Bulk Undo


====================================

The undo in R12 is completed by compiling the AP_ACCTG_DATA_FIX_PKG package and calling the single transaction or bulk
undo procedure.

1.Single Transaction Undo accounting API

AP_ACCTG_DATA_FIX_PKG.Undo_Accounting(l_source_table, l_source_id, l_event_id, p_calling_sequence, l_bug_Id,


l_gl_date);

Priority 1 : Use transaction Accounting Date, if it is in open period. Irrespective of p_gl_date parameter passed or not. If
transaction Accounting Date is in closed period then Priority 2.

Priority 2 :

Case A: p_gl_date, if this parameter is passed to API use p_gl_date, if p_gl_date is in open period. If p_gl_date is not in open
period undo API return with Error message.

Case B: p_gl_date, if this parameter is NOT passed to API, Undo api calculates Oldest open accounting date.

If no open period available, use transaction accounting date even though it is in closed period, so that XLA API will throw error.

2. Bulk Undo Accounting undo_acctg_entries()

AP_ACCTG_DATA_FIX_PKG.undo_acctg_entries
(p_bug_no => l_bug_no,
p_driver_table => l_driver_table,
p_calling_sequence => l_calling_sequence
);

Case 1: proposed_undo_date value is present in driver table. Undo API just checks as proposed_undo_date is in open period
or not. Use proposed_undo_date, if it is in open period. If proposed_undo_date values falls under closed period, undo
accounting script will fail, it will NOT take open period accounting date or sysdate or transaction accounting date automatically.

Case 2: proposed_undo_date value is NOT present or NULL in driver table

Priority 1 : Use transaction accounting date, if it in open period.

Priotity 2 : Use SYSDATE, if transaction accounting date is in closed period and SYSDATE is in open period. Any other case
return error.

Case 3: To add proposed_undo_date value in driver table if column proposed_undo_date is not present in driver table

Step 1: Run the GDF select file


Step 2: Alter the driver table and add a PROPOSED_UNDO_DATE
ALTER TABLE driver_table_name
ADD (PROPOSED_UNDO_DATE DATE);
Step 3: Populate the column with the date on which undo needs to be done
Step 4: Run the GDF fix file.

IMPORTANT: Undo accounting can affect the Trial Balance report and reconciling Payables to GL. Please see Note
605707.1 "UNDERSTANDING HOW UNDO ACCOUNTING CAN IMPACT RECONCILIATION" for more information on how
manual entries created by the undo fix can affect reconciliation. Undo also impacts drill down. Of the 3 events that exist
after the undo, only the accounting for the event that is still attached to the transaction will allow drill down from GL back to
the original transaction.
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 2/10
9/4/2017 Document Display

SAMPLE instructions for running the undo outside of a Generic Data Fix patch

====================================
1. Please download and compile apgdfals.pls and apgdfalb.pls

Or

For R12.0:

Please download and apply the latest consolidated checkin for undo - Patch 19586537 to get the latest Generic Datafix Package
with the latest undo accounting code.

For R12.1:

Please download and apply patch 24451262:R12.AP.B to get the latest data fix package files (apgdfals.pls and apgdfalb.pls)
with the latest undo accounting code. And if AP_ACCTG_DATA_FIX_PKG Package Body Invalid, see Doc Id 1335220.1 for
additional patches.

For R12.2:

Please download and apply patch 25352371:R12.AP.C to get the latest data fix package files (apgdfals.pls and apgdfalb.pls)
with the latest undo accounting code.

Note: The instance does not need to be brought down to apply this patch, you can apply it in hotpatch mode e.g. adpatch
option=hotpatch

2. Run ap_undo_acctg.sql** with the following parameters***:

P_EVENT_ID -- This can be null if all of the events related to an invoice or payment are to be unaccounted.
P_SOURCE_TABLE -- AP_INVOICES or AP_PAYMENTS
P_SOURCE_ID -- The invoice id or check id to be unaccounted.
P_BUG_ID -- The bug number under which the fix was provided. This is logged in the AP_undo_event_log table so we
can keep track of which bugs are responsible for the undo of which events.
GL_DATE -- If transaction is in closed period, then enter GL date to which it has to be swept. Format like 01-APR-2009.
If left blank the GL Date will default to the latest Open Period.
L_USER_NAME**** -- Your user name (case insensitive)
L_RESP_NAME ****-- Responsibility Name(Case Sensitive)

**Actual script name may vary e.g. ap_undo_payments.sql for payments, ap_undo_prepay.sql for prepayments,
ap_undo_act_encumb_acctg.sql for encumbrance

***The parameters may vary by script also

****Make sure you are using a responsibility name and user name for a payables responsibility and associated user
that have access to run accounting for the subject transaction.

3. Run the Transfer Journal Entries to GL process to transfer the reversing entries. The reversing entries created by the undo
are not automatically transferred. You MUST run the Transfer Journal Entries to GL program after you run any data fix that
uses the undo fix. And you must run with Process Category parameter = Blank or 'Manual' to pick up the reversing entries.

4. Run Create Accounting process to create the new/corrected accounting.

5. If the undo included transferred accounting, please follow the instructions in Note 553484.1 to rebuild the Trial Balance.
This step will remove the old/undone accounting from the xla_trial_balances table and from the Trial Balance report. This step
is only applicable if you have XLA_DATAFIXES_PUB package (xlajedfp.pkb) lower than R12.0.x version 120.1.12000000.5 or
R12.1.x version 120.1.12010000.4 The later versions of that code calls the delete_tb_entries procedued to delete the
xla_trial_balances data. The consolidated checkin for undo patch 14082924 includes the needed version to avoid the rebuild
after undo.

Note: This is just one example of how the instructions for the undo script may be presented in a data fix bug. Please make
sure you follow the instruction from the bug/SR and only use this note as a reference.
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 3/10
9/4/2017 Document Display

Queries to review and compare the incorrect, reversal, and corrected entries:

(If the ap_undo_event_log table is populated)

Note: The scripts provided below use the bug number the undo was ran for to return results. If
the undo script ran did not pass a bug number or you want to see the related entries for a specific
check_id, invoice_id, the original event_id, etc... change the where bug_id = &bug_number condition
to where invoice_id = &invoice, where check_id = &check_id, where event_id = &event_id.

1. Query the events updated/created by the undo script

select event_id original_event_id , e2 reversal_event_id,


e3 event_id_related_to_orig_acctg,
decode(status, 'S', 'success', 'U', 'unhandled exception', status) status,
invoice_id, check_id, bug_id
from AP_undo_event_log
where bug_id = &bug_number;

2. Query for original/incorrect accounting

select distinct xeh.event_id, xeh.ledger_id,


xel.*
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e3 = xeh.event_id
and undo.bug_id = &bug_number
order by xeh.event_id, xeh.ledger_id;

select xeh.ledger_id,
sum(xel.accounted_dr), sum(xel.accounted_cr),
count(distinct xeh.ae_header_id), count(distinct xel.ae_header_id||xel.ae_line_num), count(*)
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e3 = xeh.event_id
and undo.bug_id = &bug_number
group by xeh.ledger_id;

3. Query for original/incorrect reversal accounting

select distinct xeh.event_id, xeh.ledger_id,


xel.*
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e2 = xeh.event_id
and undo.bug_id = &bug_number
order by xeh.event_id, xeh.ledger_id;

select xeh.ledger_id,
sum(xel.accounted_dr), sum(xel.accounted_cr),
count(distinct xeh.ae_header_id), count(distinct xel.ae_header_id||xel.ae_line_num), count(*)
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.e2 = xeh.event_id
and undo.bug_id = &bug_number
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 4/10
9/4/2017 Document Display
group by xeh.ledger_id;

4. Query for New/correct accounting

select distinct xeh.event_id, xeh.ledger_id,


xel.*
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.event_id = xeh.event_id
and undo.bug_id = &bug_number
order by xeh.event_id, xeh.ledger_id;

select xeh.ledger_id,
sum(xel.accounted_dr), sum(xel.accounted_cr),
count(distinct xeh.ae_header_id), count(distinct xel.ae_header_id||xel.ae_line_num), count(*)
from xla_ae_lines xel, xla_ae_headers xeh,
ap_undo_event_log undo
where xeh.application_id = 200
and xel.ae_header_id = xeh.ae_header_id
and undo.event_id = xeh.event_id
and undo.bug_id = &bug_number
group by xeh.ledger_id;

(If the ap_undo_event_log table is NOT populated)

Invoices

select distinct xte2.*


from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.*
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
)
order by 1;

select *
from xla_events
where application_id = 200
and entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)

https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 5/10
9/4/2017 Document Display
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
))
order by event_id;

select *
from xla_ae_headers
where application_id = 200
and event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
)))
order by ae_header_id;

select *
from xla_ae_lines
where application_id = 200
and ae_header_id in (
select xeh.ae_header_id
from xla_ae_headers xeh
where xeh.application_id = 200
and xeh.event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (
(xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&invoice_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 6/10
9/4/2017 Document Display
(xte2.entity_code = 'AP_INVOICES' and xte2.source_id_int_1 = &&invoice_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&invoice_id)
))))
order by ae_header_id;

Payments

select distinct xte2.*


from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.*
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
)
order by 1;

select *
from xla_events
where application_id = 200
and entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
))
order by event_id;

select *
from xla_ae_headers
where application_id = 200
and event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.entity_id
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 7/10
9/4/2017 Document Display
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
)))
order by ae_header_id;

select *
from xla_ae_lines
where application_id = 200
and ae_header_id in (
select xeh.ae_header_id
from xla_ae_headers xeh
where xeh.application_id = 200
and xeh.event_id in (
select xe.event_id
from xla_events xe
where xe.application_id = 200
and xe.entity_id in (
select distinct xte2.entity_id
from xla.xla_transaction_entities xte,
xla.xla_transaction_entities xte2
where xte.application_id = 200
and xte2.application_id = 200
and (xte.entity_code = 'MANUAL' and xte.source_id_int_1 = &&check_id
and xte2.entity_code = 'MANUAL' and xte2.entity_id = xte.entity_id-1)
UNION
select distinct xte2.entity_id
from xla.xla_transaction_entities xte2
where xte2.application_id = 200
and (
(xte2.entity_code = 'AP_PAYMENTS' and xte2.source_id_int_1 = &&check_id)
OR
(xte2.entity_code = 'MANUAL' and xte2.source_id_int_1 = &&check_id)
))))
order by ae_header_id;

Troubleshooting ap_undo_acctg.sql

1. Make sure you are using a responsibility name and user name for a payables responsibility and associated user that have
access to run accounting for the subject transaction.

2. If the event undone is in a closed period, make sure the GL Date entered or the default date corresponds with an open
period in AP and GL. Use the following query to verify the AP and GL Periods are open:

select *
from gl_period_statuses
where application_id in (101,200)
and ledger_id = &ledger_id
order by start_date desc;

3. Make sure the account numbers corresponding to the event to be undone are valid account numbers.

Please run the following query to get the ccid for the accounts:

SELECT code_combination_id CCID


FROM gl_code_combinations
WHERE segment1 = '&segment1'
AND segment2 = '&segment2'
https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 8/10
9/4/2017 Document Display
AND segment3 = '&segment3'
AND segment4 = '&segment4'
AND segment5 = '&segment5' ;

Then run the following to verify the ccids are valid:

select gcc.code_combination_id, gcc.chart_of_accounts_id, detail_posting_allowed_flag,


detail_budgeting_allowed_flag, account_type, enabled_flag, summary_flag,
start_date_active, end_date_active,
substr(fnd_flex_ext.get_segs('SQLGL','GL#', gsob.chart_of_accounts_id,
gcc.code_combination_id),1,35) account
from gl_code_combinations gcc,
gl_sets_of_books gsob
where gsob.set_of_books_id = 1
and gsob.chart_of_accounts_id = gcc.chart_of_accounts_id
and gcc.code_combination_id in (&ccid);

4. Check the Undo package version

select *
from dba_source
where line = 2
and name = 'AP_ACCTG_DATA_FIX_PKG';

5. Get the FND Debug log for the ap_undo_acctg.sql script.

5.1. Navigate Responsibility: System Administrator > Profile > System > Query

User: Enter the username the script will be ran for (L_USER_NAME)
Profile: FND:%Debug%

Set the following Profile values at the user level

FND: Debug Log Enabled = Yes


FND: Debug Log Level = Statement
FND: Debug Log Module = %

Save.

5.2. Open NEW SQL*PLUS session and set the application context from SQL*PLUS:

Note: Make sure you open NEW SQL*PLUS session AFTER enabling FND Debug profiles in the application.

exec fnd_global.apps_initialize(<user_id>,<resp_id>,200);

Use the following SQL to get the user_id and resp_id:

SELECT user_id
FROM fnd_user
WHERE user_name= upper('&USER_NAME');

SELECT responsibility_id,application_id
FROM fnd_responsibility_tl
WHERE responsibility_name = '&Resp_Name'
AND Language = USERENV ('LANG');

5.3. Get the current log sequence in the FND table.

select max(log_sequence) from fnd_log_messages ; -- start

5.4. Run ap_undo_acctg.sql

https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 9/10
9/4/2017 Document Display
5.5. Get the log sequence in the FND table after the undo script completes.

select max(log_sequence) from fnd_log_messages ; -- end

5.6. Get the FND Debug log data for the undo script.

select * from fnd_log_messages where log_sequence between <start> and <end>;

5.6. Spool this into an xls file.

6. Review the log file created by the ap_undo_acctg.sql script. Use the following script to determine
the location of the log file:

SELECT decode(instr(value,','),0,value, SUBSTR (value,1,instr(value,',') - 1))


FROM v$parameter
WHERE name = 'utl_file_dir';

Getting the error message: "this line cannot be accounted until the accounting event that it referen

REFERENCES

NOTE:1112504.1 - R12 - Troubleshooting Accounting Errors


NOTE:553484.1 - Troubleshooting Accounts Payable Trial Balance (Open Account AP Balance Listing) issues in R12
NOTE:605707.1 - SLA: A TECHNICAL PERSPECTIVE OF THE AP TO GL RECONCILIATION

Didn't find what you are looking for?

https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=miz9rm08l_4 10/10

Vous aimerez peut-être aussi