11-16-2021 02:20 PM - last edited on 05-02-2023 10:08 AM by JackLacava
Hello,
I'm new to Business Rule, and I'm struggling with the execution of a data management step with type "custom calculate".
Currently, the execution of this script is giving me the message below :
Error processing Data Management Step 'CC_FY2022_BUD'. Unable to execute Business Rule 'CopyData'. Invalid destination data unit in script 'A#Account1:C#Local:T#2022M1:S#Budget:U1#None:U3#T:U8#None:O#Import'.
In the Data Management step, I have defined elements in the POV and Data Units, and "Data Units" elements seem to be taken into account correctly, but elements in the "POV" such as U2, U4, U5, U6, U7 elements that have been defined in the POV of data element task (hierarchy nodes) seem like is not considered in the calculation.
So here are my questions:
- What is the error message mentionned above actually saying ?
- Are POC elements from the Data Element task taken into account in the Finance Business Rules ?
- How do you efficiently debug a Business Rule ?
Many thanks for your prompt answers 🙂
Regards,
Solved! Go to Solution.
11-16-2021 04:55 PM
To expand on what Marc said, my understanding is that you can't have any of these dimensions on the left hand side of an equals sign in a custom calculate business rule:
Cube, Entity, Parent, Scenario, Consolidation, and Time
These dimensions comprise the data unit. When you run a business rule from data management, it re-runs the rule multiple times each of the data units you have specified in the data management job. So when you're inside the rule, you can't choose to send data across to another data unit; you work within the current data unit that is executing for that pass.
You can use conditions in the rule e.g. if you put multiple entities in the data management filter then you can say "if api.pov.entity.name = "HeadOffice" then" in the business rule to focus a piece of logic on one entity.
The odd one out is Scenario for which you can only specify one item in data management. If you wanted to have a process which modified data for Forecast and also for Budget, then you need to have two data management rules, one which specifies Forecast and one for Budget, they could potentially run the same rule / function and do the same thing, but if in the Forecast data management job you said "A#RetainedEarnings = A#xxxx" then it would modify data in the Forecast scenario.
Note that it is possible to cross over to other data units on the _other_ side of the equals sign, e.g.:
V#YTD = V#YTD:S#Actual
Cheers
11-16-2021 02:56 PM
Hi Segey,
the error message is saying it cannot write data to the dimensions specified from the current data unit. It’s important to know that OneStream ‘pulls’ data. So if you have selected e.g s#actual in you do job you cannot write to budget. The same applies to time and cons. So if you want to write to budget 2022m1 those must be in your dm job. You can pull data from other data buffers.
hope that helps
11-16-2021 04:55 PM
To expand on what Marc said, my understanding is that you can't have any of these dimensions on the left hand side of an equals sign in a custom calculate business rule:
Cube, Entity, Parent, Scenario, Consolidation, and Time
These dimensions comprise the data unit. When you run a business rule from data management, it re-runs the rule multiple times each of the data units you have specified in the data management job. So when you're inside the rule, you can't choose to send data across to another data unit; you work within the current data unit that is executing for that pass.
You can use conditions in the rule e.g. if you put multiple entities in the data management filter then you can say "if api.pov.entity.name = "HeadOffice" then" in the business rule to focus a piece of logic on one entity.
The odd one out is Scenario for which you can only specify one item in data management. If you wanted to have a process which modified data for Forecast and also for Budget, then you need to have two data management rules, one which specifies Forecast and one for Budget, they could potentially run the same rule / function and do the same thing, but if in the Forecast data management job you said "A#RetainedEarnings = A#xxxx" then it would modify data in the Forecast scenario.
Note that it is possible to cross over to other data units on the _other_ side of the equals sign, e.g.:
V#YTD = V#YTD:S#Actual
Cheers
11-16-2021 04:56 PM
For the debugging you use the API.logmessage (for financial BR) or BRAPI.errorlog.logmessage (all other) methods. The Databuffer object, has a log method as well, it writes the pov and amount of all cell to the error log.
11-16-2021 07:00 PM - last edited on 04-27-2023 06:52 AM by JackLacava
Oh yeah, I forgot to say, this is a useful thing to put in the Catch statement at the end of your Main function. If an unexpected error occurs it spits out the business rule, entity and time (and any others you add) names to the error log:
Catch ex As Exception
Dim brName As String = Me.ToString
brName = brName.Substring(31)
brName = brName.Substring(0, brName.IndexOf(".MainClass"))
api.LogMessage("Error in " + brName + ", time " + api.Pov.Time.Name + " entity " + api.Pov.Entity.name)
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
11-16-2021 08:03 PM
You can use a memberscript to write outside the dataunit. We are discussing this in the upcoming Planning book
11-16-2021 08:06 PM
I wouldn't use a logmessage inside a loop. It is better to write to a StringBuilder and then log them at the end like Marc suggested inside the exception catch.
11-18-2021 09:15 AM
Awesome ! Thanks for all of your answers !
I was able to get it to work (with the precious help of Level 2 Rules Training 😂 ) and a certain MultiplyUnbalanced function...
Regards,