Implement a Gateway service (Part 1) – Define a data model based on Data Dictionary Structure

We are going to define a Gateway service in the Service Builder SEGW.

The first stage of implementing a service is to define the data model. For that, we will create custom z tables from scratch.

  • Create 2 tables named ZStudent and ZSubjects as shown below.

3.png

22

 

  • In transaction SEGW, create a new project.

Screenshot_20180126_124330

  • Give the project name ZStudents and a description.

Screenshot_20180126_124406

  • Right-click on Data Model node and choose Import->DDIC Structure. We are not creating entity types from scratch as the data tables are already created in the Data Dictionary in the previous step.

Screenshot_20180126_124653

  • Enter a Name, ABAP Structure, select Create Default Empty Set and click on next.

Screenshot_20180126_124757

  • Select all the fields to include in the service for the student and click on Next.

23

  • Specify the field ID as key.  Click on Finish.

24

  • The result is as shown below. The Entity Type, Entity Set and the Service Implementation have been generated.

Screenshot_20180126_131143

  • Similarly, create the child Entity type and Entity Se. Import another DDIC object for Subjects.

Screenshot_20180126_132025

  • Click on the Generate Runtime Objects icon. The Service Builder will generate Model Provider classes and Data Provider classes.

5

  • Open the Service Maintenance node and click on Register. Specify the local package, the External Service Name and click on Ok.

Screenshot_20180126_132334

  • Click on Maintain to open the transaction /IWFND/MAINT_SERVICE.

6

Select the service from the Service Catalog and in the ICF Nodes section, click on SAP Gateway Client to test the service.

7

The URI of the service is /sap/opu/odata/sap/ZSTUDENTS_SRV/. You can use various oData Query options such as $metadata, ?format=xml and sap-ds-debug=true.

  • Click on Execute to test the service.

8

  • Click on Add URI Option and choose $metadata and sap-ds-debug=true options.
  • Execute to see the results below.

9

Do note that at this point we can only access the metadata of the service. The service will not return any data yet. If you try to get the data for an entity set, you will get an error as shown below.

Screenshot_20180126_170256

Business data retrieval logic will be implemented in part 2.

Advertisements