Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
ramrongala
Contributor II
Contributor II

How exit the script/terminate the QVW while current month file not there in folder

Hi Guys,

Greetings!

Issue:

we have Monthly load in that there are three folders maintained.

For every month one file will be added into that folders,

 
 

But if file is not added in particular month we could not run the job.

so  i am trying to develop automation qvw - if not updated with current month file the qvw file should automatically terminated or failed.

i have already developed the application but if any file not updated it executes entire script.so how to terminate or failed if not updated current month file.

Please find the attached QVW  and do any changes in code

Please help on this.

8 Replies
cwolf
Creator III
Creator III

Try following:

SUB CheckFiles(path)
	FILES:
	LOAD Null() as Name AutoGenerate 0;
	
	FOR Each File in filelist ('$(path)')
		Concatenate(FILES)
		LOAD 
		'$(File)' as Name
		autogenerate 1;
		exit for;
	NEXT File
	
	if NoOfRows('FILES')=0 then
		trace 'No current month file in: $(path)';
		trace 'Script is cancelled!';
		EXIT SCRIPT;
	end if
	
	drop Table FILES;
END SUB

let vCurrentMonthYear = Date(today(),'YYYYMM');

call CheckFiles('c:\New implemnts\Dashboard\Product Dept\PRODUCTION_ORDERS_DATA_$(vCurrentMonthYear)*.csv');
call CheckFiles('c:\New implemnts\Dashboard\Marketing Dept\SALES_ORDERS_DATA_$(vCurrentMonthYear)*.csv');
call CheckFiles('c:\New implemnts\Dashboard\Sales Dept\MARKET_ORDERS_DATA_$(vCurrentMonthYear)*.csv');

trace 'All folders has a current month file.';
trace 'Script is running!';
ramrongala
Contributor II
Contributor II
Author

HI ,

Thank you fro your code and guiding but it cant exit/failed while the folders not updated with current month file.

Please share the QVW which u developed, it would be great.

cwolf
Creator III
Creator III

Ok, see attachment.

 

ramrongala
Contributor II
Contributor II
Author

Bro, Sales and market folders not having current month files , only product folder having current month file.

in this case the qvw application must exit/failed right but here it execute and not showing anything.

Please help.

  

cwolf
Creator III
Creator III

This is the content of the logfile when I run it in my environment:

2019-11-15 10:40:03 0034 let vCurrentMonthYear = Date(today(),'YYYYMM')
2019-11-15 10:40:03 0036 call CheckFiles('c:\New implemnts\Dashboard\Product Dept\PRODUCTION_ORDERS_DATA_201911*.csv')
  2019-11-15 10:40:03 0014 FILES:
  2019-11-15 10:40:03 0015 	LOAD Null() as Name AutoGenerate 0
  2019-11-15 10:40:03      	1 Felder gefunden: Name, 
  2019-11-15 10:40:03      0 Sätze erhalten
  2019-11-15 10:40:03 0017 FOR Each File in filelist ('c:\New implemnts\Dashboard\Product Dept\PRODUCTION_ORDERS_DATA_201911*.csv')
    2019-11-15 10:40:03 0018 Concatenate(FILES)
    2019-11-15 10:40:03 0019 		LOAD 
    2019-11-15 10:40:03 0020 		'c:\New implemnts\Dashboard\Product Dept\PRODUCTION_ORDERS_DATA_20191112.csv' as Name
    2019-11-15 10:40:03 0021 		autogenerate 1
    2019-11-15 10:40:03      	1 Felder gefunden: Name, 
    2019-11-15 10:40:03      1 Sätze erhalten
  2019-11-15 10:40:03 0022 exit for
  2019-11-15 10:40:03 0025 if NoOfRows('FILES')=0 then
  2019-11-15 10:40:03 0031 drop Table FILES
  2019-11-15 10:40:03 0032 END SUB
2019-11-15 10:40:03 0037 call CheckFiles('c:\New implemnts\Dashboard\Sales Dept\SALES_ORDERS_DATA_201911*.csv')
  2019-11-15 10:40:03 0014 FILES:
  2019-11-15 10:40:03 0015 	LOAD Null() as Name AutoGenerate 0
  2019-11-15 10:40:03      	1 Felder gefunden: Name, 
  2019-11-15 10:40:03      0 Sätze erhalten
  2019-11-15 10:40:03 0017 FOR Each File in filelist ('c:\New implemnts\Dashboard\Sales Dept\SALES_ORDERS_DATA_201911*.csv')
  2019-11-15 10:40:03 0025 if NoOfRows('FILES')=0 then
    2019-11-15 10:40:03 0026 trace 'No current month file in: c:\New implemnts\Dashboard\Sales Dept\SALES_ORDERS_DATA_201911*.csv'
    2019-11-15 10:40:03 0026 'No current month file in: c:\New implemnts\Dashboard\Sales Dept\SALES_ORDERS_DATA_201911*.csv'
    2019-11-15 10:40:03 0027 
    2019-11-15 10:40:03 0027 trace 'Script is cancelled!'
    2019-11-15 10:40:03 0027 'Script is cancelled!'
    2019-11-15 10:40:03 0028 
    2019-11-15 10:40:03 0028 EXIT SCRIPT
  2019-11-15 10:40:03      Ende der Skriptausführung

 

After checking the production folder, everything is Ok. While checking the sales folder, the script aborts.

Brett_Bleess
Former Employee
Former Employee

Murthy, not sure what version you are running, but there is such a trigger in the 12.30 and later releases:

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/QMC/Content/QV_QMC/QMC_System_SupportingTa...

Check out the File Exists section.  If you are on an older release, then you will have to use the other logic you have been approaching, but I wanted to let you know there was a new trigger in the later releases just in case.  One trick is to be sure once that file appears, that you then need to move it elsewhere with another task, or the trigger will continue to fire etc...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
ramrongala
Contributor II
Contributor II
Author

Thank you for your great help, its working fine in my local machine.

My main agenda is  folders not updated with current month data, this qvw won't run in QMC .

we setup triggers like upon success of "folders checking app" then run the mail application(main application.qvw) 

but folder checking app(Source File Checking.qvw )  not failing in qmc but in log file showing script cancelled like below

12/5/2019 4:40:04 PM: 0027      'No current month file in: \\AWSACYIRL12345\Qv\Private\Global\Auxiliar.Files\flat files\Supplier Production\201912_Supplier_Production.txt'

 

12/5/2019 4:40:04 PM: 0028      trace 'Script is cancelled!'

12/5/2019 4:40:04 PM: 0028      'Script is cancelled!'

 

12/5/2019 4:40:04 PM: 0031      EXIT SCRIPT

12/5/2019 4:40:04 PM:      Execution finished 

we put like this in qmc:

main application.qvw -- upon success of  "Source File Checking.qvw" in triggers.

how to fix the issue based on log file message in qmc

Brett_Bleess
Former Employee
Former Employee

Really need the full script/document log here to see what is going on prior to the messages you included...  There is no error, it appears the script has built-in logic to cancel/exit if the file is not found, so it appears to me that things are working as expected in this regard...  If the issue is things not failing when you hit this logic and you do NOT want to run the subsequent task, you will likely need to force an error in this case in order to cause the failure.

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Error...

That might help in this case, not sure.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.