8 Replies Latest reply: Nov 14, 2013 4:26 AM by Friedrich Hofmann RSS

    How to drop variables from a qvw?

    Friedrich Hofmann

      Hi,

       

      I have a pretty complicated code to find out the valid cost_center for every employee for every single day from his/her join_date to (his/her leaving_date or today).

      The code works for one single employee, I have thoroughly tested it on a few quite difficult scenarios and it was correct all the way.

      Now I've made this into a subroutine and built a FOR...NEXT loop over the employees and call this subroutine once per line (Í pass the line_nr to the subroutine, not the emp_ID, I think that simple consecutive numbers are easiest for QlikView and thus fastest)

      => The code runs error-free through all lines of the employee_list.`

       

      The only remaining problem - I hope it's the only one remaining - is: The loops goes like

      FOR i = 1 TO NoOfRows('Tablename')

        CALL ...

      NEXT

       

      At the end of this, I just wanted to have a look at my counter i to see if it had the right value and I saw just that nr. of variables there - one variable labeled '1', one labeled '2' and so on all the way through to 1.000+

      Is there some way I can drop those along the way?

       

      Thanks a lot!

      Best regards,

       

      DataNibbler

       

      P.S.: I create several variables in every run of the subroutine, with both SET and LET

        • Re: How to drop variables from a qvw?
          Friedrich Hofmann

          I have an idea:

          - The variables really have the same name and value - the variable labeled '1' has the value 1, the one labeled '2' has the value 2 and so on.

          => I suppose this is the line_ID that I pass to the subroutine:

          - This is actually my counter i that I use in the loop

          - I call the sub like >>> CALL Kostenstellenroutine ($(i)) <<<

          => The sub itself begins like >>> sub Kostenstellenroutine (v_lineID) <<<

          => The counter i is thus passed to the sub labeled v_lineID.

           

          => I suppose, but unfortunately I cannot check, that this variable that is left over with every single call of the sub is just this counter.

           

          In another thread on a similar issue, I found that >>> LET [var] = NULL(); <<< could be used <=> I cannot do that because I cannot use the semicolon or my LOOP will stop right there.

          I guess, though, that those variables cost me very little in terms of performance, so I can just build a second LOOP and delete them all?

           

          P.S.: No, obviously it was not that - that second LOOP seemingly did not even execute.

            • Re: How to drop variables from a qvw?
              Srikanth P

              First of all, is it necessary to create lot of variables in the For Loop ?

               

              In loop, we create one variable and change that Variable value in every loop execution.

               

              The another way, just Let vName = ; at end of loop execution its automatically de-allocate the variable.

                • Re: How to drop variables from a qvw?
                  Friedrich Hofmann

                  Hi datu.qv,

                   

                  no, it is surely not necessary - the problem is, all of these variables just have a number as label - I cannot tell at which point in the code they are actually generated.

                  I will have another look at the SET and LET commands in the code - I believe there are several.

                  Thanks a lot!

                  Best regards,

                   

                  DataNibbler

                    • Re: How to drop variables from a qvw?
                      Friedrich Hofmann

                      Hi dathu.qv,

                       

                      I looked through my code and though there are a few variables inside the subroutine, those are updated with every calling of the subroutine.

                      => It looks very much like those variables are something to do with my counter.

                      I post the code of my loop here, there's nothing much to it:

                       

                      // Here I load a list of the emps we have RESIDENT from the base_load - a step that might be skipped...

                      Mitarbeiterliste:

                      LOAD
                        
                      GPEline
                      RESIDENT MA_Grunddaten2
                      ;

                      // this variable is also just for my own information and not relevant to the functioning of the code.
                      LET v_emps = NoOfRows('Mitarbeiterliste');


                      FOR i = 1 TO NoOfRows('Mitarbeiterliste')
                       
                      CALL Kostenstellenroutine ($(i))
                      next

                       

                      Now, that counter i takes on the values from 1 to, say, 1000 - and I have just the same nr. of variables created.

                      Can you tell me what's wrong there?`

                      Thanks a lot!

                      Best regards,

                       

                      DataNibbler