Versioning of an OData Service
Example of creating a new version of an OData service in an SAP system, followed by its use in a SAPUI5 application.
The SAP Gateway technology provides consultants and developers with the ability to leverage service versioning when improving or enhancing their OData services. One of the nice aspects of this is that older versions of an OData service remain available for use alongside the new ones. What do I mean? When developing new versions of an OData service, the older versions can still be used in your application without any limitations.
This article presents an example of creating an OData service and then creating a second version based on the existing first version.
Step #1: Creating a New OData Service (Version 001)
The following video clip shows the sequence of actions used to create the first version of the OData service.
An earlier note also covered an example of creating an OData service.
See Создание Web приложения с помощью фреймворка SAPUI5 (6)
Step #2: Preparing to Create a New Version of the OData Service
An essential part of every OData service developed in an SAP system is a pair of classes: the Model Provider Class and the Data Provider Class. To create the new version, one of these classes will be modified. In real project scenarios, you will most likely need to create new versions of both classes. However, for this demonstration, only the Data Provider Class will be used.
I will copy the previously created DPC_EXT
class into a new one and make a few cosmetic changes. The corresponding video clip shows the steps.
Step #3: Creating and Registering a New Version of the OData Service (Version 002)
The next video clip shows the steps for creating a new version of the OData service in the system, with a new version of the DPC_EXT
class (see Step #2).
The new version of the OData service is registered using transaction /IWBEP/REG_SERVICE
.
Note: you must also specify the Model Provider Class for the newly created version of the OData service, even if you didn’t create a new version of it (as in this example).

Step #4: Activating the New Version of the OData Service in the System
Activate the newly created service version #002 in the system using transaction /IWFND/MAINT_SERVICE
.
Step #5: Testing the Call to the New Version of the OData Service
Using transaction SEGW
, I test calling the second version of the OData service.
You can call a specific version of the OData service by specifying the version number in the requested URI. For example:
/sap/opu/odata/SAP/ZDEMO_VERS_SRV;v=2/
I check the results.
Step #6: Parallel Calls to Two Versions of the OData Service from a SAPUI5 Application
To confirm and demonstrate the ability to call multiple versions of an OData service in parallel within a single SAPUI5 application, I provide a short demo using the following controller source code.
onInit: function() {
var sServiceUrl_v1 = \'/sap/opu/odata/SAP/ZDEMO_VERS_SRV;v=1\';
var OdataModel_v1 = new sap.ui.model.odata.v2.ODataModel(sServiceUrl_v1);
var sPath1 = "/outTextSet";
OdataModel_v1.read(sPath1, {
success: function(oData, response) {
console.log(oData.results);
}
});
var sServiceUrl_v2 = \'/sap/opu/odata/SAP/ZDEMO_VERS_SRV;v=2\';
var OdataModel_v2 = new sap.ui.model.odata.v2.ODataModel(sServiceUrl_v2);
var sPath2 = "/outTextSet";
OdataModel_v2.read(sPath2, {
success: function(oData, response) {
console.log(oData.results);
}
});
}
});