Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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