Extending Standard Business Objects' Definitions

Objective

After completing this lesson, you will be able to extend standard business objects

Introduction

In addition to developing your custom business objects, SAP Sales and Service Cloud allows developers to extend the existing content of the cloud solution. 

When extending standard business objects, the starting point is the business object, similar to when developing custom business objects. A standard business object can be extended in multiple ways with the Cloud Application Studio.

  1. Extend Standard Business Objects with:
    • Extension fields
    • Custom logic in new actions or existing events
    • Messages
  2. Enhance Screens

    To make extension fields and custom actions available to end users, you can place them on the standard business object’s screen.

  3. Add an Extension Field to a Form

    You can add an extension field to the business object’s corresponding forms. You can either add the extension field to an original form or create a copy of a form and add the extension field to the copy.

  4. Add an Extension Field to a Report

    You can add an extension field to a data source that is based on the same business object as the extension field. You can then add the field to any reports based on the data source.

  5. Add an Extension Field to Services

    This allows you to use extension fields in SOAP web services or OData services.

  6. Add an Extension Field to Enterprise Search

    You can add an extension field to an enterprise search category. This allows users to search for the contents of an extension field within a particular category, such as sales orders or suppliers.

Further information on extending the standard solution can be found in the SAP Help Documentation.

Demo Use Case

In this unit, we'll cover a sample use case for implementing an extension to a standard business object. This use case is independent from our custom business object that we have created previously.

Before we have a closer look at the requirements, we need some background knowledge about the standard system behavior and the object that we want to extend. 

Salespeople are not supposed to create "Standard Sales Quotes" with zero-price items. Whenever a user tries to add an item with a price of zero, the new logic will flag the quote for review and display a warning. This flag will disappear after the situation has been corrected. However, the review flag will not block users from saving quotes or creating follow-up documents based on such quotes. In our scenario, we only concentrate on implementing this check routine.

While implementing the logic, we have to keep the following edge cases in mind.

In systems without product price lists, there might be no pricing information at all when adding a new item. In this case the system shows an error message "Mandatory list price missing". We will only concentrate on items where the user enters "0.00" as price.

Apart from that, we must keep in mind that the new behavior is only relevant for "Standard Sales Quotes", meaning sales quotes with the document type "Standard Quote". Other document types remain untouched. 

Please note that this is a showcase scenario. Depending on your business situation, there might be other ways to meet these requirements.

To achieve the above, we will:

  • Introduce an action that contains the business logic for this check routine. This could be executed manually by a click on a button or automatically whenever the quote is saved. 
  • Place this button on the standard quote screen (Thing Inspector).
  • Add a "Yes/No" extension field that represents the "review needed" flag and add it to the quote Thing Inspector screen. 
  • Add the capability to show a message box to inform the user about the review.

Create a Business Object Extension

In the following video, we will prepare the folder structure of our solution and create the business object extension definition for the standard business object "Sales Quote". In contrast to custom BOs, the file extension for extension object items in the project explorer is ".xbo". Therefore, extension objects are sometimes referred to as "XBOs". 

If you have access to an SAP Sales/Service Cloud tenant and want to follow along with the demonstrations, you can use the following code snippet for the business object extension:

Code Snippet
123456789101112131415161718192021222324252627282930313233
import AP.Common.GDT; import AP.CRM.Global; [Extension] businessobject AP.CRM.Global:CustomerQuote raises PriceMissing { // You must activate this business object before you can access the extension fields // or messages in script files, forms, and screens. message PriceMissing text "Item &1: Price must not be zero for this document type! Review required." : BusinessTransactionDocumentItemID; [Label("Review needed")] element ReviewNeeded : Indicator; action CheckReviewNeeded; node Item { node ItemParty { } } node Party { } node ItemProposal { } }

To create the XBO in this step we must know some technical details about the standard business object that we want to extend: The technical name of the object and its namespace.

Most objects for SAP Sales and Service Cloud can be found in the namespace http://sap.com/xi/AP/CRM/Global (within source code just referenced as AP.CRM.Global) since SAP Sales and Service Cloud is a CRM system and this namespace contains most of the CRM-related objects. The technical object names, however, can differ from the names that are used in the front end. The sales quote object is one of them. Its technical name is CustomerQuote. Another example is the ticket that has the technical name ServiceRequest and is located in the same namespace.

We haven’t addressed messages so far. However, we could have used them for our custom BO as well. While most parts of the message definition are self-explanatory, the following question might come into your mind when looking at it: "How do I know the data type for a variable?"

The answer is that it depends on what value we want to show. We can simply look up the data type of the respective field in the Repository Explorer. As we want to show the ID of a sales quote item, we can open the CustomerQuote BO and navigate to the Item structure. There we can see the data type of the ID member as shown in the following screenshot:

You can find more details about Business Object Extensions in these help pages.

Log in to track your progress & complete quizzes