Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
MarcoARaymundo
Creator III
Creator III

Intercepting errors

Hi!

I have many files that should have the same fields, but some of them are not correct and need to identify them.

When ErrorMode = 0 the QlikView shows a screen that identifies the type of error and a description.

In my case is Field Not Found, it appears the name of the missing field.

error.png

I created something like this:

SET ErrorMode = 0;

FOR EACH vFile IN FileList('..\Base\*')

     MyData:

     LOAD

          Field1,

          Field2,

          Field3

     FROM [$(vFile)]  (txt, utf8, embedded labels, delimiter is ';', no quotes, header is 4 lines);

     IF '$()' = 11 THEN

          ERROR:

          Load

            'AS 1A4' as errProject,

            '$(vFile)' as errFile,

            '$(ScriptErrorList)' as errTyp,

            '$(ScriptErrorDetails)' as errDetail

            AutoGenerate 1;

     ENDIF

NEXT

But the name of the missing field was not available in ScriptErrorDetails variable.

Does anyone know how I can get this information (Field Name Missing)?

Tks!

Marco

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

You can load the field names as a column using the Transpose option in the Transformation Step wizard and check them against the list of expected fields, or you could load them into a temp table using First 1 LOAD (to get a single line and again check against the expected list. The first option is the one I use.

Or if you just want to get the data loaded and its not that important to find the missing field, explicitly concatenate he files and use LOAD *:

    Data:

     LOAD 1 As Dummy Autogenerate (0);

     For Each .....

         

          Concatenate(Data)

          LOAD *

          FROM [$(vFile)]  (txt, utf8, embedded labels, delimiter is ';', no quotes, header is 4 lines);

     Next

     DROP Field Dummy;

Missing fields will be null.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
flipside
Partner - Specialist II
Partner - Specialist II

Try putting your ScriptErrorDetails into another variable before running any other logic code (something that can return a true/false result such as an IF) ..

  MyData:
LOAD USER,
NAME,
FLD1
FROM ...

let x = '$(ScriptErrorDetails)';
let y = ScriptError;

if $(y) = 11 THEN
ERROR:
Load
'AS 1A4'
as errProject,
'$(vFile)'
as errFile,
'$(ScriptErrorList)'
as errTyp,
'$(x)'
as errDetail
AutoGenerate 1;
ENDIF

flipside

EDIT: This will only give you the first error (missing field) it finds, of course.

MarcoARaymundo
Creator III
Creator III
Author

Thanks flipside, but the variable ScriptErrorDetails is list type, can not change to simple variable;

flipside
Partner - Specialist II
Partner - Specialist II

Strange, it worked for me, errDetail showing in the format

Field not found - <FLD1>.

Is this not what you wanted?

MarcoARaymundo
Creator III
Creator III
Author

Yes! this is i wanted, but, for me don't worked.