It’s only Elvis and CSV who can speak the headline with confidence.

In a project I’m working on, another developer reported an issue. A report I made to get related segment values from ERP to Apex was failing. Strange, It has worked for a long time, getting segment values and related segment values on a scheduled basis.

Pressing the manual “Refresh” button returns the error.

The code block below shows the bad log and how the same line looks in the BI report. Between the 0,,Y the segment name “Unspecified” is missing. This is the only row failing in the import, among hundreds of rows. This row is relatively new. The employer decided to go from many zeros in the “Unspecified”, for the Activity segment, to only one zero. This value was put in to the accounting segments recently.

Data in the BAD-log in apex:
300000009317028,83006,"Activity Hovedbok",0,,Y,,,"Activity Hovedbok",83007,"Project Hovedbok",0,,Y,,,"Project Hovedbok"

Data in BI preview:
300000009317028,83006,"Activity Hovedbok",0,Unspecified,Y,,,"Activity Hovedbok",83007,"Project Hovedbok",0,Unspecified,Y,,,"Project Hovedbok"

The reason why it fails is strange. All the commas are in the right place and the field in the database is not mandatory. The report resides in the BI folder and is executed using the xmlpserver/services/v2/ReportService?wsdl. Data is stored in a bucket and imported from the bucket using the below code.

I looked up the new value in Manage Chart of Accounts Value Set Values. I wanted to see if there was something strange with this value. I know this value has been entered manually and not imported using the rapid implementation.

Everything seems ok in the setup. Can not see any leading or trailing non printable characters, known to create errors when parsing CSV.

Trying a trim around the description in the report, like below, still the same problem.

trim(ffv1.description) AS flex_description_1,

Even tried a DUMP on the field to see if it was something strange with the flex description.

DUMP(ffv1.description) AS flex_description_1,

This returns:
Typ=1 Len=11: 85,110,115,112,101,99,105,102,105,101,100

Type: 1 The field is of type VARCHAR2 or CHAR.
Length: 11
The value stored in the field is 11 characters long.
ASCII Values: 85,110,115,112,101,99,105,102,105,101,100

These ASCII values map to: U, n, s, p, e, c, i, f, i, e, d

Nothing wrong with the description. So why does it go missing. Just as a last check i copy some of the CSV into Notpad++. This is a nice tool to see if some other fields are having characters causing the problem.

Under the “View | Show Symbol” turn on “Show all Characters”.
The CSV output is all fine. No mysterious symbols to ruin the CSV.

I asked my colleague, Gerrit, for advice. He has worked with Fusion and have been poking around in Fusion tables for a gazillion years. The output of CSV is all fine. However, the value of “Unspecified” is missing in the BAD log. He pointed me in the direction that this was a language problem. Maybe I had used the wrong tables to extract the data.

I have used the FND_FLEX_VALUES_VL that is a view that holds all the fields I needed for the report. Very practical. He pointed out that this view is a join between FND_FLEX_VALUES and FND_FLEX_VALUES_TL. The TL table is the table that holds translations. This VL-view has a language clause like this:

AND T.LANGUAGE = USERENV(‘LANG’)

This clause is causing the missing text. Se more information on these tables in the documentation: https://docs.oracle.com/en/cloud/saas/applications-common/24d/oedma/fndflexvalues-7866.html

When querying the FND_FLEX_VALUE_TABLE_TL for the Unspecified value, I get two lines back. The Norwegian translation has no Description. When running the report in BI with my US language settings, I get a value in description. When the report is run from the SOAP service from Apex it has no language settings. By coincidence it returns the Norwegian version.

I change my report to not use the VL view and using the two other tables and setting language=’US’. Now the report and the import of segments worked again.

CSV errors can often take a lot of time to figure out, what is wrong.

If you ever need to clear a column for non printable characters these regular expression is good for that:

Remove all ctrl symbols: (form feeds, tabs, and carriage returns)
SELECT REGEXP_REPLACE(column_name, '[[:cntrl:]]', '') AS new_column FROM table_name;

Remove all space symbols: (spaces, tabs, newlines, etc.)
SELECT REGEXP_REPLACE(column_name, '[[:space:]]+', '') AS new_column
FROM table_name;

Leave a Reply


Oppdag mer fra Standal.blog

Abonner for å få de siste innleggene sendt til din e-post.

Håvard Standal avatar

Published by

Discover more from Standal.blog

Subscribe now to keep reading and get access to the full archive.

Continue reading