CLAIMATE

Technical blog

Updating Customer in SAP S/4 HANA Public Cloud via OData HTTP Adapter

created by ChatGPT 4o

Jiri Fridrich

May 28, 2025

Integration

In my previous blog I describe how to create Customer in SAP S/4HANA Public Cloud via HTTP adapter. In this post we will explore the UPDATE possibilities. 

I will skip the authentication part, as that is desribed in the mention blog and it follows the same pattern.

We'll again focus on the API_BUSINESS_PARTNER service, your go-to resource for all things related to business partners (which is how customers are represented in S/4HANA). The PATCH method will be our primary tool for making targeted updates.

The official documentation, which will be your good companion is provided at the SAP Business Accelerator Hub.

1. Updating Core Business Partner Information

This is where you'll modify fundamental details about your customer, such as their name.

API Endpoint: /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('<CUSTOMER-NUMBER>')

Replace <CUSTOMER-NUMBER> with the actual customer ID you wish to update.

Method: PATCH

Let's say we want to update the customer's first name or last name. Then the request body will be as follows. General rule is that we are sending only data which we want to change. The rest remains intact.

Request Body (JSON):

{
    "FirstName": "FIRST NAME",
    "LastName": "LAST NAME"
}

2. Updating Sales Area Data

Sales area data is crucial for sales processes, defining how a customer interacts with your sales organization, distribution channel, and division.

API Endpoint: /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_CustomerSalesArea(Customer='<CUSTOMER-NUMBER>',SalesOrganization='<SALES-ORG>',DistributionChannel='<DISTR-CHANNEL>',Division='<DIVISION>')

Example (with placeholders replaced): /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_CustomerSalesArea(Customer='1000010',SalesOrganization='1000',DistributionChannel='01',Division='01')

Remember to replace <CUSTOMER-NUMBER>, <SALES-ORG>, <DISTR-CHANNEL>, and <DIVISION> with the specific values for the sales area you want to modify.

Method: PATCH

For example we want to update the Customer Group for a specific customer.

Request Body (JSON):

{
    "CustomerGroup": "<CUSTOMER-GROUP>"
}

3. Updating Customer Address

Updating addresses is a two-step process: first, you need to retrieve the AddressID, and then you can perform the update. This ensures you're targeting the correct address record, as a business partner can have multiple addresses.

Step 3a: Get Address to Extract Address ID

You'll need to query the business partner to retrieve the associated address ID.

API Endpoint (GET Request): /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('<CUSTOMER-NUMBER>')$expand=to_BusinessPartnerAddress

Replace <CUSTOMER-NUMBER> with the relevant customer ID. Notice the 'expand' in the query. Without it the system would not return the address details, as it can contain a lot of data. If we want address details, we have to ask for it.

Method: GET

Explanation: This GET request will retrieve the business partner details. Within the response, you'll find the AddressID for each address record linked to the business partner. You'll need to parse this response to extract the correct AddressID for the address you intend to update.

Step 3b: Update Address

Once you have the AddressID, you can proceed with the PATCH request to update the address details.

API Endpoint: /sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartnerAddress(BusinessPartner='<CUSTOMER-NUMBER>',AddressID=<ADDRESS-ID>')

Method: PATCH

Again, we are sending only data which we want to change. Notice that we are calling different API (A_BusinessPartnerAddress) than when we were requesting the address object (A_BusinessPartner). This can be misleading and one of the reasons I am writing this blog to clarify it.
The body to change the whole address can look like this.

Request Body (JSON):

{
    "Country": "<COUNTRY>",
    "CityName": "<CITY>",
    "StreetName": "<STREET>",
    "HouseNumber": "<HOUSE-NUMBER>",
    "PostalCode": "<ZIP-CODE>"
}

4. Updating Customer Email

Updating email is again a two-step process similar to address update, but it gets even trickier, that's why I want to demonstrate it as well.

Step 4a: Get Current Email Address 

API Endpoint
/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner('${property._CustomerNumber}')$expand=to_BusinessPartnerAddress/to_EmailAddress

Notice that we are again expanding the query, but this time even furhter, as we need the email address, which is nested under the general address.
This time we need to extract more parameters - AddressID, Person and OrdinalNumber !

Step 4b: Update Email Address

With all this data, we can finally run our update query. 

API Endpoint:
/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_AddressEmailAddress(AddressID='<ADDRESS-ID>',Person='<PERSON>',OrdinalNumber='<ORDINAL-NUMBER>')

Method: PATCH

{
    "EmailAddress": "NEW@EMAIL.COM"
}

That's it

Similarly, we can update phone or any other business partner object. Always ensure that you are expanding properly when calling the GET query, so that the object you want to get is listed in the response.

Recommendable is also to handle the response to the PATCH request, the desirable response code is 204. Anything else we can route as an exception in our iflow, as the update did not go through.

See also Creating Customer in SAP S/4 HANA Public Cloud via OData HTTP Adapter 

It was also published here:

https://community.sap.com/t5/technology-blog-posts-by-members/updating-customer-in-sap-s-4-hana-public-cloud-via-odata-http-adapter/ba-p/14109511

Navigation

© 2023 CLAIMATE

Navigation

© 2023 CLAIMATE