Hi Marco - it is not possible to write an api.Data.Calculate the way you have it with Entity defined on the destination script. You can only write to the current Entity being processed which would be defined in the Data Management step. The best way to do this would be to execute a CustomCalculateRule or DataManagementSequence and passing in the Target entities via the parameter dictionary. Below is an example of this. The initial rule would be ran on the Source Entity to write the Allocation Out and then the target entities are looped over and a Custom Calculate rule is executed on those entities to write the Allocation In.
Else If args.CustomCalculateArgs.FunctionName.XFEqualsIgnoreCase("AllocationAcrossEntities") Then
'Calculate the Allocated Out member for ACME (Source Entity)
api.Data.Calculate("A#Rent:F#AllocatedOut:I#None:O#Import = A#Rent:I#None:O#Top:F#EndBalLoad",True)
'Get a list of target entities to write allocation data to
Dim entityList As List(Of Member) = api.Members.GetBaseMembers(api.Pov.EntityDim.DimPk,api.Members.GetMemberId(dimtypeid.Entity,"ACMEGroup"))
'Loop on all the data unit dimensions to trigger the custom calculate
For Each entity As Member In entityList
If Not entity.Name.Equals("ACME") Then
Dim brParamDict As New Dictionary(Of String, String) From {{"Cube", api.Pov.Cube.name},
{"Entity", entity.Name},
{"Consolidation", "Local"},
{"Scenario", api.Pov.Scenario.Name},
{"Time", timedimhelper.GetYearFromId(api.Pov.Time.MemberId)},
{"View", "YTD"}}
'Trigger custom calculate
BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, "Chapter8Examples", "RentAllocation2", brParamDict, CustomCalculateTimeType.AllInYear)
End If
Next entity
Else If args.CustomCalculateArgs.FunctionName.XFEqualsIgnoreCase("RentAllocation") Then
'This function is referenced in the previous function
If ((Not api.Entity.HasChildren()) And (api.Cons.IsLocalCurrencyforEntity())) Then
api.Data.ClearCalculatedData(True,True,True,True,"A#Rent")
Dim totalSquareFootage As Decimal = api.Functions.GetEntityAggregationDataCell("E#ACMEGroup:O#Top:I#Top:F#EndBalLoad:A#SquareFootage:" & _
"U1#None:U2#None:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None").CellAmount
api.Data.Calculate("A#Rent:I#None:O#Import = RemoveZeros(MultiplyUnbalanced(C#Local:E#ACME:A#Rent:O#Top:I#Top, " & _
"Divide(A#Squarefootage:O#Top:I#Top:U1#None:U2#None, " & totalSquareFootage & "),U1#None:U2#None))",True)
End If