Lesson 9: Advanced Development and Optimization in SAP
Lesson 9: Advanced Development and Optimization in SAP
1. ABAP RESTful Application Programming (RAP) Advanced Scenarios
RAP supports draft handling for transactional applications.
Enables authorization checks using CDS annotations and behavior definitions.
Simplifies debugging with seamless integration in ABAP Development Tools.
2. SAP Workflow and Automation with APIs
Automates tasks by invoking workflow APIs.
Manages dynamic task routing using SAP Gateway services.
Ensures efficient workflow orchestration across systems.
3. SAP Performance Tuning with SQL Trace
SQL Trace (
ST05
) analyzes database calls in ABAP programs.Identifies long-running queries and optimizes table joins.
Enables better indexing for improved execution times.
Code Example 1: RAP Draft Handling
define behavior for ZOrderView alias Order
implementation in class ZCL_ORDER_HANDLER unique
{
draft;
lock;
create;
}
Explanation
Configures draft handling and locking for RAP entity
ZOrderView
.Allows data save without finalizing creation.
Associates draft behavior with
ZCL_ORDER_HANDLER
.
Code Example 2: Workflow Task Creation Using API
DATA: lv_task_id TYPE swr_struct-task_id.
CALL FUNCTION 'SAP_WAPI_CREATE_WORKITEM'
EXPORTING
task = 'TS12300001'
objtype = 'ORDER'
IMPORTING
workitem_id = lv_task_id.
Explanation
Creates a workflow task using
SAP_WAPI_CREATE_WORKITEM
.Associates the task with a specific object type.
Returns the generated task ID for tracking.
Code Example 3: ABAP SQL Trace Execution
DATA: lt_trace TYPE TABLE OF st05_trace.
CALL FUNCTION 'ST05_START_TRACE'.
SELECT * FROM zcustomer INTO TABLE lt_trace.
CALL FUNCTION 'ST05_STOP_TRACE'.
Explanation
Starts SQL Trace using the
ST05_START_TRACE
function.Executes a database query on the
zcustomer
table.Stops the trace for further analysis.
Code Example 4: Dynamic Workflow Task Routing
DATA: lv_user TYPE sy-uname.
CALL FUNCTION 'RH_DYNAMIC_AGENT_ASSIGN'
EXPORTING
task = 'TS12300002'
agent_user = lv_user.
Explanation
Dynamically assigns a workflow task to a user.
Uses
RH_DYNAMIC_AGENT_ASSIGN
for task routing.Simplifies task delegation based on runtime conditions.
Code Example 5: RAP Authorization Check
define behavior for ZProductView alias Product
implementation in class ZCL_PRODUCT_HANDLER unique
{
authorization master ( instance = CDS ZAuthInstance );
}
Explanation
Implements RAP authorization checks for
ZProductView
.Links instance-based authorization with CDS
ZAuthInstance
.Ensures secure access control in transactional scenarios.