Product Information
Add Custom Fields to SAP S/4HANA Business Partner OData API Entities
Business Partner OData API is available on the SAP API Business Hub. This API can be used to maintain master data related to Business Partner, Customer and Supplier entities.
There are standard fields available in the delivered service, but sometimes these fields do not suffice the business requirements and there may be a need to extend it.
This blog explains the addition of custom fields to the standard OData API for Business Partner (API_BUSINESS_PARTNER).
The extensibility feature is supported from SAP S/4HANA Cloud 1708 Edition.
Currently, custom fields can be added to the following list of entities in the OData Service API_BUSINESS_PARTNER.
Entity | Business Context Description |
A_BusinessPartner | Business Partner Core View |
A_CustomerCompany | Customer company code core |
A_CustomerSalesArea | Partner Sales area core view |
A_Customer | Customer Core View |
A_SupplierCompany | Supplier Company Code Core |
A_SupplierPurchasingOrg | Supplier Purchasing Org Core |
A_Supplier | Supplier Core View |
(An entity in the OData service corresponds to a Business Context which has to be used when a field has to be extended. This Business Context is also associated with a database include, added to the respective master data tables.)
“Custom Fields and Logic” app available on SAP Fiori Launchpad is used to extend the OData entities.
Using this app, it is possible to:
- Create,Edit and Delete the custom fields (extend the SAP table, application, CDS views and OData services)
- Manage the usage of a custom field on UIs, reports, forms, service interfaces, processes (data flows), search etc.
Procedure:
1. Log on to the SAP Fiori Launchpad with a user assigned with Business Catalog SAP_CORE_BC_EXT.
2. Select the app “Custom Fields and Logic”.
3. Click the ‘+’ (plus sign) button to add a new field. When the popup opens, select the appropriate Business Context from the above table, depending on the entity to be extended (here I want to extend the entity A_BusinessPartner). Fill other necessary details like label, type etc.
4. Click “Create and Edit” button.
4. In the tab “UIs and Reports” select the OData model (API_BUSINESS_PARTNER 0001 in this case) for which the field has to be extended and click on “Enable Usage” button.Click “Save” and “Publish” buttons.
5. Once the extended field “YY1_TEST_EXT_DEMO_bus” is successfully published, it will be part of the metadata of the OData service and the corresponding database include.
6. There is no explicit coding required for implementing CRUD operations on these extended fields.
It is possible to maintain the values of these extended fields using appropriate HTTP methods, just like other standard fields.
For Example,
1) Creation of a new Business Partner with the extended field.
- Use ‘POST’ method to create a Business Partner
- URI: https://{system_path}/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner
- Json: {
“BusinessPartnerCategory” : “2”,
“OrganizationBPName1” : “SAP”,
“YY1_TEST_EXT_DEMO_bus” : “demo_value”}
2) Update an existing Business Partner with the extended field.
- Use ‘PATCH’ method to update the Business Partner.
- URI: https://{system_path}/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner({‘BusinessPartner’})
- Json: {“YY1_TEST_EXT_DEMO_bus” : “demo_value”}
For more information please refer to these resources :
In case of any queries, please feel free to contact me or Former Member.
Hi Mansi,
Thanks for the blog.
I followed the same steps which is available in the document and created new field successfully using Custom fields and logic App.
After completion of the above steps, I am trying to see the output in browser but I am getting the error as 'No authorization to access Service 'API_BUSINESS_PARTNER_0001'.
Can you please suggest what authorization required to check in browser or if any other settings need to perform before execution.
Thanks in Advance.
Hi,
To access the odata service, you need to create a communication arrangement using the scenario SAP_COM_0008 , and use the communication user for authorization in the REST client.
Regards,
Manasi Sridhar
Hi Minashi,
Thanks for this great blog.
Best regards.
I can create a new Field. But when I then click to continue (and edit the field), I get an Internal Server Error in the screen.
POST .../sap/opu/odata/sap/APS_CUSTOM_FIELD_MAINTENANCE_SRV/$batch?sap-client=300 500 (Internal Server Error)
The following problem occurred: HTTP request failed500,Internal Server Error,<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>GEN_INTERNAL_ERROR</code><message>Runtime Error: 'GEN_INTERNAL_ERROR'. The OData request processing has been abnormal terminated. If "Runtime Error" is not initial, launch transaction ST22 for details and analysis. Otherwise, launch transaction SM21 for system log analysis.</message><timestamp>20200310095157</timestamp></error> -
This might help you in using this app
2715284 - Dump in "Custom Fields and Logic" S/4HANA
Hi Manasi,
Thank you for posting this blog.
Could you please assist on how to handle additional standard fields which is not part of API. We were able to add fields by extending the respective CDS, however the field value mapping is not automatically handled in method FILL_BP_DATA of DPC_EXT class.
Hi Vinod,
What solution did you implement in your case of additionl standard fields which are not part of the API?
Hi @Manasi Sridhar,
Thanks for sharing the info, I will need to add Customer Attribute1 (KNA1-KATR1) field to Entity A_Customer. Since this is not available for us (1909 On-Prem) I was thinking of extending that entity as a Custom field (for ZKATR1) and save it to KNA1-KATR1 (since we have custom programs/reports etc that use this field). Is there a user-exit or BAdI that I can use to achieve this?
Hi Manasi Sridhar
https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/#/detail/Apps('VL31N')/S22OP
and API hub:
https://api.sap.com/api/API_INBOUND_DELIVERY_SRV_0002/resource
Thank you in advance.