SAP on Power

SAP on Power

IBM Power servers are purpose built for data-intensive applications such as SAP HANA and S/4HANA that require large amounts of in-memory computing but still let you maintain the high availability and flexibility required for your hybrid cloud. 


#Power
#TechXchangeConferenceLab
 View Only

watsonx.ai integration with SAP S/4HANA® on IBM Power Virtual Server (3/6): OData Demo Scenario Setup

By Joachim Rese posted 22 hours ago

  

Introduction

This is Part 3 of the technical guidance series, "watsonx.ai Integration with S/4HANA® on Power Virtual Server."

This blog provides step-by-step instructions for setting up and configuring an S/4HANA system to serve OData services.

OData (Open Data Protocol) is an OASIS standard for data exchange over the internet. It is built on the REST architecture which bases on the HTTP(S) protocol.

OData is widely adopted by SAP. SAP cloud applications like SuccessFactors and Concur provide an OData API. Furthermore, the ABAP Restful Application Programming Model (RAP) is a framework that exposes business objects via the OData protocol. In short, OData is the method of choise for accessing data and services that are provided by an SAP solution.

In this blog post an OData service on SAP S/4HANA is configured that will be use in subsequent parts of this blog series.

Setting up the SAP Gateway

The SAP Gateway must be configured to receive and execute OData requests.

Configuring HTTP(S) ports

OData operates on the HTTP or HTTPS protocol. Therefore, the corresponding services must be enabled in the Internet Communication Manager (ICM).
If not already done, you must set the following SAP profile parameters. Start transaction SMICM and select menu item GotoParameters.

icm/server_port_0 = PROT=HTTP,PORT=<http port>,TIMEOUT=60,PROCTIMEOUT=600
icm/server_port_1 = PROT=HTTPS,PORT=<https port>,TIMEOUT=60,PROCTIMEOUT=600

Activating the SAP Gateway

Activate the SAP Gateway:

  1. Call transaction SPRO and click SAP Reference IMG.
    2. Right-click on node SAP Customizing Implementation GuideABAP PlatformSAP GatewayOData ChannelConfigurationActivate or Deactivate SAP Gateway and select Edit Activity from context menu.
    3. If message in dialog reads "SAP Gateway is currently active", click Cancel. Otherwise click Activate.

Defining SAP System Alias for Backend System in Gateway System

You must define a system alias for the backend S/4HANA system. Proceed as follows.

  1. Call transaction SPRO and click SAP Reference IMG.
  2. Right-click on node SAP Customizing Implementation GuideABAP PlatformSAP GatewayOData ChannelConfigurationConnection SettingsSAP Gateway to SAP SystemManage SAP Aliases and select Edit Activity from context menu.
  3. If the backend SAP system appears in the list, you are done. Otherwise:
  4. Click New Entries.
  5. Specify System Alias, a Description, the RFC Destination (NONE for embedded deployment), the Target System ID and the Target Client of the backend SAP system. Check flag Local Gateway and enter DEFAULT for Software Version.
  6. Click Save (Ctrl+S).

Setting up SAP Gateway in Backend System

Furthermore, the SAP Gateway must be enabled to serve OData requests.

  1. Call transaction SPRO and click SAP Reference IMG.
  2. Right-click on node SAP Customizing Implementation GuideABAP PlatformSAP Gateway Service EnablementBackend OData ChannelConnection Settings to SAP GatewaySAP Gateway Settings and select Edit Activity from context menu.
  3. If the Gateway system appears in the list, you are done. Otherwise:
  4. Click New Entries.
  5. Specify Destination System, Client, System Alias and RFC Destination.

Activating OData Web Services

After the SAP Gateway has been configured, you must activate the OData Web Services. To do so, proceed as follows

  1. Call transaction SICF.
  2. Enter /sap/opu for Service Path, odata* for Service Name and click Execute.
  3. Right-click on node odata and select Activate from context menu. Confirm by clicking Yes.
  4. Repeat previous step for service odata4.

Prepraring SAP Flight Demo Scenario

For test and demo and education purposes, SAP provides the Flight Demo Scenario. There are two flavors of this demo. In this blog series we will leverage the classic Flight Demo, opposed to the newer RAP optimized demo scenario (namespace /DMO/).

Populate Flight Demo Scenario Tables

The tables that form the Flight Demo Scenario are present with each S/4HANA system. However, transaction data tables SPFLI, SFLIGHT and SBOOK are empty. ABAP Report SAPBC_DATA_GENERATOR can be used to populate the tables. Run this ABAP report to generate a demo scenario with a size of your choice.

Add Flight Demo Scenario Backend Service to OData Service Catalog

The Flight Demo Scenario also comes with a OData service. As a last configuration step you must add this OData service to the catalog of active services. Proceed as follows:

  1. Call transaction /n/IWFND/MAINT_SERVICE.
  2. Click Add Service.
  3. Select System Alias and enter *RMTSAMPLEFLIGHT* for Technical Service Name. Hit or click Enter.
  4. Check rows of services /IWBEP/RMTSAMPLEFLIGHT and /IWBEP/RMTSAMPLEFLIGHT_2 and click Add Selected Services.
  5. Enter Package Assignment or click Local Object and click Continue (Enter).
  6. If confirmation dialog appears, click Continue (Enter).
  7. Click Back (F3) to get back to the service catalog. Validate that the services you have just added are in the list.

Test the OData Service

To test the OData service you should first run an OData service request using the built-in SAP Gateway client. If you have verified that the service works correctly, you can run an OData REST request from an external host to check the connectivity.

SAP Gateway Client

Proceed as folloes to use the built-in SAP Gateway client for calling an OData service.

  1. Call transaction /n/IWFND/GW_CLIENT to start the SAP Gateway client.
  2. For Request URI enter the following path
    /sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection?$format=json&sap-client=000&$select=carrid,connid&$filter=flightDetails/airportFrom eq 'FRA'
  3. Click Execute. In response, you get a list of carrier ids (carrid) and connection ids (connid) of all flights that depart from Frankfurt / Germany (FRA).

External REST Call

Determine SAP Gateway Host Address

The SAP Gateway host has not yet been exposed and can therefore only be reached within its network. Thus, to test the OData service from outside the SAP S/4HANA system, use the local hostname where the SAP Gateway resides.

export SAPGWHOST=<local SAP Gateway host>

Execute OData REST Call

To access the SAP S/4HANA system using an OData service, you should create an SAP S/4HANA user of type Communication that has only those roles assigned that are needed to run the OData service.

Set environment variables

export SAPUSER=<S/4HANA communication user>
export SAPUSERPW=<S/4HANA communication user password>

Afterwards you can run the CURL command below to query the OData service for a list of flights that depart from Frankfurt.

curl -u "$SAPUSER:$SAPUSERPW" "$SAPGWHOST/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection?%24format=json&sap-client=000&%24select=carrid,connid&%24filter=flightDetails/airportFrom%20eq%20'FRA'"

The response you are receiving should look like below.

{
  "d": {
    "results":[
      {
        "__metadata":
          {
            "id":".../sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection(carrid='AC',connid='0820',fldate=datetime'2002-12-20T00%3A00%3A00')",
            "uri":".../sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection(carrid='AC',connid='0820',fldate=datetime'2002-12-20T00%3A00%3A00')",
            "type":"RMTSAMPLEFLIGHT.Flight"
          },
          "carrid":"AC",
          "connid":"0820"
      },
      ...
    ]
  }
}

Creating an OData Service to Expose Database Table Content

So far you learnt how to setup and configure an existing OData service. In this section a new OData service is created. There are various way to create an OData service. It can be generated based on a RFC enabled function module or implemented in ABAP code. With RAP, business objects are always accessed by an integral OData service.

In this section an OData service is generated based on a Core Data Services (CDS) view that forms a trivial mapping of the content of database table ZMYTAB, where it is assumed that table ZMYTAB exists and is populated. (Replace ZMYTAB by any table that you like to expose by an OData service.)

Create CDS view and OData service

 First proceed as follows to create a very simple CDS view with an OData service.

  1. In Eclipse / ABAP Development Tools (ADT) logon to your SAP S/4HANA system.
  2. Right-click on your system in Project Explorer, select context menu item NewABAP Repository Object and select Core Data SeviceData Definition.
  3. Enter a Package, ZMYTAB_CDSV for Name and any Description and click Finish.
  4. Modify annotation: @AbapCatalog.sqlViewName: 'ZMYTAB_V'
  5. Add annotation: @OData.publish: true
  6. Click Save (Ctrl+S) and Activate (Ctrl+F3).
  7. Add generated backend service ZMYTAB_CDSV_CDS to OData service catalog as described in section above (transaction /n/IWFND/MAINT_SERVICE).

Test the OData service

Run the SAP Gateway client (transaction /n/IWFND/GW_CLIENT) with the Request URI below.

/sap/opu/odata/sap/ZMYTAB_CDSV_CDS/ZMYTAB_CDSV?$format=json

Next Steps

Next blog article in this series:

watsonx.ai Integration with S/4HANA® on Power Virtual Server (4/6): Deploy IBM watsonx Satellite Connector Agents

0 comments
27 views

Permalink