Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts
While moving error files to the destination folder, the following script is moving all files instead of only error files. Can any one trace where i am writing wrong code.
LET vErrorFolderPath='F:\Qlikview\ErrorFolder';
LET vtxtPath='F:\Qlikview\TextFiles';
LET vReloadTimeIn = Now();
SET ErrorMode = 0;
FOR Each vFile in filelist ('$(vtxtPath)\*.txt')
Employee:
LOAD EmpId,
EmpName,
Salary
FROM
'$(vFile)'
(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
ErrorLog:
LOAD
'$(vFile)' as FileName,
'$(vReloadTimeIn)' as [Reload Date and Time],
if(len('$(ScriptError)')=0,'No Error','$(ScriptError)') as Error,
if(len('$(ScriptErrorDetails)')=0,'No Error','$(ScriptErrorDetails)') as ErrorDetails,
'$(#ScriptError)' as ErrorCode
AutoGenerate 1;
if len($(ScriptError))=1 then
EXECUTE cmd.exe /c MOVE "$(vFile)" "$(vErrorFolderPath)\";
end if
next
SET ErrorMode = 1;
LET vReloadTimeOut = now();
Please find the attached files and application.
Any Suggestions regarding the Scripting Issues.
Best Regards,
Madhu.
Hi Madhu,
Try this code its working fine.
LET vErrorFolderPath='C:\Users\Ganesh\Desktop\Data\Error Floder';
LET vtxtPath='C:\Users\Ganesh\Desktop\Data';
LET vProcessedFolderPath='C:\Users\Ganesh\Desktop\Data\Processed Folder';
LET vReloadTimeIn = Now();
SET ErrorMode = 0;
FOR Each vFile in filelist ('$(vtxtPath)\*.txt')
Employee:
LOAD EmpId,
EmpName,
Salary
FROM
'$(vFile)'
(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
ErrorLog:
LOAD
'$(vFile)' as FileName,
'$(vReloadTimeIn)' as [Reload Date and Time],
if(len('$(ScriptError)')=0,'No Error','$(ScriptError)') as Error,
if(len('$(ScriptErrorDetails)')=0,'No Error','$(ScriptErrorDetails)') as ErrorDetails,
'$(#ScriptError)' as ErrorCode
AutoGenerate 1;
//let vTest=if(FieldIndex('ErrorCode','11'),11,0);
let vpeek=peek('ErrorCode',-1,'ErrorLog');
If $(vpeek) ='0' then
EXECUTE cmd.exe /C MOVE "$(vFile)" "$(vProcessedFolderPath)\";
ELSE
EXECUTE cmd.exe /C MOVE "$(vFile)" "$(vErrorFolderPath)\";
end if
Let vpeek='';
next
SET ErrorMode = 1;
Best Regards,
Ganesh
Scripterror does not have NULL-values, therefore LEN(ScriptError) will always be 1 (from 0 Errors till 9 Errors).
Suggest to change the script to
if len($(ScriptError))> 0
HTH Peter
Thanks for the reply Peter, but no change in the result. 'if len($(ScriptError))> 0' is also moving all files to that folder. Any other suggestions
Best Regards,
Madhu.
Hi Experts
can any one suggest me on the above issue
Best Regards
Madhu
Hi all
I am struggling to find the condition , that particular file got Errors.Can any one help to sort this issue.
Example :
if len($(ScriptError))> 0
Thanks
Madhu
Hi Madhu,
Try this code its working fine.
LET vErrorFolderPath='C:\Users\Ganesh\Desktop\Data\Error Floder';
LET vtxtPath='C:\Users\Ganesh\Desktop\Data';
LET vProcessedFolderPath='C:\Users\Ganesh\Desktop\Data\Processed Folder';
LET vReloadTimeIn = Now();
SET ErrorMode = 0;
FOR Each vFile in filelist ('$(vtxtPath)\*.txt')
Employee:
LOAD EmpId,
EmpName,
Salary
FROM
'$(vFile)'
(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
ErrorLog:
LOAD
'$(vFile)' as FileName,
'$(vReloadTimeIn)' as [Reload Date and Time],
if(len('$(ScriptError)')=0,'No Error','$(ScriptError)') as Error,
if(len('$(ScriptErrorDetails)')=0,'No Error','$(ScriptErrorDetails)') as ErrorDetails,
'$(#ScriptError)' as ErrorCode
AutoGenerate 1;
//let vTest=if(FieldIndex('ErrorCode','11'),11,0);
let vpeek=peek('ErrorCode',-1,'ErrorLog');
If $(vpeek) ='0' then
EXECUTE cmd.exe /C MOVE "$(vFile)" "$(vProcessedFolderPath)\";
ELSE
EXECUTE cmd.exe /C MOVE "$(vFile)" "$(vErrorFolderPath)\";
end if
Let vpeek='';
next
SET ErrorMode = 1;
Best Regards,
Ganesh
Madhu,
just learned from the error-text returned that Scripterror and ScriptErrorDetails etc are no valid functions.
Please use ScriptErrorCount instead in your script - it will always have an integer-value (incl "0")
HTH Peter
Hi Ganesh Reddy
Thanks for For your reply, The above script is working fine.
Best Regards
Madhu.