# Using BRFplus for formula-based (un-)loading times

##### Tags:

Using BRFplus for formula-based (un-)loading times

The flexibility of BRFplus offers the possibility to create formula-based conditions by specifying the dependency of several values in a formula expression. In our case we want to create a condition that determines loading times based on the total weight of a freight unit.

*Example: We want to define the loading time as 10 seconds per 100kg.*

**In the first step we have to create a condition via NWBC including our Condition Type, in this case /SCMTMS/FU_LOAD_DURA and the Origin of the condition which is as mentioned before a BRFplus Expression.**

** **

**As we want to calculate the Loading Time of our Freight Unit based on its weight we have to maintain this value in our Data Access Definition as shown below. **

**When saving this Condition the System triggers the creation of a BRFplus application according to the maintained data. **

**Via the transaction “brfplus” we enter the BRFplus workbench where we have all our applications listed in the column on the left with the search criteria “My Applications” . You should find there the application that has been created before including the relevant elements Load, Unload and Total Weight of a Freight and the function TEST_CALC_DURA_LOAD. **

**We choose our function, which we want to enrich with an expression and change to edit mode. To create a new expression we choose the button next to “<not assigned>” and click on create. In the following pop-up select formula as expression type. Enter a name and description for your expression and create it.**

** **

**Jump into your newly created expression by clicking the link that was former called “<Not assigned>” and now has the name of your expression.**

*Change Result Data Object to Load*

** As a first step we have to change our result data object, as right now it is more or less a simple number without any context. In our case we want to have the time that is required to load a freight unit as the result. Click the symbol next to <Not Assigned> and choose select. An object query will appear where we can search our BRFplus application for Data Objects. In case the Application Name field is empty enter the name of your new BRFplus application. Collapse the “Loading and unloading durations” structure to find the Data Object “Load” of type number. Mark “Load” and click OK. Our Result Data Object has now changed to “Load”.**

*Insert Data Object "Total Weight of a Fr" into the equation*

**Now we can maintain the formula that gives us the value for the Result “Load”. As the central Data Object to get our Result is the Total Weight we have to get this Data Object into our equation. We instantly find it in our context table as our expression and this object are part of the same function. Insert “Total Weight of a Fr” into our equation by clicking on the data object.**

**We now define several steps to determine our loading time:**

*Convert Quantity to KG*

**We want to make sure that the unit of our Weight is always KG, so we insert the function “CONVERT_QUANTITY” in front of our Data Object and add the Unit KG in the second part of the brackets. **

*Changing Data Type from Quantity to Number*

**As the left and the right side of our equation have to be consistent in their data type we have to convert Weight of type quantity into a number. For that reason we enter the function “TONUMBER” in front of “CONVERT_QUANTITY”. Make sure that the whole term we have created before is inside the brackets.**

*Set loading time to 10 seconds per 100 KG*

** As a last step we want to define that every 100KG take 10seconds to be loaded, so we just divide our equation by 100 and multiply it by 10. **

**Use the check button to make sure your object is consistent.**

**In the expression menu as well as in the function menu you can start the option “Start Simulation” to check if your expression is acting as expected for several values.**