Lesson 5: SAP Development Mastery
Lesson 5: SAP Development Mastery
1. Custom ABAP CDS Annotations
Enhance CDS views with annotations for metadata-driven configurations.
Enable UI-specific behaviors and OData service generation.
Simplify integration with Fiori apps and APIs.
2. Event-Driven Programming in SAP
Triggers specific logic when predefined events occur.
Implements event handling with ABAP or SAPUI5.
Integrates seamlessly with workflows and backend processes.
3. SAP Security Concepts
Role-based authorization ensures controlled access to resources.
Uses Secure Network Communication (SNC) for data encryption.
Enforces strict authentication and authorization policies.
Code Example 1: Custom Annotation in CDS
@UI: {
selectionField: [{ position: 10 }],
lineItem: [{ position: 20 }]
}
define view ZSalesView as select from zsales {
key id,
customer,
total_amount
}
Explanation
Adds
@UI
annotations for Fiori application integration.Configures selection and line item behaviors.
Exposes
ZSalesView
with metadata-driven behavior.
Code Example 2: ABAP Event Handler
CLASS zcl_event_handler DEFINITION.
PUBLIC SECTION.
EVENTS on_customer_save.
METHODS handle_save FOR EVENT on_customer_save OF zcl_event_handler IMPORTING iv_customer_id TYPE zcustomer-id.
ENDCLASS.
CLASS zcl_event_handler IMPLEMENTATION.
METHOD handle_save.
WRITE: / 'Customer Saved:', iv_customer_id.
ENDMETHOD.
ENDCLASS.
Explanation
Declares and raises the
on_customer_save
event.Implements
handle_save
method to process the event.Outputs the saved customer ID dynamically.
Code Example 3: ABAP Role Check
AUTHORITY-CHECK OBJECT 'ZCUSTOMER_ROLE'
ID 'ACTVT' FIELD '03'
ID 'ZCUSTOMER_ID' FIELD lv_customer_id.
IF sy-subrc = 0.
WRITE: / 'Authorization granted'.
ELSE.
WRITE: / 'Access denied'.
ENDIF.
Explanation
Verifies user access with
AUTHORITY-CHECK
.Checks the custom role
ZCUSTOMER_ROLE
.Grants or denies access based on the result.
Code Example 4: SAPUI5 Event Handling
onCustomerSave: function() {
sap.m.MessageToast.show("Customer saved successfully!");
}
<Button text="Save" press="onCustomerSave"/>
Explanation
Implements
onCustomerSave
event in SAPUI5 controller.Displays a success message on button press.
Enhances user interaction with intuitive feedback.
Code Example 5: SNC Configuration in ABAP
DATA: lv_snc_name TYPE sncname VALUE 'p:CN=SAPServer,O=Company,C=US'.
SET PARAMETER ID 'SNC_PARTNERNAME' FIELD lv_snc_name.
WRITE: / 'SNC connection established with:', lv_snc_name.
Explanation
Configures SNC parameters for secure communication.
Uses
SET PARAMETER ID
for SNC partner setup.Establishes encrypted connections securely.