In this exercise, you will create objects needed to expose your data model as an OData service.
In this exercise, you will perform the following tasks:
- Create service definition
- Create service binding
- Clean up authorization details
-
Right click on the root projection view ZC_PROJECT_{YOUR_ID}.
-
Select New Service Definition in the popup menu.
- Enter the following details and choose Next:
- Z_PROJECT_{YOUR_ID} in the Name field
- Service Definition for Project in the Description field
- On the next screen select your transport and then choose Finish button.
- Assign aliases to your Business Object projection entities and expose local associations as shown in the code below (considering {YOUR_ID} replacement):
@EndUserText.label: 'Service Definition for Project'
define service Z_PROJECT_{YOUR_ID} {
expose ZC_PROJECT_{YOUR_ID} as A_EnterpriseProject;
expose ZC_PROJECT_EL_{YOUR_ID} as A_EnterpriseProjectElement;
expose I_EntProjProcessingStatus as A_EntProjProcessingStatus;
expose I_ProjectProfileCode as A_ProjectProfileCode;
}
- Select Activate button.
-
Right click on your service definition.
-
Select New Service Binding option in the popup menu.
- Enter the following details and then choose Next button:
- ZAPI_PROJECT_{YOUR_ID} in the Name field
- API V4 for Project in the Description field
- OData V4 - Web API in the Binding Type list box
- On the next screen select your transport and choose Finish button.
- Choose Activate button.
- After the service binding was activated, choose Publish button.
It may take several minutes. Please be patient.
Do not press the button twice as the publishing is in progress! Note the message in the header:
IMPORTANT! You can skip this task if your SAP S/4HANA Cloud runs on version 2402 and higher.
Every SAP Business Object contains its own authorization concept which is at the end defined by the list of authorization objects. After the service binding is created it generates the default values for these authorization objects. In this workshop we do not touch the authorization aspects at all. But for the further exercises these default values should be edited as they contain the objects which are not yet released for cloud development.
- Open the generated Authorization Default Values from your new service binding.
- Select object C_PROJ_PRC and choose Delete selected item button.
-
Repeat the previous step with the objects C_PROJ_KOK, C_PRPS_KOK and C_PRPS_PRC.
-
Choose Save button. Make sure that the list doesn't contain the objects mentioned above after save.
You have created a service definition and a service binding. Now your service is ready to be consumed.