9 Replies Latest reply: Nov 28, 2013 10:23 AM by Ashish Kumar RSS

    error handling script getting error(Script line error)

    Ashish Kumar


      Hi All,

       

      I am using below script for error handling geeting error message (Script line error).

       

      Please help me.

       

      Set vConcatenate = ;

      sub ScanFolder(Root)

                for each FileExtension in 'txt'

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


                                    set ErrorMode=0;
                                    Protection:
                                    LOAD
                                    ID,
                                   Name,
                                   Premium,
                                                              
                                   FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

                                    Set vConcatenate = Concatenate;
                                   
                                    if ScriptError=11 then
                                  
                                    next FoundFile
                                   
                                    else
                                   
                                   
                                    for each FoundFile1 in filelist( Root & '\Protection_*.' & FileExtension)

                                   
                                    Protection:
                                   LOAD
                                   ID,
                                   Name,
                                   Premium,
                                   FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

                                    Set vConcatenate = Concatenate;
                                   
                                    next FoundFile1                         
                              
                               endif
                              
                              
            
                next FileExtension

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

                          call ScanFolder(SubDirectory)

                next SubDirectory

      end sub

      Call ScanFolder('C:\Production\Life\Data');

       

       

      Regards

      Ashish

        • Re: error handling script getting error(Script line error)
          Aurélien Martinez

          Set vConcatenate = ;

          Set vtest = ;

          sub ScanFolder(Root)

            for each FileExtension in 'qvd'

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

           

                set ErrorMode=0;

           

                Protection:

                LOAD
                    ID,
                    Name,
                    Premium             
                 FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

               

                Let vtest = ScriptError;

           

                Set vConcatenate = Concatenate;

                                      

                if '$(vtest)'<>'Field Not Found' then     

               

                Set vConcatenate = Concatenate;

                    

                  for each FoundFile1 in filelist( '$(Root)\*.$(FileExtension)')

                Protection:

                LOAD
                    ID,
                    Name,
                    Premium             
                 FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

           

           

           

           

                     Set vConcatenate = Concatenate;

                                       

                  next FoundFile1                         

                                  

                endif

             

              NEXT FoundFile   

            next FileExtension

           

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

              call ScanFolder('$(SubDirectory)')

            next SubDirectory

           

          end sub

           

           

          Call ScanFolder('D:\Projets\QlikView\Concours AM-DV\5-QVD');

          • Re: error handling script getting error(Script line error)
            Ashish Kumar

            Hi,

             

            The above script given me duplicate record.

             

            Duplicate record is comming because it relode one file three time

             

            I want it's relode one file only one time.

             

             

            Regards

            Ashish

            • Re: error handling script getting error(Script line error)
              Ashish Kumar

              Hi,

               

              i am wating for your reply it urgent for me.

              I culd not find any soluation.

               

               

              Please help me.

               

              Thanks in advance.

               

               

              Regards

              Ashish

                • Re: error handling script getting error(Script line error)

                  Hi Ashish,

                   

                  you are using 2 for each loops and loading the same file from the folder, thats y the duplicate issue.

                   

                  I think the below script should solve your problem.

                   

                  Set vConcatenate = ;

                  sub ScanFolder(Root)

                            for each FileExtension in 'txt'

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

                   

                   

                                                set ErrorMode=0;

                                                Protection:

                                                LOAD

                                                ID,

                                               Name,

                                               Premium,

                                                                          

                                               FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

                                                Set vConcatenate = Concatenate;

                                               

                                             

                                                next FoundFile

                   

                   

                            next FileExtension

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

                                      call ScanFolder(SubDirectory)

                            next SubDirectory

                  end sub

                   

                   

                  Call ScanFolder('C:\Production\Life\Data');

                   

                  thanks,

                  Shruthi