Lesson 4: Advanced SAP Development Practices

Lesson 4: Advanced SAP Development Practices


1. ABAP Managed Database Procedures (AMDP)

  • Used for creating database logic in SAP HANA using SQLScript.

  • Enhance performance by executing logic directly in the database.

  • Allow seamless integration with ABAP programs.


2. SAP Fiori Elements

  • Simplifies app creation with predefined templates and metadata-driven UI.

  • Supports dynamic views with annotations.

  • Enables faster app deployment and consistency.


3. BRF+ (Business Rule Framework Plus)

  • Centralizes business rule management in SAP.

  • Offers a decision table interface for rule configuration.

  • Improves rule maintainability and reusability.


Code Example 1: AMDP Method Implementation

CLASS zcl_amdp_example DEFINITION.
  PUBLIC SECTION.
    INTERFACES: if_amdp_marker_hdb.
    METHODS get_customers BY DATABASE PROCEDURE FOR HDB
      LANGUAGE SQLSCRIPT USING zcustomer.
ENDCLASS.

CLASS zcl_amdp_example IMPLEMENTATION.
  METHOD get_customers.
    SELECT * FROM zcustomer INTO TABLE @lt_customers.
  ENDMETHOD.
ENDCLASS.

Explanation

  1. Implements an AMDP method using the if_amdp_marker_hdb interface.

  2. Executes SQLScript directly on HANA.

  3. Fetches data from the zcustomer table.


Code Example 2: SAP Fiori List Report App

<ListReport
  xmlns="sap.fe.templates"
  entitySet="Customers"
  navigationPropertyBinding="to_CustomerOrders">
</ListReport>

Explanation

  1. Defines a Fiori List Report app using SAP Fiori elements.

  2. Binds the app to an OData entity set Customers.

  3. Enables navigation to related CustomerOrders.


Code Example 3: BRF+ Decision Table

CALL FUNCTION 'FDT_PROCESS_TABLE'
  EXPORTING
    iv_table_id = 'DT123'
  IMPORTING
    et_result = lt_rules.

Explanation

  1. Invokes a BRF+ decision table using function FDT_PROCESS_TABLE.

  2. Processes rules defined in the table with ID DT123.

  3. Outputs results into lt_rules.


Code Example 4: Dynamic SQL Execution

DATA(query) = 'SELECT * FROM zcustomer WHERE city = ?'.
EXEC SQL.
  EXECUTE IMMEDIATE :query INTO :lt_data USING 'Berlin'.
ENDEXEC.

Explanation

  1. Constructs a dynamic SQL query for flexible execution.

  2. Filters zcustomer data by city using a parameter.

  3. Executes directly with improved performance.


Code Example 5: SAP Fiori Navigation Handler

onNavigate: function() {
  var oRouter = this.getOwnerComponent().getRouter();
  oRouter.navTo("CustomerDetails", { id: "123" });
}

Explanation

  1. Implements a navigation handler in a SAPUI5 controller.

  2. Uses navTo for routing to a specific page.

  3. Dynamically passes parameters like id.