Pulling the tax request and response from Oracle EBS

Every tax problem gets easier once you can see exactly what Oracle sent to the tax engine and what came back. This lesson shows how to find that pair of XML documents in the adapter log with SQL, and what to read first.

By Herb Park, Clarent Technologies

A screen shows you the tax result. The request shows what the engine was told and the response shows what it decided and why. With both in hand, most "wrong tax" questions can be triaged in minutes. The examples use the ONESOURCE (Sabrix) Oracle adapter, which logs to a table called SABRIX_LOG; other engines’ adapters keep similar logs under different names.

What you need

alter session set current_schema=apps;

Method 1: find the logs for a transaction that already ran

Use this when an invoice is already on hold or already shows the wrong tax. The log stores Oracle’s internal document ID, not the number users see, so look that up first. For an AP invoice:

SELECT invoice_id, invoice_num, org_id, creation_date
FROM ap_invoices_all
WHERE invoice_num = :invoice_num;

If several rows come back, pick the one with the right operating unit (org_id). Then pull the XML rows:

SELECT log_date, batch_id, log_id, document_num, procedure_name,
       location, message, extended_message
FROM sabrix_log
WHERE document_num = :document_num
  AND location LIKE '%DATA%XML%'
ORDER BY log_id DESC;
Each engine call appears as two rows that share the same BATCH_ID.
RowLocationWhat it is
RequestINDATA XMLWhat Oracle sent to the engine
ResponseOUTDATA XMLWhat the engine returned

Take the most recent pair unless you are investigating a specific earlier attempt.

Rows pair up by batch ID, and the newest pair is on top What the log query returns for one invoice (illustrative). Two attempts were logged, each as a request row and a response row with a shared batch ID.
  • LOG_DATE: 15-OCT 09:05; BATCH_ID: 77120; LOG_ID: 9034418; DOCUMENT_NUM: 284511; LOCATION: OUTDATA XML; EXTENDED_MESSAGE: <OUTDATA>...
  • LOG_DATE: 15-OCT 09:05; BATCH_ID: 77120; LOG_ID: 9034412; DOCUMENT_NUM: 284511; LOCATION: INDATA XML; EXTENDED_MESSAGE: <INDATA>...
  • LOG_DATE: 14-OCT 16:22; BATCH_ID: 76893; LOG_ID: 9029977; DOCUMENT_NUM: 284511; LOCATION: OUTDATA XML; EXTENDED_MESSAGE: <OUTDATA>...
  • LOG_DATE: 14-OCT 16:22; BATCH_ID: 76893; LOG_ID: 9029970; DOCUMENT_NUM: 284511; LOCATION: INDATA XML; EXTENDED_MESSAGE: <INDATA>...
  • 4 rows fetched. DOCUMENT_NUM holds the internal invoice ID.
  • (1) The most recent pair: same batch ID, one request and one response. Take this one.
  • (2) An earlier attempt. Use it only if that attempt is the one you are investigating.

Method 2: capture a fresh log by re-running the transaction

  1. Note the current highest log ID. Run SELECT MAX(log_id) FROM sabrix_log; and write the number down.
  2. Run the transaction. Validate the invoice or recalculate tax in Oracle. Only do this in production when the business owner agrees.
  3. Pull everything logged since then. Query sabrix_log for log_id > :max_log_id and location LIKE '%DATA%XML%', newest first.
  4. Check it is yours. Confirm DOCUMENT_NUM and LOG_DATE. On a busy system someone else’s transaction can land in the same window.
Mark the log, re-run the transaction, then read only what is new The four steps above across the three places they happen. The log ID noted first is what separates your re-run from everything logged before it.
  • 1. You, in SQL: Note the highest log ID
  • 2. Oracle EBS: Validate the invoice
  • 3. Adapter log: Call logged as two rows
  • 4. You, in SQL: Query the newer rows
  • 5. You, in SQL: Check it is yours

Copying the XML out

The full XML is in EXTENDED_MESSAGE; the results grid only shows the start of it. Open the cell’s full-value editor, select all, copy, and save it as a file. Save the request and the response, and name them so they stay paired, for example request-<log_id>.xml and response-<log_id>.xml.

What to read first

Three questions, in order, once you have the pair The three questions below as a path. Each "no" tells you where to look next.
  • Any rows in the log?: Was the engine called at all
  • Look upstream: Call point, adapter or E-Business Tax
  • Request facts right?: Ship-to, ship-from, dates, product codes, tax code
  • Fix what Oracle sent: Master data or the integration
  • Read the response: Jurisdiction, rate, rule fired, tax code, error flags
  1. Was the engine called at all? No rows means the problem is upstream: the call point, the adapter, or Oracle E-Business Tax itself. See When it isn’t the tax engine.
  2. Are the facts in the request right? Ship-to, ship-from, dates, product codes, the tax code passed in. See Anatomy of a tax calculation request.
  3. What did the engine decide? In the response: jurisdiction, rate, the rule that fired, the tax code returned, and any error or partial-success flags.

Then work through Diagnosing an unexpected tax result.