Show TOC

Data Provider ClassLocate this document in the navigation structure

This document makes you familiar with the Data Provider Class created on generating a project that complies with OData V4.

Introduction
The Service Builder automatically generates classes for the DPC once you generate the project. The following are the classes:
  • Base Class: The generated base class inherits its code from the SAP Gateway abstract class, /IWBEP/CL_V4_ABS_DATA_PROVIDER. The generating mechanism for the DPC redefines and implements the following operations in the SAP Gateway: Create, Read, Update, Delete, (CRUD) and Query. For each entity set in the model, it generates the specific methods for implementation.
  • Extension Class: The Service Builder creates an extension class for the DPC, which is the implementation class. The extension class is inheriting from the DPC base class. You must redefine each method in the DPC extension class for specific functionality .
There are several methods in each class, methods in base class are inherited from the abstract class and can be redefined. Base class has some redefined methods from abstract class and some methods based on the model. You can add your own methods in extension class only.
Base Class
The generating mechanism redefines and implements the following operations in SAP Gateway: Create, Read, Update, Delete (CRUD) and Query. The class is generated only when the Service Builder successfully generates the code for the classes of the Model Provider Class (MPC). The DPC base class inherits from the generic runtime class /IWBEP/CL_V4_ABS_DATA_PROVIDER .
Note Do not make any change in this class.
When generated, the DPC creates specific methods for the implementation of each operation. Doing so, the Service Builder enables you to work with a small number of classes while redefining only the specific operation for a specific entity set without affecting others.
Naming of Methods
Method names are automatically created and can contain a maximum of thirty characters. Naming convention: <ENTITY SET NAME_OPERATION NAME>
Example

For example, for an entity set called BANKLIST, the base class automatically creates new methods for the CRUD and Query operations. In this case, the names of the methods for the entity set, BANKLIST, will be as follows: BANKLIST_CREATE, BANKLIST_READ, BANKLIST_DELETE, and so on. The description for the method provides information about the method for the corresponding entity set. If a method name exceeds the maximum length, the method is renamed by removing characters from the entity set name and not the operation name. For example, the method name BANKLISTOFCUSTOMERSOFAREA1_CREATE, is too long, it will be renamed as BANKLISTOFCUSTOM_CREATE. If there are two methods with the same name, each one is renamed by adding a number to the entity set name. If the mechanism detects two methods with the same name, BANKLISTOFCUSTOME_CREATE, both methods will be renamed as follows, BANKLISTOFCUSTOM01_CREATE, and BANKLISTOFCUSTOM02_CREATE.

Extension Class
The Service Builder creates an extension class for the DPC, which is the implementation class. You must implement the methods in this class to suit your needs. The extension class inherits from the DPC base class. You can add your own code to specific methods for an entity set in the extension class.
Example If you have a model for customer data and you want to implement the Create operation, redefine the method, CUSTOMER_CREATE, and write your own code. At runtime, your code for the CUSTOMER_CREATE method will be executed in addition to the other generated methods.
If your model does not consist of any Entity Set, only Entity Type methods will be generated for CRUD and Query operations that are defined form abstract classes. You must have at least one Entity Type in your model for the methods to be generated apart from the methods generated from abstract class.
If you have Entity Type and Entity Set in your model then the methods generated are:
  • the redefined methods of abstract class for CRUD and Query operations
  • CRUD and query methods for every Entity Set in the model
Collection and Navigation Flags
Two methods are generated with respect to combination of Collection and Nullable flag in Navigation Property:
Table 1: Combination of Collection and Nullable

Collection

Nullable

Method Redefined

Method Generated

Selected

Not Selected

/iwbep/if_v4_dp_basic~read_ref_target_key_data_list

READ_REF_KEY_LIST

Not Selected

Selected

/iwbep/if_v4_dp_basic~read_ref_target_key_data

READ_REF_KEY

Not Selected

Not Selected

/iwbep/if_v4_dp_basic~read_ref_target_key_data

READ_REF_KEY

Selected

Selected

Cannot be selected together Cannot be selected together
Note

If you do not define Navigation Property Binding, methods for Navigation Property will not be generated.

Base Class holds just the template which can be used while redefining the methods in Extension Class and Extension Class is the place where you can write all the business logic to suite your needs.