Skip to content

Pjha72/SAP_BTP_APP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAP BTP Application Development with RAP Model

This repository contains the implementation steps and files for creating an SAP BTP Application using the RAP (RESTful ABAP Programming) Model. The project demonstrates how to build a robust and scalable application on the SAP Business Technology Platform.


Repository Overview

This repository includes the following:

  • Database table definitions
  • Interface and consumption views
  • Metadata extension files
  • Behavior definitions and implementations
  • Service definitions and bindings
  • Published services for deployment

You can use this repository as a reference or starting point for your own SAP BTP projects.


Steps for Creation

Step 1: Create Database Table

Define the database table in the ABAP Dictionary to store your application's data. Ensure it contains all the required fields and configurations (e.g., primary keys, data types).

Example Code

@EndUserText.label : 'Event Table'
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #ALLOWED
DEFINE TABLE zbtp_event_table {
  key event_id   : abap.numc(10);
  event_name     : abap.char(50);
  event_date     : abap.dats;
  event_status   : abap.char(10);
}.

Step 2: Create Interface View

Create an interface view that reads data from the database table. This view serves as the foundation for other layers and ensures abstraction of the database structure.

Example Code

@AbapCatalog.sqlViewName: 'ZBTPEVTIV'
@AbapCatalog.compiler.compareFilter: true
@EndUserText.label: 'Interface View for Events'
DEFINE VIEW zbtp_event_interface AS SELECT FROM zbtp_event_table {
  key event_id,
  event_name,
  event_date,
  event_status
}.

Step 3: Create Consumption/Projection View

Define a consumption view (or projection view) that reads data from the interface view. This view is exposed to the frontend and users.

Example Code

@AbapCatalog.sqlViewName: 'ZBTPEVTCPV'
@EndUserText.label: 'Consumption View for Events'
@Analytics.dataCategory: #DIMENSION
DEFINE VIEW zbtp_event_consumption AS PROJECTION ON zbtp_event_interface {
  key event_id,
  event_name,
  event_date,
  event_status
}.

Step 4: Create Metadata Extension File

Enhance the consumption view by creating a Metadata Extension file. Use this file to define the UI annotations for fields, labels, and other presentation settings.

Example Code

@Metadata.layer: #CUSTOMER
ANNOTATE VIEW zbtp_event_consumption WITH {
  @UI.lineItem: [ { position: 10, label: 'Event ID' },
                  { position: 20, label: 'Event Name' },
                  { position: 30, label: 'Event Date' },
                  { position: 40, label: 'Event Status' } ]
}.

Step 5: Create Behavior Definition

Define the Behavior Definition for both the interface and consumption views. Specify:

  • The actions and operations (e.g., create, update, delete, read).
  • Key features such as draft handling, validations, or determinations.

Example Code

DEFINE BEHAVIOR FOR zbtp_event_interface
IMPLEMENTATION IN CLASS zcl_btp_event_behavior
{
  create; update; delete;
}

Step 6: Create Behavior Implementation

Implement the business logic for the application in the Behavior Pool Class linked to the interface view. This includes writing the logic for validations, determinations, and other custom operations.

Example Code

CLASS zcl_btp_event_behavior DEFINITION PUBLIC FINAL.
  PUBLIC SECTION.
    INTERFACES if_abap_behavior.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_btp_event_behavior IMPLEMENTATION.
  METHOD if_abap_behavior~validate_save.
    LOOP AT entities INTO DATA(entity).
      IF entity-event_name IS INITIAL.
        APPEND VALUE #( %tky = entity-%tky
                        %msg = new_message( id = 'ZMSG' number = '001'
                                          severity = if_abap_behv_message=>severity-error
                                          v1 = 'Event Name is required' ) )
               TO reported.
      ENDIF.
    ENDLOOP.
  ENDMETHOD.
ENDCLASS.

Step 7: Create Service Definition

Create a Service Definition to expose the data model and functionality to external consumers. The name of the service definition should match the application.

Example Code

DEFINE SERVICE zbtp_event_service {
  expose zbtp_event_consumption;
}

Step 8: Create Service Binding

Create a Service Binding to enable the service definition. This step allows you to configure the service type (OData V2/V4) and activate it for consumption.

Example Code

@EndUserText.label: 'Service Binding for Event Service'
DEFINE SERVICE BINDING zbtp_event_service_binding
FOR zbtp_event_service
WITH PURPOSE 'ODATAV2'
VERSION 1.

Step 9: Publish

Publish the service binding to make your application available for consumption on SAP BTP. Test the service endpoints to ensure everything works as expected.

Example Command

sapcli service publish zbtp_event_service_binding

How to Use

  1. Clone this repository to your local machine:
    git clone https://github.com/Pjha72/SAP_BTP_APP.git
  2. Follow the steps in the Steps for Creation section to set up and deploy the application.
  3. Test the published service endpoints using SAP tools or REST clients.

Additional Notes

  • Ensure you follow SAP best practices while implementing behavior logic and designing database tables.
  • Use the appropriate SAP tools (e.g., ADT, Eclipse) for development.
  • Test each step thoroughly to avoid issues during deployment.

Contributions

Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Happy Coding! 🎉

Releases

No releases published

Packages

No packages published