Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Message pop up while running script

hi All,

while writting a if statement in script

if file = true then

load * from table

else

"File not saved on Drive"

end if

above gives an error .. please advise

thanks

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this for excel file

SET vFileName='\\10.199.199.199\shared\QAReport.xlsx';

// Set a variable indicating if the file exists or not. -1 is True, 0 is False

LET vFileExists = if(FileSize('$(vFileName)') > 0, -1, 0);

IF $(vFileExists) THEN      

    Data:  

    LOAD *

    FROM $(vFileName)(ooxml, no labels, table is Sheet1); // Sheet1 is the sheet name in your excel file

ELSE      

     MsgBox('File Not exists.');

END IF;

Hope this helps you.

Regards,

Jagan.

View solution in original post

9 Replies
Not applicable
Author

hi All,

any luck on this request

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

SET vFileName='Refund.qvd';

// Set a variable indicating if the file exists or not. -1 is True, 0 is False

LET vFileExists = if(FileSize('$(vFileName)') > 0, -1, 0);

IF $(vFileExists) THEN       

    Data:  

    LOAD *

    FROM $(vFileName);   

ELSE                       

     MsgBox("File Not exists.");

END IF;

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

hi jagan and all,

while using the above solution if the file is present on shared drive or not

vfileExists always give 0 value

please advise

thanks

jagan
Luminary Alumni
Luminary Alumni

Hi,

This script is working for me

SET vFileName='\\10.199.199.199\shared\Sales.qvd';

// Set a variable indicating if the file exists or not. -1 is True, 0 is False

LET vFileExists = if(FileSize('$(vFileName)') > 0, -1, 0);

IF $(vFileExists) THEN     

     Data:  

    LOAD *

    FROM $(vFileName)(qvd);   

ELSE                       

     MsgBox('File Not exists.');

END IF;

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

i have xls file will that make a difference

set vFileName='\\........\sales.xls';

sujeetsingh
Master III
Master III

Jagan it worked but when i reload and file is not there then msg do not pop ups.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this for excel file

SET vFileName='\\10.199.199.199\shared\QAReport.xlsx';

// Set a variable indicating if the file exists or not. -1 is True, 0 is False

LET vFileExists = if(FileSize('$(vFileName)') > 0, -1, 0);

IF $(vFileExists) THEN      

    Data:  

    LOAD *

    FROM $(vFileName)(ooxml, no labels, table is Sheet1); // Sheet1 is the sheet name in your excel file

ELSE      

     MsgBox('File Not exists.');

END IF;

Hope this helps you.

Regards,

Jagan.

jagan
Luminary Alumni
Luminary Alumni

Hi,

I am getting the popup if the file is not available.  Can you attach the script.

Regards,

Jagan.

Not applicable
Author

Hi Jegan,

Thank for this ans. It helped me:

Hi,

Try this for excel file

SET vFileName='\\10.199.199.199\shared\QAReport.xlsx';

// Set a variable indicating if the file exists or not. -1 is True, 0 is False

LET vFileExists = if(FileSize('$(vFileName)') > 0, -1, 0);

IF $(vFileExists) THEN     

    Data: 

    LOAD *

    FROM $(vFileName)(ooxml, no labels, table is Sheet1); // Sheet1 is the sheet name in your excel file

ELSE     

     MsgBox('File Not exists.');

END IF;