Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Srivatsa
Explorer
339

Creating Custom Business Objects

In our project, we started by creating Custom Business Objects in the Customizing Tenant. This process automatically generated a user interface (UI) that allowed us to create entries directly. Here's a quick overview of the steps:

  1. Navigate to the Customizing Tenant: Access the SAP Fiori launchpad and go to the Custom Business Objects app.
  2. Create a New Custom Business Object: Define the object with the necessary fields and attributes.
  3. Generate the UI: Once the object is created, the system generates a UI for data entry. (https://developers.sap.com/tutorials/abap-extensibility-cbo-create..html)

Using the ODATA API

Our next task was to create entries using the ODATA API of the Custom Business Object. This required a few prerequisites:

  1. Create a Custom Communication Service: Ensure you have set up a communication service for your Custom Business Object. (https://developers.sap.com/tutorials/abap-custom-ui-business-object..html)
  2. Access the Development Tenant: Log in to the Development Tenant and open Eclipse ADT.

Creating a Class in Eclipse ADT

To interact with the ODATA API, we created a class in Eclipse ADT. Here are the steps:

  1. Open Eclipse ADT: Launch Eclipse and log in to your Development Tenant.
  2. Create a New ABAP Class: Use the following template in your class:

Srivatsa_0-1744307749345.png

 

We have created a structure with Code & Reason. To know the HTTP Response for our action.(EX : 201 Created, 400 BADRequest..)

Srivatsa_1-1744307749414.png

 

We are getting to the implementation part.

LV_URL will have the ODATA Url which you would have got from the Communication Service of your CBO 

From lv_user_id to lv_last_name are the declaration of values which will be used in the payload.

We use cl_http_destination_provider=>create_by_url to create an HTTP destination, which represents the connection to the OData service.

Srivatsa_2-1744307749437.png

 

  • HTTP Client: An HTTP client is created using cl_web_http_client_manager=>create_by_http_destination.
  • Authorization: Basic authorization is set using set_authorization_basic.
  • Headers: Headers for content type, accept, and CSRF token are set.
  • CSRF Token: The CSRF token is fetched and set in the request header.

The Final Part,

Srivatsa_3-1744307749352.png

 

  • Payload: A payload is created with user details and set in the request.
  • POST Request: A POST request is executed to create entries in the Custom Business Object.
  • Response Handling: The response status and reason are captured.

Srivatsa_4-1744307749380.png

 

I am creating 3 entries by iteration, so i have used DO statement in it.

To check the result, you can check the CBO Application.

Conclusion

Working with Custom Business Objects in SAP S/4HANA Public Cloud 3SL has been an enriching experience. The ability to create and manage custom objects, coupled with the power of ODATA APIs, opens up numerous possibilities for customization and integration.

I hope this post helps you get started with Custom Business Objects and ODATA APIs in SAP S/4HANA Public Cloud 3SL. Stay tuned for more insights and tutorials. Cloud Operations   SAP S/4HANA Cloud Public Edition   ABAP Extensibility   SAP Community

1 Comment
Labels in this area