Maintain calculation logic
Maintain calculation logic (formula builder)
The calculation logic (formula builder) settings are usually done by the IT department in the customizing based on the given rules / defined requirements from business departments. However, the handling should be described here to give a better overview above the general calculation context of CM behavior.
Usage
The main calculation of final commission value should happen within the SAP standard “formula builder”, used by commission management.
Because each formula builder logic / calculation is fix assigned to a single calculation type, the point of entry to the corresponding formula builder application is done via a button in calculation type customizing (by pressing icon formula builder).
Maintain calculation logic - entry formula builder via settings
In general, there are no preconditions required to use the formula builder, just a calculation type must be defined. However, each customer requirement concerning commission calculation will be very different and in most cases we expect some additional values / enhancements will be required.
To get this additional values / enhancements, there are a various of different possibilities within commission management. But some are maybe not the best way to do and so we set here some general rules to get a proper solution:
- All values from commission based documents (e.g. invoice, VSS order, vehicle), that should be used for calculation and could be changed within these documents after commission creation, should be copied to commission header structure extension during commission creation.
- All values that should be used for calculation and can be determined already before formula builder, should be enhanced by own parameter structure and values should be filled by own BAdI implementation (in case fields are not already in the commission header enhancement)
- All values that should be used for calculation, but determination is based on results of the formula builder logic, should be enhanced by own function class and own methods within this class
- The result structure of the formula builder should only hold information, that are calculated during formula builder logic and which could not be determined later on e.g. name of salesman for displaying in HTML calculation sheet makes no sense to transfer
Entered to the formula builder maintenance screen, the shown areas are always the same -just the provided values could be different, depending on the calculation type and the provided enhancements.
To learn in detail, how to work with formula builder application, we refer to the SAP standard documentation in SAP help portal.
However, here we will give a short overview about the main areas of the application:
Maintain calculation logic - formula builder overview
- Area 1 - “overview”
The overview shows all for the own calculation defined steps.
Here we make difference between step types “conditions” and “substitutions”.
- condition if condition with result true / false
- substitution single logic line
To add a new step, mark the corresponding line after that you want to enter new step and press right mouse button to pen context menu and choose condition / substitution.
Maintain calculation logic - create new condition / substitution
In addition, you have by calling the context menu also the possibility to move a single step up / down (also possible by drag&drop), to copy or to delete marked step.
- Area 2 - “step”
Here you define description of your step, shown in the overview screen.
The description itself is obligatory, but we recommend to do it, to keep better overview about your calculation logic. - Area 3 - “parameter”
Shows a list of fields, which could your result value. It doesn’t matter if this is a final result or just a “help result for handling”. So for each substitution entry you must define a parameter as target of your calculation logic. The following parameter values are provided:- Total commission value - transferred to commission header
- Some standard work fields from type text - no transfer
- Some standard work fields from type value - no transfer
- Fields of customer enhancement “substitution structure” – transferred to commission calculation
- Areas 4 - “value type”
Here you define if your result should be a fix value or a formula result. - Areas 5 - “logic definition”
In case you choose in the area before the value formula result, you must enter here your formula. To build up your formula you can use the available fields and functions (see next areas).
Using the icon you can switch here between “description mode” and “technical mode” (expert mode).
Examples for logic definition:
- Using standard functions
- Value Item Type 01 + Value Item Type 02
- ABS( Value Item Type 04 / Base value vehicle ) * 100
- Using VSS functions
- LOOKUP_PROVISION_ITEM_VALUE( PROV_DATA-PRNUM, '01' )
- LOOKUP_CONDITION( 'ZPVE', Document Date, Percentage discount of vehicle value, 'VKORG', Sales Organization, 'VTWEG', '00', 'PMATN', Material, '', '', '', '' )
- Areas 6 - “available field”
Shows a list of fields, which could be used to build up the formula logic. So for each condition / substitution entry you can use this fields in combination with the available functions to create condition or to fill the chosen parameter. The following available fields are provided:- Standard commission header data
- VSS standard work fields from type text (see also parameter)
- VSS standard work fields from type value (see also parameter)
- Some standard SYST data
- Fields of customer enhancement “parameters”
- Fields of customer enhancement “substitution structure”
- Areas 7 - “available function”
Shows a list of functions, which could be used to build up the formula logic. So for each condition / substitution entry you can use this fields in combination with the available fields to create condition or to fill the chosen parameter. The following available fields are provided:- Arithmetic functions
- Logical functions
- Character functions
- VSS standard functions
- VSS customer enhanced functions (by class / methods)
Because the description in some cases is not so clear, the complete handling of formula builder can be switched to expert mode.
Maintain calculation logic - switch to expert mode
In that case, the single steps in the overview area shown with the technical names, like in the following screen:
Maintain calculation logic - formula builder example logic in expert mode
Authority check
No specific authority checks
Customer Enhancement
Formula builder logic itself is the enhancement