Skip to content

Latest commit

 

History

History
114 lines (66 loc) · 4.33 KB

File metadata and controls

114 lines (66 loc) · 4.33 KB

Expose Service

Introduction

In this exercise, you will create objects needed to expose your data model as an OData service.

Task Flow

In this exercise, you will perform the following tasks:

  1. Create service definition
  2. Create service binding
  3. Clean up authorization details

Content

Task 1: Create service definition

  1. Right click on the root projection view ZC_PROJECT_{YOUR_ID}.

  2. Select New Service Definition in the popup menu.

Alt text

  1. Enter the following details and choose Next:
  • Z_PROJECT_{YOUR_ID} in the Name field
  • Service Definition for Project in the Description field

Alt text

  1. On the next screen select your transport and then choose Finish button.

Alt text

  1. 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;
}
  1. Select Activate button.

Alt text

Task 2: Create service binding

  1. Right click on your service definition.

  2. Select New Service Binding option in the popup menu.

Alt text

  1. 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

Alt text

  1. On the next screen select your transport and choose Finish button.

Alt text

  1. Choose Activate button.

Alt text

  1. After the service binding was activated, choose Publish button.

It may take several minutes. Please be patient.

Alt text

Do not press the button twice as the publishing is in progress! Note the message in the header:

Alt text

Task 3. Clean up authorization details

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.

  1. Open the generated Authorization Default Values from your new service binding.

Alt text

  1. Select object C_PROJ_PRC and choose Delete selected item button.

Alt text

  1. Repeat the previous step with the objects C_PROJ_KOK, C_PRPS_KOK and C_PRPS_PRC.

  2. Choose Save button. Make sure that the list doesn't contain the objects mentioned above after save.

Alt text

Result

You have created a service definition and a service binding. Now your service is ready to be consumed.

Next tutorial: Create Communication Scenario

Further reading / Reference Links