In the realm of SAP development, the ABAP RESTful Application Programming Model (RAP) has emerged as a powerful framework for building efficient and scalable Fiori Elements applications. With RAP, developers can focus on implementing custom business logic, while the framework handles common functionalities.
Among RAP’s capabilities, defaulting action parameters stand out as a way to streamline user interactions. Non-standard operations (like actions or functions in a business object) often require parameters, which can be defaulted using context-aware logic. This blog focuses on different ways to default action parameters in a Fiori Elements application built on RAP, with a special emphasis on defaulting parameters using complex business logic.
The Purpose of Defaulting Action Parameters
The primary goal is to enhance user efficiency by pre-filling form fields with relevant values. This:
-
Reduces manual data entry.
-
Minimizes errors.
-
Ensures consistency across the application.
-
Adapts to varying business scenarios and user-specific requirements.
Defaulting Options in RAP
1️⃣ Default Action Parameter with a Constant Value
3️⃣ Default Action Parameter with Complex Business Logic
This approach enriches the business logic, allowing RAP applications to dynamically determine default values based on conditions, calculations, and data queries.
Business Scenario
For example, converting a Purchase Requisition (PR) into a Purchase Contract (PC) involves:
-
Prefilling optional but mandatory fields (e.g., validity dates).
-
Allowing modification of certain fields (e.g., description).
-
Determining complex fields dynamically (e.g., supplier).
Implementation Steps
✅ Define the action with a defaulting function:
✅ Implement the function in the behavior class:
✅ Consume the function in the projection behavior:
use function GetDefaultsForConvert_Into_PC ;
Key Considerations
-
Multiple Selections: If multiple records have different default values, fields will appear blank.
-
Function Naming: Must start with
GetDefaultsFor
followed by the action name. -
Create Scenarios: Use
%cid
instead of%tky
for create or create-by-association actions. -
Release Information: This feature is available as part of the 2311 BTP release.