3 Replies Latest reply: Mar 21, 2017 5:59 AM by Shanmuga S RSS

    How to filter inside a for loop in subroutine

    Shanmuga S

      Hi Qlikers,

       

      I need to filter a particular named txt files from the root folder (including all sub folders in it). I'm using the following sub routine and then filtering the sub routine result set to achieve the desired result.

       

      sub ScanFolder(Root)

        for each FileExtension in 'txt'

        for each FoundFile in filelist( Root & '\*.' & FileExtension)

        FileList:

        LOAD '$(FoundFile)' as SourceFile,

        FileTime( '$(FoundFile)' ) as Filetime

        AUTOGENERATE 1;

        Set vConcatenate = Concatenate;

        next FoundFile

        next FileExtension

        for each SubDirectory in dirlist( Root & '\*' )

        call ScanFolder(SubDirectory)

        next SubDirectory

      end sub;


      Call ScanFolder ('myfolder\Log');


      FinalFileList:

      NOCONCATENATE

      LOAD

      SourceFile,

      Filetime

      RESIDENT FileList

      WHERE SourceFile LIKE '*Reload_Task_Check';

       

      My question is it is possible to filter the name of the txt file inside the subroutine itself? Can you please help me here.

       

      Thanks,

      Shan S