cancel
Showing results for 
Search instead for 
Did you mean: 

Questions on SDK APIs for Business Partners

zje8szh
Participant
0 Kudos

Hello experts,

I have some questions about Business Partner SDK APIs. Below is the structure of business partner. Hope to have some suggestions from you.

{
    "BusinessPartner": "",
     ...
    
    "to_BusinessPartnerAddress": [ {
        ...
        } 
    ]
}

1. I want to get Business Partner along with the address data. But address data is not returned in method getAllBusinessPartner. Does that mean I need to invoke method getAllBusinessPartnerAddress to get address data based on business partner number?

2. What is the SDK api to support fuzzy search? filter() or withCustomQueryParameter() method?

3. How can I update business partner general data and address data at the same time? Seems I cannot set

to_BusinessPartnerAddress and then do update. It does support for POST operation. The request payload for POST is as below.

{
    "BusinessPartner": "1534",
    "LastName": "Jerry",
    "to_BusinessPartnerAddress": [ {
        "Country": "DE",
        "StreetName" : "Dietmar-Hopp-Allee 16",
        "PostalCode" : "69190",
        "CityName" : "Walldorf",
        "to_AddressUsage" : [ {
        "AddressUsage" : "XXDEFAULT" } ]
    } ]
}
View Entire Topic
0 Kudos

Hello Jerry,

> I want to get Business Partner along with the address data. But address data is not returned in method getAllBusinessPartner. Does that mean I need to invoke method getAllBusinessPartnerAddress to get address data based on business partner number?

If you plan to use OData V2 sub-entity expansion, we recommend adding the respective fields to the select method:

service
  .getAllBusinessPartner()
  .select(
    BusinessPartner.FIRST_NAME,
    BusinessPartner.LAST_NAME,
    BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS // you can chain attributes here
  )


> What is the SDK api to support fuzzy search? filter() or withCustomQueryParameter() method?

Unfortunately this is not yet supported by the SAP Cloud SDK, but it is in our backlog. As a workaround please specify a custom filter, e.g.:

service
  .getAllBusinessPartner()
  .withCustomQueryParameter("$filter", "substringof('Foo', LastName) eq true")

Please note, not all SAP OData service endpoint actual support the custom filters. Please check with your browser or Postman, how the service responds to your request. Also please keep in mind, by adding a custom "$filter" you cannot add API filters with the filter(...) method.


> How can I update business partner general data and address data at the same time?

This is not supported by OData V2. You will need to iterate over the nested update operations. Please note, it's not required to update the sub-entities, when only doing changes on the base-entity.

For example, if you only want to update fields on a BusinessPartner, you are not required to update the addresses. On the other hand, if you want to update the fields of a BusinessPartnerAddress, just use the dedicated service to do so. In that case, the BusinessPartner will not be touched.

Best regards

Alexander

zje8szh
Participant
0 Kudos

Alexander, thank you very much.