Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
Not applicable

On post reload fail script

Hi,

Is there any way to fail a script only at then end of execution?

We have a script which should not fail until it runs the entire script so we set errormode=0 but in case of failure we have to open the log and check line by line. Please suggest a way to track the error and display it at the end of the log.

Thanks in advance

8 Replies
agni_gold
Valued Contributor III

Re: On post reload fail script

Can you please explain your question ? , you want to fail your script at the end of execution?

Am i correct ?


Not applicable

Re: On post reload fail script

Hi Agnivesh,

Yes, that is right.

Thanks

agni_gold
Valued Contributor III

Re: On post reload fail script

apply any unknown charecter at the last of the script. It will fail

agni_gold
Valued Contributor III

Re: On post reload fail script

I have used simple a load statement

X:

LOAD A,
B,
C
FROM

(
ooxml, embedded labels, table is Sheet1);

DROP TABLE N;

when this script will run then it will give the error for table not fount and this will also captured in the log file , i have attached the log file screenshot .

Or

If you want other thingh then tell me 

aveeeeeee7en
Valued Contributor III

Re: On post reload fail script

Hi

Try Using Errormode=2

Hope that helps you.

Regards

Av7eN

Not applicable

Re: On post reload fail script

Hi Nirmal,

I would propose following solution

After each statement in load script you can check error an store them in table. As a result you will have loaded data and table with errors.

For example define following procedure

SUB checkForError (vScriptError, vScriptErrorDetails)

    //saving error code if error occurred

    IF vScriptError > 0 THEN

        LET vErrorCode = vScriptError ;

        LET vErrorMessage = replace(vScriptErrorDetails, chr(39), '"');  //if errormessage looks like " '<filename>' file not found"  we should replase (') with (")

        CALL writeLog (vErrorCode, vErrorMessage);

    END IF

    ;

END SUB

;

Call this procedure after each operator in your script

CALL checkForError(ScriptError, ScriptErrorDetails);

Don't forget to prepare procedure for writing log in table

SUB writeLog (vStatus, vMessage)

    LET vStopLogTime = now();

     LoadingLog:

    LOAD

         '$(vStopLogTime)'                  AS [StopTime],

          '$(vStatus)'                    AS [Status],

        '$(vMessage)'                     AS [ErrorMessage]

    AUTOGENERATE(1);

END SUB

;

Not applicable

Re: On post reload fail script

Hi,

Let me try that.

Thanks

Not applicable

Re: On post reload fail script

Thanks everyone for your valuable inputs.

I have used ScriptErrorCount and alert service to notify admin in case of failure.