The Simple Contract business object serves as an example that contains the most important structure elements. It helps demonstrate the different capabilities of SAP Cloud Applications Studio and the extension framework. It consists of:
- Fields with different data types and pre-defined labels on the root node.
- A sub node "Items" that contains more fields and has a 0:n relationship to the root node. Hence, we can have multiple "Item" instances per contract.
- Dependent Objects that allow us to reuse existing objects as part of our BO.
- Associations that represent references to other business objects which can be used for navigation and property access.
- Actions to encapsulate business logic.
- A message that can be shown to the user (this will be shown in the next unit).
Let’s have a look at the various fields in more detail. Let’s begin with the root node’s fields, sometimes referred to as header fields.
- The first two fields allow us to store an ID and a description for the contract. The attribute AlternativeKey for the ContractID field ensures that the ID is unique amongst all SimpleContract instances. The system creates a technical identifier called UUID transparently in the background and uses it internally for referencing the object. The alternative key field ContractID is human readable and hence, more user friendly. Similar to the IDs of accounts and employees, it is usually used in the front end to enable end users in creating references to other business objects.
- The fields AccountID and ContractOwnerID can store IDs of an account and an employee. To access data of the respective objects, these IDs must be resolved to object references, that are then stored in the respective associations.
- The date fields allow users to specify different dates for the contract processing.
- The ContractAmount field is used to store the sum of the item’s amounts. It will be calculated by a script, implemented for the CalculateReportAmount action and executed whenever the object is saved.
We will create the definition of the business object and implement the logic in the following sections and lessons. To make all of this accessible for end users, we generate screens for the object and adapt them to our needs.