Query Design Elements: Restricted/Calculated Key Figures, Variables, Conditions, and Exceptions (Part 2)
Preview · a free account unlocks the full lesson
Learn how to build advanced query logic using restricted and calculated key figures, variable types, conditions, and exceptions, and how these choices affect performance and front-end consumption.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Once basic query structure is understood, most real-world reporting requirements need query-level calculations and conditional logic that go beyond simple rows and columns. Restricted Key Figures (RKFs) take an existing key figure and apply a fixed or variable restriction to one or more characteristics, producing a new reusable column such as 'Revenue - Current Year' or 'Quantity - Region North'.
Calculated Key Figures (CKFs) combine existing key figures (including RKFs) using formulas, such as computing a margin percentage from revenue and cost key figures. Both RKFs and CKFs can be defined locally within a single query or saved globally for reuse across multiple queries against the same InfoProvider, which is an important design decision: global reuse reduces duplication but increases the blast radius if the definition changes.
Variables extend beyond simple characteristic value prompts. Common variable types include: characteristic value variables (user enters or defaults a value, e.g., fiscal year), text variables (dynamically change a column header, e.g., showing the selected month name), formula variables (inject a value into a calculation, e.g., an exchange rate), and hierarchy node variables (restrict to a selected node in a characteristic hierarchy).
Variables can be manual input, default values, replacement path (deriving the value from another query or characteristic), or customer-exit (ABAP-based logic for complex derivation, common for 'current fiscal period' logic). Processing type selection matters: manual-input variables require user interaction at runtime, while customer-exit variables run automatically, which is important for scheduled/broadcast queries where no user is present to respond to a prompt.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
More lessons in this topic
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.