03-04-2024 05:03 AM
Dear Community,
I am trying to run an allocation finance rule. I believe I have set up everything for that in the business rule.
However, upon running the BR I get the message "An internal method is not implemented"
Please find below the business rule (currently set on a demo asset) :
Dim MyAllocationType As allocationtype = Allocationtype.EvenDistribution
Dim MyAllocationOptions As New allocationoptions
Dim MyAllocationResult As New AllocationResult
MyAllocationOptions.AllocationType = MyAllocationType
If MyAllocationType = AllocationType.EvenDistribution
' The value to allocate
MyAllocationOptions.SourcePOVMemberScript = "Cb#Houston:E#[Houston Heights]:C#USD:S#BudgetV2:T#2022M12:V#Periodic:A#2000_100:F#None:O#Import:I#None:U1#None:U2#Mach5:U3#NA:U4#[Active Hub]:U5#None:U6#None:U7#None:U8#None"
' Any override to be done on source value
MyAllocationOptions.SourceCalcScript = "A#SourcePOV * 0.1"
' Target POV, must be lowest level on all dim except the one being allocated
MyAllocationOptions.DestPOVMemberScript = "Cb#Houston:E#[Houston Heights]:C#USD:S#BudgetV2:T#2022M12:V#Periodic:A#2000_100:F#None:O#Forms:I#None:U1#None:U2#Mach5:U3#Connecticut:U4#[Active Hub]:U5#None:U6#None:U7#None:U8#None"
' Dimension being allocated
MyAllocationOptions.DimTypeName = "UD4"
' Filter to define which elements will be allocated
MyAllocationOptions.DestMemberFilter = "U4#Root.Base"
' Should zeros be saved with "no data" attribute
MyAllocationOptions.SaveZerosAsNoData = True
' Calculate allocation result based on the allocation options
Myallocationresult = api.Data.CalculateAllocationResult(MyAllocationOptions)
End If
Any ideas where this might come from ?
Regards,
03-04-2024 05:15 AM
The CalculateAllocationResult function takes 2 parameters: session information and allocation options. Try this:
Myallocationresult = api.Data.CalculateAllocationResult(si, MyAllocationOptions)
03-04-2024 05:50 AM
Hi Marcus,
Thank you for your feedback. The intellisence is giving a contradicting info :
There is also a compiling error when you add the "si," .
Regards,
03-04-2024 06:01 AM
There is an example in GolfStream: Dashboard Extender, DBP_SolutionHelper. That uses BRApi rather than api and that call needs si:
If allocPrice > "" Then
allocOptions.SourcePOVMemberScript = memberScript & ":A#[List Price]"
allocOptions.SourceCalcScript = allocPrice
allocOptions.DestCalcScript = "|SourceAmount|)"
allocResult = brapi.Finance.Data.CalculateAllocationResult(si, allocOptions)
brapi.finance.data.SaveAllocationResult(si, allocResult)
End If
03-04-2024 09:32 AM - edited 03-04-2024 09:38 AM
Hi @Sergey
I can confirm this error in versions 7.3.3, 7.4.2, and 8.1 using your code:
' Initialize allocation options with proper properties set
Dim allocationOptions As New AllocationOptions With {
.AllocationType = AllocationType.EvenDistribution,
.SourcePOVMemberScript = "Cb#Houston:E#[Houston Heights]:C#USD:S#BudgetV2:T#2022M12:V#Periodic:A#2000_100:F#None:O#Import:I#None:U1#None:U2#Mach5:U3#NA:U4#[Active Hub]:U5#None:U6#None:U7#None:U8#None",
.SourceCalcScript = "A#SourcePOV * 0.1",
.DestPOVMemberScript = "Cb#Houston:E#[Houston Heights]:C#USD:S#BudgetV2:T#2022M12:V#Periodic:A#2000_100:F#None:O#Forms:I#None:U1#None:U2#Mach5:U3#Connecticut:U4#[Active Hub]:U5#None:U6#None:U7#None:U8#None",
.DimTypeName = "UD4",
.DestMemberFilter = "U4#Root.Base",
.SaveZerosAsNoData = True
}
' Initialize the allocation result variable
Dim allocationResult As AllocationResult = api.Data.CalculateAllocationResult(allocationOptions)
@MarcusH si is not needed as an argument to the data api method CalculateAllocationResult. The api object arrives in the Main method parameter already initialized with a SessionInfo assigned. BRApi is uninitialized with SessionInfo so the object is passed in to it's methods. No need to use BRApi in a finance rule for finance things. 🙂
The error suggests a situation internally where the existing logic is not ready for the supplied options / parameters combination.
Personally, I'd skip this API and write my own allocation calc using standard business logic. The constructor signature for AllocationOptions is huge 15 parameter beast. Without proper examples all but the most clairvoyant will be challenged by it's implementation. Consider KISS and and write your alloc using standard calculate() methods and DataBuffers.
AllocationOptions:
Public Sub New( 'AllocationOptions
allocationType As AllocationType,
sourcePOVMemberScript As String,
sourceCalcScript As String,
sourceTransferPOVMemberScript As String,
sourceTransferOffsetPOVMemberScript As String,
destPOVMemberScript As String,
dimTypeName As String,
destMemberFilter As String,
dimTypeName2 As String,
destMemberFilter2 As String,
destOffsetPOVMemberScript As String,
weightCalcScript As String,
destCalcScript As String,
translateDestIfDifferentCurrency As Boolean,
saveZerosAsNoData As Boolean)
03-04-2024 10:18 AM - edited 03-04-2024 10:19 AM
Hello @RobbSalzmann @MarcusH
Thank you both for your feedbacks. I really wanted to leverage this allocation principle, I'll have a go with internal people to see if I haven't missed anything, but thank Robb for the suggestion using my own calculate logic.
(it's also not working on 8.2 beta).
Regards,