This document describes about generating ABAP Classes for the Service Builder project
that comply with OData V4
Context
You can automatically generate code for the runtime functionality of your data model.
The Service Builder generates the classes with the generated code. The generated
classes are listed in the Runtime Artifacts folder.
Prerequisites
- You must have already created a Service Builder project and must have defined required
artifacts
- The project must be in edit mode
Procedure
To generate the classes and publish the service, proceed as follows:
- In the SAP Gateway Service Builder, right click the project name and click
. Alternatively, select the project, and click , or from Project in the menu, click Generate. The Model
and Service Definition window displays. All the fields in
this window are editable.
- In Model Provider Class section:
- enter a name for the implementation class in the Class
Name field. Naming convention:
Code Syntax
CL_<PROJECT NAME>_MPC_EXT
.
- enter the name for the base class in the Base Class Name
field. Naming convention:
- In Data Provider Class section:
- Generate Classes is selected by default to
generate the classes for the Data Provider Class (DPC). If you do
not want to generate DPC, deselect Generate Classes
- enter a name for the implementation class in the Class
Name field. Naming convention:
Code Syntax
CL_<PROJECT NAME>_DPC_EXT
- enter the name for the base class in the Base Class Name
field. Naming convention:
- In Service Registration section:
- in Service ID field enter a unique service ID
for the service to be created.
- in Service Version field specify the version
number for the service
- Click . Create Object Directory Entry dialog box appears.
- Choose Local Object, or assign the objects to the
appropriate package. You can assign the generated classes to a transport
request. The Service Builder checks if the MPC classes are already assigned
to a transport request package, and if they are, the DPC classes are
automatically assigned to that same transport request.
- Click in the subsequent windows.
The Service Builder saves the content of the project, checks the project, and
saves it again. It then creates the classes, lists them in the Runtime Artifacts
folder of the project, and registers the service in the backend system. Double-click
any of the content in the Runtime Artifacts folder. In the Runtime Artifacts screen,
you can view the properties of the classes.
Note
- Once the classes are generated they are never overwritten. During
regeneration if any error is present in the project, a warning message
is displayed.
- If you rename an Entity Set name and regenerate the project, previously
generated method names do not change, only the description of the method
changes based on the new name.