<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loop in script to confirm QVD has been updated in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734565#M722513</link>
    <description>&lt;P&gt;Yes that's correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Execute a batch file (which i have done)&lt;/P&gt;&lt;P&gt;then to check that all QVDs in the local directory have today's timestamp. I do not want the reload to complete until all QVDs are updated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That will then stop the tasks from starting in the QMC until all of the QVDs have been copied.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Aug 2020 15:25:05 GMT</pubDate>
    <dc:creator>CNH_1978</dc:creator>
    <dc:date>2020-08-10T15:25:05Z</dc:date>
    <item>
      <title>Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734419#M722505</link>
      <description>&lt;P&gt;Hi everyone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for some help to write a simple loop in my script which confirms a QVD has the latest date stamp (QVDCreateTime) before the script exits.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following which checks the date stamp&amp;nbsp;&lt;/P&gt;&lt;P&gt;let vQVDPath = 'C:\Users\USER1\Desktop\';&lt;BR /&gt;let vToday = date(today(),'DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;if left(date(QvdCreateTime('$(vQVDPath)TestQVD.QVD'),'DD/MM/YYYY'),10) = '$(vToday)' then&lt;/P&gt;&lt;P&gt;SET vResult = 'Yes';&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;SET vResult = 'No';&lt;/P&gt;&lt;P&gt;ENDIF;&lt;/P&gt;&lt;P&gt;What i want to do now is wrap a loop around it so it keeps looping until the condition is met.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help please?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734419#M722505</guid>
      <dc:creator>CNH_1978</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734447#M722506</link>
      <description>&lt;P&gt;try below&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let vQVDCreateTime = floor(QvdCreateTime('$(vQVDPath)TestQVD.QVD'));

let vToday = floor(today());

do UNTIL vQVDCreateTime = vToday

if vQVDCreateTime = vToday then

SET vResult = 'Yes';

TRACE $(vResult);

EXIT do;

ELSE

SET vResult = 'No';

TRACE $(vResult);

ENDIF;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Aug 2020 10:56:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734447#M722506</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-10T10:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734456#M722507</link>
      <description>&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;Thanks for your reply. I have tried your suggestion but i can't get it to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the QVW, are you able to see what i have done wrong please?&lt;/P&gt;&lt;P&gt;Also, how does the script know to go back to the start of the loop if the QVD date does not = the todays date?&lt;/P&gt;&lt;P&gt;Currently the result is stating 'No' but the script ends instead of looping through again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 11:23:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734456#M722507</guid>
      <dc:creator>CNH_1978</dc:creator>
      <dc:date>2020-08-10T11:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734466#M722509</link>
      <description>&lt;P&gt;If QVD crete time equal to today then do you want to perform something? or do you want to perform when it is not equal&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 11:47:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734466#M722509</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-10T11:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734563#M722510</link>
      <description>&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;So the reason for this loop is as follows.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have QlikView server (not publisher), we have a QVW that executes a batch file that copies 20+ QVDs from a remote server to the local server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The QVW in question runs from the QMC with a chain of tasks underneath.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the QVW is running and the batch file is executed, the task finishes and the next task in the list starts. The problem is that even though the task finishes (according to the QMC), it hasn't actually finished. The QMC does not know when the batch file commands are complete, so the tasks that run after it have loaded in old data because the new QVDs are still in the process of copying across.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i thought i could put a check in the script of the QVW to check that the QVDs in the local folder have been updated with today's QVDs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea was to execute the batch file, then start a loop where it keeps checking each QVD in the local folder and does not exit until all QVDs are today's date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently i am trying to get it working by checking a single QVD in the local folder, but the goal is to check all QVDs in the local folder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 15:15:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734563#M722510</guid>
      <dc:creator>CNH_1978</dc:creator>
      <dc:date>2020-08-10T15:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734564#M722512</link>
      <description>&lt;P&gt;ok so idea is to copy files if all QVDs is refresh with today's date?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 15:20:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734564#M722512</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-10T15:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734565#M722513</link>
      <description>&lt;P&gt;Yes that's correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Execute a batch file (which i have done)&lt;/P&gt;&lt;P&gt;then to check that all QVDs in the local directory have today's timestamp. I do not want the reload to complete until all QVDs are updated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That will then stop the tasks from starting in the QMC until all of the QVDs have been copied.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 15:25:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734565#M722513</guid>
      <dc:creator>CNH_1978</dc:creator>
      <dc:date>2020-08-10T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734598#M722514</link>
      <description>&lt;P&gt;This loop will run until all files are not updated meaning that it will check this forever until condition met.&amp;nbsp; You cam limit the loop to run for specific hours as enhancement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let vUpdateQVDFlag= Null();

Do UNTIL vUpdateQVDFlag=1

Sub DoDir (Root)
     For Each Ext In 'qvd' // filetype to search for in current directory
          For Each File In FileList (Root &amp;amp; '\*.' &amp;amp; Ext)
                    Files:
                    Load '$(File)' as FileName,
                        RowNo() as Row,
                     floor(FileTime('$(File)')) as FileTimeNum,
                     FileTime('$(File)') as FileTime
                    Autogenerate 1;
          Next File
     Next Ext
     For Each Dir In DirList (Root &amp;amp; '\*') // searching in subdirs
          Call DoDir (Dir)
     Next Dir
End Sub
Call DoDir ('C:\Data'); // Change the actual path of your QVD folder

FilesCheck:
LOAD if(QVDCount=UpdateQVDCount,1,0) as UpdateQVDFlag;
LOAD max(Row) as QVDCount,
     sum(if(FileTimeNum=floor(Today()),1,0)) as UpdateQVDCount
Resident Files;

let vUpdateQVDFlag = Peek('UpdateQVDFlag',0,'FilesCheck');

if vUpdateQVDFlag=1 THEN

TRACE "All Files are upto date";

exit do

ELSE

TRACE "All Files are not updated yet";

DROP Tables FilesCheck,Files;

ENDIF

LOOP

if vUpdateQVDFlag=1 THEN

// Here you can do what you want to perform when all files are updated

EXECUTE;  // you can call your execute command to run batch file.

ENDIF

let vUpdateQVDFlag= Null();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 20:37:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734598#M722514</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-10T20:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734718#M722515</link>
      <description>&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;Fantastic, I removed the part of code used to search in sub folders (as that is not needed) and tested and it works perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 08:26:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734718#M722515</guid>
      <dc:creator>CNH_1978</dc:creator>
      <dc:date>2020-08-11T08:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734728#M722516</link>
      <description>&lt;P&gt;Glad that it worked&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 08:52:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1734728#M722516</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-11T08:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1736298#M722517</link>
      <description>&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;Is there an easy way to add another condition into this script. What i am thinking is, if the reload takes more than 1 hour then exit script. I am concerned that if something happens and the file copy hangs then the script will carry on looping until someone stops it. But we will not know straight away if that happens as the task will still be running.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 08:54:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1736298#M722517</guid>
      <dc:creator>CNH_1978</dc:creator>
      <dc:date>2020-08-17T08:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Loop in script to confirm QVD has been updated</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1736357#M722518</link>
      <description>&lt;P&gt;Yes. You can put condition to limit it to loop for one hour from when it got started. But if still condition is not met then do you need to fail the app? Because if you just do exit script it will show successful in task.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 12:00:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-in-script-to-confirm-QVD-has-been-updated/m-p/1736357#M722518</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-08-17T12:00:29Z</dc:date>
    </item>
  </channel>
</rss>

