4 Replies Latest reply on Mar 29, 2017 7:16 PM by 3020702

    HFM Rulefile populating local variable

    3020702

      Hi,

       

      I am trying to initialize a variable based on trigger value which I created. There are 12 conditions and this variable is being used in 7 subroutines,to decrease the code I created a sub procedure Scenario to initiate this variable. I am able to populate variable strScenario in scenario procedure ,which I created for this. But I am not able to get it populated in all other procedures . All the procedures are called from sub calculate procedure as shown below which gets triggered during consolidation. I used write to file and found out that it is just being populated in the main procedure but it is empty in all other procedures. I even tried calling all the procedures from Scenario procedure where the strScenario is initialized but even then it is not getting populated in the other procedures.Can you please help me if I am missing something.

       

      Attached below is sample code which explains what I am trying to do.

       

      Sub Calculate()

       

      intTrigger = Round(Hs.GetCell("A#Trigger.S#" & strTarget & ".P#Cur.Y#Cur.E#[None]"  & Nones))

       

      Call Scenario(povScen,intTrigger)

       

      Call BalancesheetFlow(povYear, povScen, povNum, IsTrans, BaseEnt,strScenario)

       

      End Sub

       

      //////////////////////////////////////scenario Procedure//////////////////////////////////////////////////////////////

       

      SubScenario(povScen,intTrigger)

      strScenario =""

      If UCase(povScen) = "ACTUAL" Then

         strSourceScenario = ".S#Actual"

      ELse

        If intTrigger = 1 Then

        strScenario = ".S#Actual"

        ElseIf intTrigger = 2 Then

        strScenario = ".S#WrkFcst"

      Else

      End If

      End If

      End Sub

       

      //////////////////////////////////////BalancesheetFlow//////////////////////////////////////////////////////////////

       

      Sub BalancesheetFlow(povYear, povScen, povNum, IsTrans, BaseEnt,strScenario)

       

      Hs.Exp "A#" & strBSList(i) & ".C2#BB = A#CTA_TOT.Y#Prior.P#Last.C2#EB"& strScenario

       

      End Sub

       

      Thanks,

      SA

        • 1. Re: HFM Rulefile populating local variable
          SH_INT

          This question probably belongs in the  Financial Management discussion group. However your issue is that you are decalring a local variable in the Sub Scenario procedure and are then expecting it to be available in the containing SubCalculate procedure, that will not work. What you need is have a Function Procedure which will return the scenario value back to the calling Sub procedure i.e. in your use case the code would be

           

          Sub Calculate()

           

          intTrigger = Round(Hs.GetCell("A#Trigger.S#" & strTarget & ".P#Cur.Y#Cur.E#[None]"  & Nones))

           

          strScenario = Scenario(povScen,intTrigger)

           

          Call BalancesheetFlow(povYear, povScen, povNum, IsTrans, BaseEnt,strScenario)

           

          End Sub

           

          //////////////////////////////////////scenario Procedure//////////////////////////////////////////////////////////////

           

          Function Scenario(povScen,intTrigger)

          strScenario =""

          If UCase(povScen) = "ACTUAL" Then

              strSourceScenario = ".S#Actual"

          Else

              If intTrigger = 1 Then

                 strScenario = ".S#Actual"

             ElseIf intTrigger = 2 Then

                 strScenario = ".S#WrkFcst"

             Else

             'You should really have some code here to set your default scenario value

             End If

          End If

          Scenario = strScenario

          End Function

          • 2. Re: HFM Rulefile populating local variable
            3020702

            Hi,

             

            Creating function worked in populating the variable . But when I populate the strScenario as Actual  and my pov scenario is WRKFCST. Does the below expression mean I am writing data from Actual to WRKFCST ,that is what I am trying to do or is it  going to write from Actual to Actual.

             

            Hs.Exp "A#" & strBSList(i) & ".C2#BB = A#CTA_TOT.Y#Prior.P#Last.C2#EB"& strScenario

             

            Thanks,

            SA

            • 3. Re: HFM Rulefile populating local variable
              SH_INT

              It is writing from Actual to WRKFCST. Lefthand side of the HS.Exp equation is where data is going to be written to, the right hand side is where you are getting the data from i.e pull data from all valid intersections on the right of the '=' sign to all valid intersections on the left. On the left Scenario,Year,Period,Value and Entity are always set from the POV and cannot be overriden so if your POV scenario is WRKFCST that it where the data will be being pulled to on the left of the equation

              • 4. Re: HFM Rulefile populating local variable
                3020702

                Hi,

                 

                Is it possible to use the variable strScenario in other function. I need to use it in a function in the one of sub procedure. I tried calling the function strScenario = Scenario(povScen,intTrigger) to populate it in Function STA(Acct).I even tried manually writing the condtions in function strScenario in the new function.But both of them  did not work. Can you please let me know what is the best approach to do this.

                 

                This is what I am trying to do

                 

                Subtest(strScenario)

                HS.Exp "A#CF_IC_ACCR_INT.C1#CF_Calc" & C1C3Nones & " = " & STA("IC_ACCRD_INT")

                Endsub()

                 

                Function STA(Acct)

                strScenario = Scenario(povScen,intTrigger)

                 

                STA="(A#" & Acct & C3Tops & ".P#Last.Y#Prior" & strScenario& _

                  "- A#" & Acct & C3Tops & ")"

                 

                End Function