Creating business rules
You create User-defined business rules by clicking Maintain > Business Rules and creating a script.
The script is based on functions. For a complete list of available functions, see UDBR functions.
The script must include a source definition and a target definition as a minimum. The source defines the data that should be run in the consolidation. The target defines the data that is created and stored in the consolidation calculations. There are also filter definitions to use in both the source and the target definitions, as well as pre-defined model functionality.
If no other values are defined, the following default values will be used by the UDBR script:
- Source company: Same as in the job definition.
- Current period: Same as used when running the consolidation.
- Manual journal type: REPO
- Automatic journal type: Base
- Journal number: blank
A source definition for a UDBR must include the following parts:
- A start and name definition with the following format: XXXX=Creator.createSource(),
where XXXX is the source name. All source functions must start with
this name.
All source functions in the script must start with the source name followed by a period (.) and then the function.
- A function (setAccount in the example below) and a definition
of what should be retrieved, for example an account code (YYYYYY in
the example below).
Example: XXXX.setAccount(YYYYYY)
- A loaddata function at the end of the definition, that includes
the name of the source.
Example: XXXX.loadData()
A target definition for a UDBR must include the following parts:
- A target and name definition, with the following format: ZZZZ=Creator.createTarget(), where ZZZZ is the target name.
- A function (setAccount in the example below) and a definition
of what should be created and stored as a result of the script, for
example an account code (YYYYYY in the example below).
Example: ZZZZ.setAccount(YYYYYY)
- A mergeAndSaveData function at the end of the definition, that
includes the name of the target.
Example: ZZZZ.mergeAndSaveData()
Example of UDBR - Move data from one account to another account by multiplying it by 1.2
#Define variables used in the script.
#Define the accounts we want to move data from and to.
SourceAccount = 'P10030'
TargetAccount = 'S12080'
source1 = Creator.createSource()
source1.setAccount(SourceAccount)
source1.loadData()
target1= Creator.createTarget()
target1.setAccount(TargetAccount)
target1.addDataWithFactor(source1, 1.2)
target1.mergeAndSaveData()
Procedure
- Click Maintain > Business Rules.
- Click Add a new row.
- Add a Code, Group name, and a Local name.
- Add the source and target definitions and functions for the script. For an overview of available functions, see UDBR functions.
- Click Run Script.
- Specify Actuality, Period, Group and Company Subset.
- Click OK.
Results
To include your script in consolidation by steps, click Group > Consolidate by Steps > User-defined Business Rules. For more information, see Consolidate User-defined business rules.
To include your script in consolidation with status, create a default UDBR job and map it to a consolidation type. For more information, see Create jobs for user-defined business rules.