7 Replies Latest reply: Jun 19, 2010 10:52 AM by 780133 RSS

    LOOP..ENDLOOP does not break in the calculation script

    780133
      Hi experts,

      my problem is that LOOP does not break in the calculation script below.
      any advice.

      thanks.


      LOOP (10000,quit)
      FIX ("Jan",@relative("person"))

      "wage"
      (

      quit=0;

      IF ("wage"->"wage_type"->"begbalance"==2) /*if wage is net*/

      IF (("wage"->"begbalance" - "Net_paid" >=0 ) AND ("wage"->"begbalance" - "Net_paid" <0.000000000001 ))

      quit=1;

      ELSEIF (("wage"/ "wage"->"begbalance" ==0) OR ("wage"/ "wage"->"begbalance" ==#MISSING))

      "wage"->"begbalance" * 2.34 ;

      ELSEIF ("wage"/ "wage"->"begbalance" ==2.34)

      "wage" - ("Net_paid" - "wage"->"begbalance");

      ELSE

      "wage" - ("Net_paid" - "wage"->"begbalance");

      ENDIF
      ENDIF
      )

      ENDFIX
        • 1. Re: LOOP..ENDLOOP does not break in the calculation script
          776485
          Hi,

          First of all, I don't understand why you were using LOOP in this script.

          what is the purpose of executing same sentences again and again...?

          - Krish
          • 2. Re: LOOP..ENDLOOP does not break in the calculation script
            780133
            I am trying to find gross wage by using net wage and I found a formula to do that.
            So this is the only formula calculating what I want.
            If essbase had had something like "do while ..." command , it would be much easier for me to do the iteration depending on a condition instead of using loop.

            I need some advice please. I would be really grateful.

            tnx.
            • 3. Re: LOOP..ENDLOOP does not break in the calculation script
              776485
              Fine, though i dont know much about your requirements & your sturcture.

              The one thing I can say is you need to check whether the following statements are resulting TRUE in any case.

              IF ("wage"->"wage_type"->"begbalance"==2) /*if wage is net*/

              IF (("wage"->"begbalance" - "Net_paid" >=0 ) AND ("wage"->"begbalance" - "Net_paid" <0.000000000001 ))

              IF any of the above two IF statements never yield TRUE, your script will keep on looping for 10000 times for each member combination.

              - Krish
              • 4. Re: LOOP..ENDLOOP does not break in the calculation script
                637316
                The reason the it won't stop is that quit does not get evaluated until the FIX is complete. Everytime you process another person quit gets set to 0. Remember, essbase processes the list of users 10000 times. It does not process a single user 1000 times and then move to the next. When the loop evaluates the quit value is determined by the last person.

                The real problem here is that you are thinking procedurally. As you gain more experience you will start to think multi-dimensionally and then the scripting language starts to make sense.

                To find a solution, maybe you should post what you are trying to achieve. Someone can probably help you and it will run a heck of a lot faster than loop 10000.

                Regards,
                Dave
                • 5. Re: LOOP..ENDLOOP does not break in the calculation script
                  776485
                  I agree with Dave here... if you could throw more light on your requirements, someone would be able to help you in finding a solution or say a better solution.

                  - Krish
                  • 6. Re: LOOP..ENDLOOP does not break in the calculation script
                    780133
                    thank you Dave and Krish for the quick answers

                    Actually , Dave approved something that I was always questioning myself since I become a planning consultant in hyperion.
                    I was a software developer for years so I am used to pure programming logic. in a way that seems to be an advantage but it also directs me wrong way as in this case. Right now I have no idea what is the transaction sequence when a script runs in essbase.

                    anyway,after reading the posts I realized I must make some changes in my fix statement. will let you know the result.

                    regards,
                    • 7. Re: LOOP..ENDLOOP does not break in the calculation script
                      780133
                      I just tried the script below to understand the loop logic.


                      FIX ("Person","Jan")

                      var c=0;

                      LOOP(2)
                      "wage"
                      (
                      c=c+1;
                      c;
                      )
                      ENDLOOP

                      ENDFIX

                      I expected that the result of the calculation would be wage = 2 but instead I found wage = 10.
                      I tried this with LOOP(2) too and the result was wage = 19.

                      it is like when loop = 1 c= 1
                      when loop = 2 c= 10
                      when loop = 3 c= 19

                      I am completely lost in LOOP logic. How does this logic work.