Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

ErrorCode - seemingly quite easy ...

Hi,

I want to build several LOADs for tables with data about errors in the underlying files - but I cannot be sure whether these files really exist - so what I did up to now is, I set the ERRORMODE to 0 so QlikView would continue with the code and then I tried to build my own error-handling-code - but something about it seems to be wrong: The paths are all defined - the first file I am trying to load really does not exist and the messagebox appears all right - but is the variable ERRORCODE reset after that?

Something seems to be wrong because the messagebox appears after the second file, too - and that one does exist, so there should be no error except if there's an error in the code itself - see here:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

SET ErrorMode = 0; // Hier schalten wir die QlikView-Fehlerbehandlung aus, dann müssen wir selbst eine individuelle Fehlerbehandlung aufbauen.
Abrechnung_syn_Fehler1:
LOAD
*
From $(v_filepath_syn_Pflegefehler1_qvd) (qvd);

IF $(Errorcode) = 8 THEN // Dieser Code steht dafür, dass die betr. qvd-Datei nicht gefunden wurde.
  Tmp: LOAD MsgBox('Fehlertyp1 (weder Zeit noch Volumen) kommt nicht vor.', 'Fehlerinfo', 0,64,0) as Usermsg AutoGenerate 1;
DROP TABLE Tmp;
ENDIF
 
Abrechnung_syn_Fehler2:
LOAD
*
FROM $(v_filepath_syn_Pflegefehler2_qvd) (qvd);

IF $(Errorcode) = 8 THEN  // Dieser Code steht dafür, dass die betr. qvd-Datei nicht gefunden wurde.
  Tmp: LOAD MsgBox('Fehlertyp2 (ComCode passt nicht zum PackageType) kommt nicht vor.', 'Fehlerinfo', 0,64,0) as Usermsg AutoGenerate 1;
DROP TABLE Tmp;
ENDIF

The second table, as I said, does exist and QlikView loads all the data from the qvd_file - but still the messagebox is displayed, as if the ERRORCODE variable was not reset to 0 inbetween ...

=> Do I have to take into account the ScriptErrorCount, too, or can I somehow reset that?

Thanks a lot!

Best regards,

DataNibbler

11 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Yes, you could.

But as I said before, IMHO the best way to approach the task of reporting volatile values & states is to use a SUBroutine. That will also do away with the repetition of the MessageBox LOAD statements all over your script.

For example:

SUB CheckError(ErrorNum, TableName, Position)

  IF ErrorNum <> 0 THEN
    Tmp:

    LOAD MsgBox('Error $(ErrorNum) occurred while trying to load table [$(TableName)] at script location [$(Position)]', 'Table LOAD Error !', 0,64,0)

    AUTOGENERATE 1;
    DROP TABLE Tmp;
  END IF

END SUB

:

SET ErrorMode = 0;

Abrechnung_syn_Fehler1:
LOAD *
FROM [$(v_filepath_syn_Pflegefehler1_qvd)] (qvd);


CALL CheckError(ScriptError, 'Abrechnung_syn_Fehler1', 'Step 1');

:


(The long discussion makes the code formatting look compressed, but I'm sure you get the idea)


Best,


Peter

datanibbler
Champion
Champion
Author

Yep. I get it. Thanks! That would of course be a more elegant solution.

The TRACE works when I put it in upper_quotes - but why does it display the text, not the numeric value?

And why does the >> ScriptErrorList << list the same error twice?

The script_editor clearly does not recognize the >> ScriptError << variable as a variable if you don't put it in $() - but if you do, it does not work because it contains a STRING. Strange. Well, there are more things the script_editor does not recognize ...

Thanks for all the help! I think I can get along now.

Best regards,

DataNibbler