Skip to Content
Product Information
Author's profile photo Bernhard Grusie

Service Consumption Model 2 for OData Client Proxy


  • 16/11/2023: ADT wizard robustness, see section “What comes next?”.


This blog post will describe the Service Consumption Model 2 for OData. I will describe its benefits, provide a description of the model, take a look at the OData Client Proxy at runtime and also dive into the ABAP cross trace integration as well.

If you want to receive or send data to an OData V2 or V4 service within SAP BTP, ABAP Environment or SAP S/4HANA ABAP Environment, you can use the “Service Consumption Model 2” for OData. As of release 2311, it is possible to consume Complex Types, Complex Collection, Action (bound) and Functions (bound). Of course, the consumption of Entity Types and Entity Sets is also possible.

In addition you get fewer generated artifacts. The persistence of the underlying model has changed completely. In the first version you get an abstract CDS View for each Entity Type. For large services with multiple Entity Types, you could end up with a lot of artifacts. Now only one class with type definitions is created.


Many artifacts in the first version of the Service Consumption Model for OData

Use case

If you have an SAP BTP, ABAP Environment or SAP S/4HANA Cloud, ABAP Environment system you can use the Service Consumption Model for OData. From here you can connect to a Cloud or an on-premise system.





In my scenario I am consuming the /dmo/travel service from another Cloud system. A call to the Entity Set Travel returns the following data:

GET /sap/opu/odata4/dmo/api_travel_u_v4/srvd_a2x/dmo/travel_u/0001/Travel
    "@odata.context": "$metadata#Travel",
    "@odata.metadataEtag": "W/\"20230919122803\"",
    "@odata.nextLink": "/sap/opu/odata4/dmo/api_travel_u_v4/srvd_a2x/dmo/travel_u/0001/Travel?$skiptoken=100",
    "value": [
            "@odata.etag": "W/\"SADL-202305191948080000000C~20230519194808.0000000\"",
            "AgencyID": "70041",
            "AgencyName": "Maxitrip",
            "BeginDate": "2023-06-03",
            "BookingFee": 40.0,
            "CurrencyCode": "USD",
            "CustomerID": "594",
            "CustomerName": "Ryan",
            "EndDate": "2024-03-31",
            "LastChangedAt": "2023-05-19T19:48:08Z",
            "Memo": "Vacation",
            "SAP__Messages": [
            "Status": "P",
            "StatusText": "Planned",
            "TotalPrice": 1889.0,
            "TravelID": "1"

Service Consumption Model 2 for OData

As of release 1808, you can use the Service Consumption Model for OData. From release 2311 on, the wizard in the ABAP Development Tools (ADT) will automatically use the new version.


Select File –>  New –> Service Consumption Model and choose OData as Consumption mode in ADT.

The consumption system requires a representation of the remote service. This knowledge is used to create the URL, write and read the JSON form the HTTP requests and responses. Therefore, the wizard needs the EDMX file (a service metadata document that describes the data model exposed by the service as an HTTP endpoint). OData uses EDMX as the format for this description of the remote service. You can get this by adding $metadata to the end of the service document, in my case it is the following URL:

GET /sap/opu/odata4/dmo/api_travel_u_v4/srvd_a2x/dmo/travel_u/0001/$metadata

I saved this file on my computer to use this in the wizard. In addition I chose ZBG_TRAVEL_SCM as the class name. This class is the model representation and will contain all the types for my client.


EDMX import and class name


The EDMX file is analyzed beforehand to identify potential problems. It could be that certain artifacts are ignored, for example, parts of them violate the OData metadata rules. In my case, the EDMX file describes several Entity Types, Entity Sets, a Complex Type and a Bound Action.


Analysis of EDMX file


The next step looks for the OptimisticConcurrency annotation of the Org.OData.Core.V1 vocabulary. If an Entity Set has this annotation, modifying requests must use an ETag. If an Entity Set does not have this annotation, you can select the ETag support here.


ETag support

Finally, I get the Service Consumption Model 2 for OData:


Service Consumption Model 2 for OData

In the upper left section, you can see the model class that describes the /dmo/travel service. I use the code snippets from Travel EntitySet and Read list as operation, as a starting point for my OData client.


Model class

The model class has the following parts:

  1. Type definitions that can be used in my client code. I use a table of zbg_travel_scm=>tys_travel_type to retrieve the travel data.
  2. To find the corresponding types, constants are created for Entity Sets, Entity Types, Complex Types, Actions and Functions. Here is the ABAP doc for the Entity Type constant, including the link to the type:


  3. The model definition is done in several method implementations. The types are used to define all the artifacts of the remote service. In addition a mapping between the ABAP and the EDMX name is done here. ABAP artifacts are limited to 30 characters. In EDMX they can be up to 128 characters long in camel case.

If you need to customize the result of the wizard, for example because you need to adapt to certain naming conventions, you can modify the source code of the generated class and adapt it to your needs.


Support for Action and Functions

To call an action or a function, structures and tables for the parameter are generated. With release 2311 the ADT integration is still missing. So I can’t select a bound action, an action import, a bound function or a function import and use the code snippet from the ADT. However, the parameter structure is there and I can use it at runtime to call the operation. You can find examples in SAP Help portal.


Connecting to a Remote Service

In a cloud system I need an outbound communication scenario, an outbound service and a communication arrangement for the http connection. Tutorial: Prepare Consuming System and Service Consumption Model describes the steps to achieve this.


OData Client Proxy at Runtime

For my client, I have used the code snippet from ADT (right hand side in the Service Consumption Model) to read the Entity Set Travel. The client code uses the type from the model. changed three things after that:

  1. Established the HTTP connection using the communication scenario and the outbound service.
  2. Changed the IV_RELATIVE_SERVICE_ROOT parameter of the factory (line 56 in the screenshot below) to point to the OData service. This path depends on the communication system.
  3. Added the out->write() statement at the end (line 81).

And voila, the GET request and transformation of the JSON response to ABAP was done for me.


OData Client Proxy at Runtime


The Service Consumption Model 2 for OData supports more OData features and generates fewer artifacts. The model class can be adapted to my needs, if the result of the wizard does not meet my expectations. It would be great to get feedback from you, so that we can further improve the wizard if this is indeed the case.

What comes next?

  • Make the ADT wizard more robust when importing EDMX files. Skipped elements will be part of the generated model to identify them later. 
    • As of release 2405, the ADT wizard skips elements that violate the OData specification (for example trying to create a key property inside a complex type). You find skipped elements in the gcs* constants.
  • Full support for actions and functions in the ADT, including code snippets.
  • On-premise shipping of the Service Consumption Model for OData.
  • Multiple namespace support for SuccessFactors services.
  • OpenAPI importer to support REST services.


For more details on the OData Client Proxy, Service Consumption Model and communication scenario, see Developing External Service Consumption: OData Services

Feel free to ask me questions, provide feedback or to share this blog with others. Thank you.




Tip for developers

Sometimes it is good to know what the OData Client Proxy does under the hood. Especially connecting to another system can be tricky. Therefore the OData Client Proxy is part of the ABAP Cross trace (ADT Windows –> Show View –> ABAP Cross trace):


Activate OData Client Proxy in cross trace


In the trace result you can see for example the response payload and the CSRF token fetch:


HTTP payload in cross trace



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Frank Li
      Frank Li

      Thank you for great sharing. You mentioned that want to receive or send data to an OData V2 or V4 service within SAP BTP, ABAP Environment,  can use the “Service Consumption Model 2” for OData. What do you mean receive or send data to an OData V2 or V4? In this case why not use Remote API? Is this for there is no corresponding Remote API then turn to this approach? Thank you.

      Author's profile photo Bernhard Grusie
      Bernhard Grusie
      Blog Post Author

      HI Frank,


      you have two systems (see use case section), the Service Consumption Model is for the client side. The OData Client Proxy is an ABAP client for OData. It allows you to make GET, POST, PUT, etc. requests to a remote OData service.

      Best regards

      Author's profile photo sathyaprabhu n
      sathyaprabhu n

      Hi Bernard,

      Thanks for Sharing. It is now available for ABAP on BTP and S/4 HANA Cloud as per the article, is there a plan to enable the OData client of On-premises too? Technically ABAP on Cloud is now available as a part of Development Extensibility(Embedded Steampunk).


      Author's profile photo Bernhard Grusie
      Bernhard Grusie
      Blog Post Author

      Hi Sathya,

      On-premises delivery is planned, as you can see in the "What's next?" section. The reason for not shipping was that our first design approach in SCM1 was not perfect. After changing of the persistence, we can ship OData client on premise.

      Best regards

      Author's profile photo sathyaprabhu n
      sathyaprabhu n

      Thanks for the response. I missed the "What's next?" section.

      Author's profile photo Andre Fischer
      Andre Fischer

      Hi Sathya,

      as described in my blog post

      How to use the OData Client Proxy in SAP S/4 HANA | SAP Blogs

      it would be possible to generate the Service Consumption Model as a workaround in a Steampunk System (e.g. a trial system).

      Then you would be able to copy the code to your on premise system and perform the steps described in my blog post to create an OData V4 model provider class from the generated Service Consumption Model class.

      This can then be registered as an OData Proxy Client.

      Kind regards,


      Author's profile photo Vijaya Kumar Vadrevu
      Vijaya Kumar Vadrevu

      Hi Bernhard,

      Thank you for sharing the new features.  I look forward to use consumption model 2.

      I have been using consumption model to push and pull data from S/4 On-prem from SAP BTP.

      I am facing a strange problem. Everytime whenever there is a change in metadata, I had to create a new consumption model and delete the old one. I had to adjust the code accordingly.

      I could not regenerate or refresh the existing consumption model.

      Does Consumption model 2 overcome this issue?

      Best Regards


      Author's profile photo Bernhard Grusie
      Bernhard Grusie
      Blog Post Author

      I mention in the blog that we have to guess an ABAP name (30 characters) from the Edm world of 128 characters. This guessing algorithm is stable up to a certain point.
      For example, if a new entity type has been introduced and multiple entries reach the 30 character limit, we add a number to the end of the type name to be unique.


      Finally, we create a large class with types and the definition. It is also possible to just add the new type and method implementation to your used model class manual when you come to such situations.

      Author's profile photo Marko Kundacina
      Marko Kundacina


      hello Bernhard


      For the metadata:$metadata/

      I've tried to generate the SCM in the trial ABAP Runtime in BTP and I'm getting "Activation failed with code '2'" ?!

      Moreover, an inactive SCM is generated and if I try to delete it, I'm getting HTTP/1.1 500 Internal Server Error ?!


      Could you kindly help, please?


      thanks & best regards



      Author's profile photo Maryia Saskevich
      Maryia Saskevich


      Did you solve this problem?

      Author's profile photo Marko Kundacina
      Marko Kundacina



      no, i did not.

      I think this is (yet another) limitation of the Trial abap account in BTP. The strange thing is that the previous version of the SCM used to work in the Trial. With this new version, it cannot seem to be activated in Trial nor I can delete the generated malfunctioning SCM object 🙁




      Author's profile photo Bernhard Grusie
      Bernhard Grusie
      Blog Post Author

      The limitation of the Trial ABAP account will be removed with Hot Fix collection 6.

      Author's profile photo Christian Dülsen
      Christian Dülsen


      one there a tutorial how to use the Business Data (lt_business_data) within a new Fiori.

      In Version 1 of the Service Consumption Model we had an generated CDS that we could use for generating a Fiori-App.

      Now there is only a model class....

      Thx in advance

      Christian Dülsen

      Author's profile photo Bernhard Grusie
      Bernhard Grusie
      Blog Post Author

      Hi Christian,


      I am not sure how you reused the abstract CDS view for a Fiori UI, but with the new version it is not possible to use the type definition directly.

      Best regards