Introduction

In a professional services project you might use S/4HANA Cloud in combination with other solutions to apply the relevant business processes for professional services such as opportunity to cash. Scenario could be that project opportunities are managed in another solution, once the opportunity gets realized and priced, a project in S/4HANA Cloud will be created.

To be able to integrate these processes you need to understand how the S/4HANA Cloud APIs related to commercial projects work and how to address them. Depending on the source system where the priced opportunity is created, you might need a middleware such as SAP Cloud Platform Integration to perform mapping requirements of the message structure.

In this blog I would like to show you how we can leverage these S/4HANA Cloud APIs. We will start by understanding what these APIs are, where we can find information and documentation and how to test the APIs directly in S/4HANA Cloud.

The scenario in this blog will look like this:

In a following blog we will create an OData Service and Integration Flows on SAP Cloud Platform Integration to consume the S/4HANA Cloud API. Once you have your OData Service established, other systems can connect to SAP Cloud Platform Integration to match their source structure to the structure of the OData service.

This scenario will look like this and will be discussed in following blog:

Discover and explore Commercial Project APIs

A good starting point to understand, which API to use and how, is the SAP API Business Hub. It lists the APIs that you can use for integration including a testing tool and detailed information on the structure of the API.

Under APIs –> S/4HANA Cloud –> Artifacts, you can search for your desired API on the right side, in our case I filter for “project”:

Currently we have five APIs related to projects. In this blog we will be using the APIs:

Create and Update Commercial Projects (OData)

Read Commercial Projects (OData)

In the overview page you get details regarding the communication scenario of your APIs, in our case SAP_COM_0054. This communication scenario you will need to activate in your S/4HANA Cloud system to be able to use the relevant APIs. Additionally you can find a link to a documentation of your API on the overview page under Business Documentation.

The API documentation is very important to understand the complete functionality of the API, what the service nodes are and which fields are mandatory and optional. For our read and create/update APIs the service nodes are ProjectSet, WorkpackageSet, WorkItemSet, PlanDataSet (read), DemandSet (create/update). In this blog we will be using the service node ProjectSet.

Clicking on service node ProjectSet will lead you to the parameter list of mandatory and optional parameters of the service. In our case we have 12 mandatory fields for the create API which need to be filled out to test the create/update service.

If you want to visualise your OData model, you can do it in SAP Web IDE in your SAP Cloud Platform account (trial account also works).

For the create/update project API you will receive following OData model. Here you can see how the different entity sets relate to each other:

Enable APIs in S/4HANA Cloud

Communication Management

To be able to address the API, we need to activate the relevant communication scenario (SAP_COM_0054). You can find detailed steps on how to activate the communication scenario in API Business Hub under S/4HANA Cloud –> Documents –> Testing API Services of SAP S/4HANA Cloud

In your S/4HANA Cloud system under communication management you need to setup:

A communication user for the technical exchange with your source system

Define your source system from where the messages will come from, for this test you can tip in any name, I used APIHUB

Activate communication arrangement SAP_COM_0054

Once you activated the scenario you can see that both read and create/update APIs are in communication scenario SAP_COM_0054.

Consume S/4HANA Cloud API directly

Testing

In this scenario we will be testing the APIs that we just activated in S/4HANA Cloud directly via Postman.

Read project

Once you have activated your communication arrangement in S/4HANA Cloud the read API will have an endpoint similar to this. Please replace <S4HC> with your S/4HANA Cloud tenant:

In Postman you can execute the method GET with the credentials of your communication user, which you created when you setup the communication arrangement, and will receive the details regarding the current commercial projects in the system. If you want to search for a specific project, you can add the project ID at the end of your URL, in our case the project ID is “API”:

Running the read API first before using the create project API helps us understand the structure of the message, with which we address the create API. Note:

The cost center field requires 10 digits, our cost center (10201903) has only 8 digits, we need to add 2 leading zeros

Specific date and time format for start and end date.

Read API gives you the value of the project manager ID, while using the create API you require the project manager external ID. The project manager ID is the personnel ID of business user, while project manager external ID is the user name of the business user.

Create project

To create a project you need to execute the POST method on the create project API with relevant service node, in our case ProjectSet:

Before we want to use the POST method, we require the x-csrf-token. We can get this by using the GET method on the API service with parameter x-csrf-token=fetch. Note that you do not need the service node here:

You need to have the payload in JSON format ready, which includes all the relevant project details and all 12 mandatory fields as mentioned before are maintained. You can get the model schema for the API in API Business Hub:

It included some optional fields and not all mandatory field, which I included manually. Below payload has only mandatory fields for service node ProjectSet:

Now you can use the POST method on the read API with the payload, the x-csrf-token and credentials of your communication user. If you are able to post it successfully, you should be able to search for project in S/4HC:

By default a work package is automatically created with the name of the project. If you want to post additional information when creating a project, such as work packages, work items or project role demand, you can use following payload structure:

Again, if you struggle to find your values for any of these fields, you can use the read (GET) method to read the existing data of these fields in your S/4HANA Cloud system. This is an indication for you what the field value you need to enter could be.

If you set it up correctly another project is created:

Additionally a work package is created with the ID we specified and the work item is assigned to the work package. In our case the work item ID is “P002” and the work item name is “Testing”: