Lesson 4 of 5
Custom logic and custom analytical queries
9 min
Fields and screens are about data and layout. Sometimes the requirement is about behavior: check this value, default that one, warn the user. Sometimes it is about insight: show me open fleet orders by contract. Key user extensibility has tools for both, and both need more governance than a field.
Custom logic
The Custom Logic app lets a key user write a small implementation for an extension point that SAP has released for this purpose (technically, a Business Add-In). Each extension point has a defined moment (for example, when a sales document is checked before saving) and a defined set of data it can read and change. The key user writes the logic in a web-based editor using a restricted, safe subset of ABAP and can test it with sample data before publishing.
| Typical use | Example |
|---|---|
| Validation | Warn or stop when a fleet order has no contract number |
| Default value | Propose the fleet segment from the customer's classification |
| Derivation or substitution | Fill a custom field from other values; SAP also offers extension points such as journal entry substitution in finance |
| Field control | Make a field read-only in certain situations, where the extension point supports it |
What custom logic is typically used for.
To see whether logic actually runs, SAP provides a Custom Logic Tracing app, which records when an implementation is called and with which values. It is a key user's best friend when a validation "does nothing".
Custom analytical queries
The Custom Analytical Queries app lets a key user build a query on a released analytical data source (a CDS view that SAP has prepared for analytics), choosing fields, filters, measures and calculations. The result can be used in analytical apps and on the launchpad. Custom fields enabled for the relevant data source can be included.
| Custom logic | Custom analytical query | |
|---|---|---|
| Changes process behavior? | Yes | No; it reads data |
| Main risk | Stopping or altering transactions | Wrong numbers leading to wrong decisions |
| Typical test | Positive and negative transactions in the scenario | Reconcile the query result with a known total |
| Owner | Process owner of the affected process | Owner of the report and its users |
Governance
- A request and approval. Each extension starts from a requirement approved by the process owner.
- An inventory. Keep a register of every field, logic implementation and query: purpose, owner, business context, transport status.
- Naming rules. Agree how fields and queries are named so they can be found and understood later.
- Limits. Decide what key users may do alone and what needs a developer or architect review, for example logic in finance postings.
What would you do?
After Contoso publishes a custom validation for fleet contract numbers, the order desk reports that orders for a non-fleet customer are also being stopped. What should Maria do first?
- Custom logic implements released extension points with restricted ABAP for validations, defaults and derivations.
- Treat logic as code: specification, review, positive and negative tests, owner.
- Custom Logic Tracing shows when logic runs and with which values.
- Custom analytical queries read released data sources; reconcile them before use.
- Keep an inventory of all extensions with owners and approval.
Check your understanding · not graded
Lesson check
1. What does a key user implement in the Custom Logic app?
2. Which app helps you see whether custom logic was called and with which values?
3. What is the main risk of a custom analytical query?
4. How should a validation be tested?