Wednesday, 13 March 2024

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP

This blog post will explain how to expose a CDS view as an API using developer extensibility in SAP S/4HANA Cloud Public Edition to be consumed in the SAP Business Technology Platform

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP

Technical Procedure


Extending our solutions allows you to differentiate yourself from the competition, simplify processes, and adapt the software according to the specific needs of your business.

In the case of SAP S/4HANA Cloud Public Edition, we have three types of extensibilities:

  • Key user extensibility through built-in capabilities
  • Developer extensibility through custom ABAP code in SAP S/4HANA Cloud Public Edition
  • Side-by-side extensibility through SAP Business Technology Platform

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
Extensibility and Integration S/4HANA Cloud Public Edition

Typically, details can be found regarding instances where the SAP S/4HANA Cloud Public Edition is extended using a single kind of extension. Here, we're dealing with developer extensibility, which, given the right configuration, can be revealed through an Identity and Access Management (IAM) application. This can then be linked to the SAP Business Application Studio as a side-by-side extension.

Prerequisites


  • SAP S/4HANA Cloud Public Edition system, access to the development tenant (80), and the developer role assigned to the business user: SAP_BR_DEVELOPER
  • Eclipse with ADT (ABAP Development Tools)
  • SAP Business Technology Platform with a subaccount in the Cloud Foundry environment, with access to the SAP Business Application Studio
 

Process


This blog will cover both Developer extensibility and side-by-side extensibility

Developer Extension

1. Installing the ABAP development tools Eclipse
2. Connecting to the SAP S/4HANA Cloud ABAP environment
3. Finding the Object in the SAP Business Acceleration Hub
4. CDS view
5. Data Definition
6. Service Definition
7. Service Binding
8. Consuming Services in UI

Side-by-Side Extensibility

1. SAP S/4HANA Cloud Public Edition Communication Management Configuration
2. Connect the SAP Business Application Studio and the SAP S/4HANA Cloud System
 

Developer Extension


1. Installing the ABAP development tools in Eclipse

After installing Eclipse, go to Help -> install new Software.

For installing the latest tools, please enter the URL https://tools.hana.ondemand.com/latest

Select ABAP Development Tools and after clicking on Next and confirming the Licenses agreements finish the installation. 

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
Installing new ABAP Tools in Eclipse

2. Connecting to the SAP S/4HANA Cloud ABAP Environment

Go to Eclipse and create a new ABAP Project. After this, you can establish a service instance connection by entering the ABAP service instance URL, for example https://my12345.s4hana.ondemand.com (without ui) and selecting Next. 

Now you will need to log on the system, please use the default browser by selecting Open Logon Page in Browser or Copy Logon URL to Clipboard to use another browser.

After correct Login, create the project by selecting Next. Then, specify the logon language and the ADT Project name and choose Finish.

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
New ABAP Cloud Project

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
Login into the S/4HANA Cloud Public Edition System

After correct logon, the following message will appear on the browser. Now you can go back to Eclipse.

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP

3. Finding the Object in the SAP Business Acceleration Hub

To review the available APIs, go to the SAP Business Acceleration Hub visiting https://api.sap.com and choose the one you need. 

After entering the page, choose the product to explore, in this case SAP S/4HANA Cloud Public Edition, then go to developer extensibility, Business Object Interface, and choose the Business Partner object. In the general information of the Business Object Interface, you will find the object ID. Copy it.

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
Business Partner Business Object

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
Object Information

4. CDS View

CDS or Core Data Service, refers to virtual data models of SAP HANA, used to define and consume semantic data models on the central database of the application server AS ABAP. A CDS Entity is basically source code in the CDS data definition, DDL or Data definition language, and DCL or Data control Language, are the base of this data models.

5. Data Definition

Click on the package you want to use, and go to file > New > Other

Search for the ABAP Data Definition and press Next.

After Naming the projection View and referencing the searched object: I_BUSINESSPARTNERTP_3 the projection code will be automatically generated.

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
Data Definition

There are various types of CDS projection views, with their own feature set and own syntax. For defining the type of view, use the syntax statement PROVIDER CONTRACT for more information please refer to the SAP Help portal.

After defining provider contract transactional_query , save and activate the changes.

@EndUserText.label: 'Business Partner Projection View'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity ZXXXXXXXXXXXXX provider contract
transactional_query asprojection on I_BusinessPartnerTP_3
{

   key BusinessPartner,
   BusinessPartnerUUID,
   FullName,
   BusinessPartnerForEdit,
   BusinessPartnerGrouping,
   BusinessPartnerCategory,
   CreatedByUser,
   CreationDate,
   CreationTime,
   LastChangedByUser,
   LastChangeDate,
   LastChangeTime,
   FormOfAddress,
   FormOfAddressPerson,
   FirstName,
   LastName

}

6. Service Definition

A service definition refers to which CDS entities of a data model must be exposed so that a specific business service can be enable.

For creating a new service definition, go to New > Other repository objects, and search for Service Definition. Choose the package, name the new service, add a description, and choose Definition as source type. Finally, reference the object I_BUSINESSPARTNERTP_3 . The system will automatically create the service with the CDS entity.

Now save and activate the service definition.

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
New Service Definition

7. Service Binding

The service binding or business service binding is an ABAP repository object that connects a service definition to a client-server communication protocol.

In Eclipse, go to New > other repository object and search for Service Binding. To correctly create the binding, choose the package, add a name and description. In Binding Type, choose one of the options and link the service definition you just created by clicking on browse and searching for the correct one.

After a correct creation of the service binding, save and activate the changes, and to finish, publish it locally.

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
New Service Binding

8. Consuming Services in UI

One of the needs of this example is that the service created is available for a specific type of business role, therefore, it is necessary to add this service to an IAM app, which is assigned to a business catalog. This becomes more relevant since it is only related for Identity and Access Management (IAM). You have two options: You can either assign the service to an already created IAM, or create the new IAM to add the service to it.

Procedure

1. Creating an app
2. Creating a business catalog
3. Creating a business role template

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP
IAM App
 

Side-by-Side Extensibility


Side-by-side extensions are software applications that run externally to the main core application. 

These kinds of extensions provide freedom of development, including the ability to code in different programming languages such as ABAP or Java. They can also be integrated at different levels such as UI level, application logic level, or data level. The interaction of these extensions with SAP S/4HANA Cloud Public Edition is given through the standard SAP APIs. 

Side-by-side extensions can potentially run on any runtime application platform. However, the use of SAP's own platform, SAP Business Technology Platform, is recommended.

1. SAP S/4HANA Cloud Public Edition Communication Management Configuration

The SAP S/4HANA Cloud Public Edition system can be configured with three types of connections: SAML Assertion Authentication, Basic Authentication and Client Certificate Authentication. In our example, we will use SAML Assertion Authentication.

SAP S/4HANA Cloud Public Edition has the following functionalities that must be correctly configured: 

1. Communication arrangement: Basically, this allows communication with the remote system, configuring the metadata for the service configuration.
2. Communication system: This involves the technical information needed for communication, which includes identity, user information, and certificates.
3. Communication user: It represents a technical user type, related to the communication system. This is created for a particular scenario.
4. Communication scenario: The scenario defines the communication between your SAP system and external systems, connecting inbound and outbound services.
 
2. Connect the SAP Business Application Studio and the SAP S/4HANA Cloud Public Edition System

Exposing an oData Service from SAP S/4HANA Cloud Public Edition to the SAP BTP

To avoid common errors, make sure to configure the correct authentication type in the BTP in this case SAML and as for the SAP S/4HANA Cloud Public Edition system make sure that the service created and added to the business catalogue is assigned to the communication protocol visible from the BTP.

No comments:

Post a Comment