Lesson 2: Advanced SAP Development Concepts

Lesson 2: Advanced SAP Development Concepts


1. ABAP Object-Oriented Programming

  • Implements modular and reusable components using classes and interfaces.

  • Enhances development with polymorphism and inheritance.

  • Simplifies complex business logic handling.


2. SAP Gateway and OData Services

  • Exposes SAP data as OData services for consumption.

  • Enables integration with external web and mobile apps.

  • Supports CRUD operations through REST-based services.


3. Debugging and Performance Optimization

  • Utilize ABAP debugging tools for runtime issue detection.

  • Optimize database queries using SQL trace and indexes.

  • Analyze performance with SAP HANA Performance Monitor.


Code Example 1: ABAP Class and Method

CLASS zcl_customer_handler DEFINITION.
  PUBLIC SECTION.
    METHODS display_customer IMPORTING iv_customer_id TYPE zcustomer-id.
ENDCLASS.

CLASS zcl_customer_handler IMPLEMENTATION.
  METHOD display_customer.
    WRITE: / 'Customer ID:', iv_customer_id.
  ENDMETHOD.
ENDCLASS.

Explanation

  1. Defines a class zcl_customer_handler with a method.

  2. display_customer method outputs the passed iv_customer_id.

  3. Demonstrates modular ABAP programming.


Code Example 2: SAPUI5 OData Service Binding

this.getView().getModel().read("/Customers", {
  success: function(data) {
    console.log("Customer Data:", data);
  },
  error: function(err) {
    console.error("Error:", err);
  }
});

Explanation

  1. Reads customer data from an OData service endpoint.

  2. Handles success and error callbacks for results.

  3. Integrates SAP Gateway with SAPUI5 for real-time data binding.


Code Example 3: ABAP Data Dictionary Table Creation

TABLES: zcustomer.

APPEND INITIAL LINE TO zcustomer ASSIGNING <fs>.
<fs>-id = '001'.
INSERT zcustomer FROM <fs>.

Explanation

  1. Uses TABLES to reference a Data Dictionary object.

  2. Appends and assigns initial data to a structure.

  3. Inserts data into the database table zcustomer.


Code Example 4: SAP OData Service Implementation

METHOD get_entityset.
  SELECT * INTO TABLE et_entityset FROM zcustomer WHERE city = iv_city.
ENDMETHOD.

Explanation

  1. Implements an OData entity set method.

  2. Fetches customer data filtered by iv_city.

  3. Exposes SAP backend data for external use.


Code Example 5: SAPUI5 Button and Event

<Button text="Save" press="onSavePress"/>
// Controller
onSavePress: function() {
  sap.m.MessageToast.show("Save button clicked.");
}

Explanation

  1. Defines a button in SAPUI5 XML view.

  2. onSavePress controller function triggers on button press.

  3. Implements a responsive user action with message toast.