5.1 Rules Engine Fundamentals: Scenarios, Base Objects, MDF Rule Events, and the Execution Log
Key Takeaways
- Business rules are built in Configure Business Rules from a rule scenario, a rule ID without spaces, a start date, and a base object.
- A rule runs only after it is assigned; assigned rules cannot be deleted until the assignment is removed.
- For MDF objects, Initialize rules run before all other rules and only when a new record is created; field-level assignment supports only onChange.
- Validate rules run before Save rules and also run during import validation in Import and Export Data.
- A Business Rule Execution Log trace can run for at most two days and traces the user who executes the rule.
5.1 Rules Engine Fundamentals: Scenarios, Base Objects, MDF Rule Events, and the Execution Log
Quick Answer: A business rule is created in Configure Business Rules from a rule scenario. It has a base object, IF conditions, THEN (and optional ELSE) actions, and it runs only when assigned to an object, field, or setting with a rule event. For MDF objects the events are Initialize, Validate, Save, Post Save, onChange (field level), Delete, On Load, and UI rules. The Business Rule Execution Log traces rules for troubleshooting.
What Rules Are Used For
Rules add application logic without code. THR80 lists typical uses:
- Workflow: pick the right approval workflow, for example an alternate workflow if a salary increase exceeds 10%
- Propagation: copy data from one field to another, for example the job code into a position
- Calculations: for example current age from date of birth
- Validation: check input before saving, for example FLSA status required when the country is USA
- Eligibility: for example who is eligible for a compensation or variable pay form
- Defaulting values: for example new hires in a given company are eligible for stock with a default grant
The rules engine is technically based on MDF but has its own tool, Configure Business Rules. MDF must be enabled (Enable Generic Objects in Provisioning), and the administrator needs Metadata Framework > Configure Business Rules.
Separating View and Edit Rights for Rules
To distinguish viewing from editing rules, open the Rule object in Configure Object Definitions. Set Secured = Yes, Permission Category = Business Rules Object Permissions, and CREATE Respects Target Criteria = Yes. Then grant View Rules (View Current, View History) or Edit Rules (plus Create, Insert, Correct, Delete). Field-level overrides are not respected here. Target criteria can separate rule authorizations by area, for example Time Management admins versus Recruiting admins.
Creating a Rule
Choose + (Create New Rule), pick a rule scenario, and fill in:
- Rule Name: the label shown in search.
- Rule ID: the unique identifier. The name is copied in automatically, but best practice is no spaces in the ID; an ERD rule with spaces in its ID won't trigger correctly.
- Start Date: the rule applies only from this date. The default is 01/01/1900.
- Rule Type: optional grouping for Basic rules, from the RuleType picklist.
- Description: optional business context.
- Base Object: the object whose fields and related objects the rule can use. Application-specific scenarios define or limit the base object.
Rule scenarios are rule templates grouped by application (Employee Central Core, Metadata Framework, Position Management, and so on). You see only scenarios for enabled applications. Legacy Basic rules can be migrated to application-specific scenarios one at a time (Change Scenario) or in bulk through the Check Tool (Migration > Business Rules Application).
Building the Logic
Statements follow the pattern left expression – operator – right expression.
- Left expression: base-object data, functions, additional MDF objects, variables, Current User, or Effective Date.
- Right expression: a field type or value, fields of the same type, functions for that type, variables, Current User, Effective Date, or Null.
| Operator | Field types |
|---|---|
| is equal to / is not equal to | all types |
| is greater than, is less than, greater than or equal, less than or equal | Number, Decimal |
| is before, is on or before, is after, is on or after | Date |
Collection filters select one value from a list where a parent-child relationship exists. For example, Job Relationship is a child of Job Information, so a filter picks the HR Manager relationship (Select… where…).
IF defines the condition, THEN the action, and ELSE the action when the condition is false. Setting IF to Always True makes the THEN run every time the rule is triggered.
MDF Rule Events
For MDF objects, rules are assigned in Configure Object Definitions, at object level or in a field's details. Only onChange can be used at field level.
| Event | When it fires | Typical use |
|---|---|---|
| Initialize | Before all other rules, only when a new record is initialized | Default values |
| Validate | After submit, before save. Also runs during import validation in Import and Export Data. | Validate input and raise errors |
| Save | When the user saves | Set values from input before saving |
| Post Save | After the change is saved | Alerts; not for setting values |
| onChange | When a specific field changes (field level) | Populate another field |
| Delete | After a record is deleted | Follow-up logic |
| On Load | When a UI loads | Calculate displayed totals |
| UI rules | Only in a Configurable UI screen | Show, hide, or require fields; not applied on import |
Warning messages from Validate and Save rules appear before workflow confirmation messages.
Assigning Rules
A rule is only triggered when it is assigned. Depending on the scenario, you assign it to an object, a business process, an event, a screen, or a setting. The rule list shows an assignment icon: a green check means assigned, grayed out means not assigned, and empty (white) means no assignment information (for example Basic rules). The icon opens a wizard that links to the right assignment page. Assigned rules cannot be deleted; remove the assignment first. You can export the list of rules with their assignments as a CSV.
The Business Rule Execution Log
The Business Rule Execution Log traces a rule's execution. It needs the Access to Business Rule Execution Log permission. There are separate permissions to create a trace and to create and view logs; SAP advises limiting viewing because logs can contain sensitive data.
- Choose Create New > Rule Trace, enter a name and code, a start and end date (maximum two days), the user who executes the rule (not the user whose data changes), and optionally specific rules (blank traces all rules for that user).
- Reproduce the transaction, then Download the CSV log.
- Each log file is limited to 5 MB. When the limit is reached, no more entries are written until the file is deleted. Deleting the log keeps the trace definition.
For EC transactions, the Diagnostic Tool adds a rule execution view (Section 10.2).
An MDF rule must set default values that users see as soon as a new record is created. Which event should it use?
A consultant creates a rule trace in the Business Rule Execution Log. Which setting is correct?
An administrator tries to delete an application-specific rule and gets an error. What is the most likely reason?