4 Replies Latest reply: Mar 12, 2012 10:53 AM by Michael Distasio RSS

    Issues with File Scan

      I've got a QVW that scans file information to help build auditing tables, and it runs fine when I run it locally on the desktop version.  However, whe I go to run it on the server and publish it on the access point, it will fail right away.  The code is modified from the meta scanner QVW.

       

      The script can't seem to find the final Files Table.

       

       

      Here is a copy of the script:

       

       

      UNQUALIFY *;
      
      
      Looptable:
      LOAD * INLINE [
          FileFolder, Environment
          Z:\Qlikview\Data, $(vEnvironment)
      ]; 
      
      Exception:
      LOAD * INLINE [
          DenyPath
                MetaData
      ];
      
      
      // --------------------------------------------------
      // Main loop through the folders holding the files
      // --------------------------------------------------
      FOR X = 1 to fieldvaluecount('FileFolder');
                let dodirpath = fieldvalue('FileFolder',$(X));
                let Env = fieldvalue('Environment',$(X));
                if dodirpath = 'RelativePath' then 
                          let dodirpath=replace(Documentpath(),Documentname(),'')&'$(RelativePath)';
                endif
      
      
      Sub DoDir(Root)
                for each Ext in $(Suffix)
                          for each File in filelist (Root&'\*.'&Ext)
      
                                    // Finding exceptions in the file structure
                                    SET denydirpath = 0;
                                    for Y = 1 to fieldvaluecount('DenyPath')
                                    let vDenyPath = fieldvalue('DenyPath',$(Y));
                                    let denydirpath = denydirpath + SubStringCount(lower('$(File)'),lower('$(vDenyPath)'));
      
                                    Next Y
                                    if $(denydirpath) = 0 then 
      
      
      FileListTMP: 
                                    Load 
                                              Upper(FileName) & '_' & Date(Today(), 'YYYY-MM-DD') as LoadDateKey,
                                              FileName                                                                       as FileName,           // Modified 5/2/11 BPN
                                              Date(Today(), 'YYYY-MM-DD')                     as LoadDate, 
                                              lower(subfield(FileName,'\',-1))           as DocName,                    // Modified 5/2/11 BPN
                                              FileSize(FileName)                                                   as Size, 
                                              FileTime(FileName)                                                   as FileTime, 
                                              makedate(year(FileTime(FileName)), month(FileTime(FileName)),day(FileTime(FileName))) as FileDate,
                                              '$(dodirpath)'                                                             as RootPath,
                                              left(FileName,len(FileName) - len(subfield(FileName,'\',-1))-1) as Path,
                                              lower(right(FileName,Len(FileName)-index(FileName,'.',-1))) as Extension,
                                              '$(Env)'                                                                       as Environment,
                                              1 as FileCount;
                                    Load * Inline [ 
                                              FileName
                                              "$(File)" ];
      
                          endif
                          Next File 
                Next Ext 
      
                For each Dir in Dirlist(Root&'\*') 
                          Call DoDir(Dir)
                Next Dir 
      End sub
      Call DoDir('$(dodirpath)')
      Next X
      drop table Looptable; 
      
      
      Files:
      LOAD LoadDateKey,
                FileName,
                Mid(FileName, 16) as FileNameTrim,
                LoadDate,
                DocName,
                Size,
                FileTime,
                FileDate,
                RootPath,
                Path,
                Extension,
                Environment,
                FileCount,
      RESIDENT FileListTMP;
      
      
      drop table FileListTMP;
      
      
      store Files into Files.QVD (QVD);
      
      
      Drop table Files;