Skip to Content

OData for CDS with Parameters

Hi Experts,

Let me share my experience and ‘How to’ while creating OData Service for CDS View with Parameters.


I am not sure whether the steps i will be explaining is the right one but i would like to share how i did it.

Step 1:

Add the Package to Eclipse Project Explorer and create a DDL Source .


Step 2:

Define a sample view with Parameter and Activate it.


Anotation OData.publish will expose the CDS View as OData Service.

Step 3:

Add the Service using the /iwfnd/miant_service.

Step 4:

Get the metadata and find out the entitySet of an entity without a sap:parameter


Step 5:

Execute the URL as shown below


voila thats the result…

Open to comments and anybody can edit appropriately.

Happy Coding


You must be Logged on to comment or reply to a post.
  • Hello Vishnu,

    I have followed the steps as mentioned in the blog, but i am getting error while executing the URI as 'Resource not found for segment'.

    Could you please suggest!

    Thanks in advance.



  • Hi Vishnu,

    If I want to get multiple values from the service, how can I pass the parameters. In your example, only one row is retrieved. Use case: Suppose I want to retrieve all employees of a department, so I give Dept_Id as parameter, and key will be obviously employee id only. So I don't want to give empid as input parameter in service, but only the dept id. Is it possible?


    • Hi Rajiv,

      Inside the CDS Definition you can custom code required queries.You can even have a Definition without parameters and in this sample Parameter is used in where clause for READ operation.



    • Hi Vishnu,

      Thanks for the blog. It was good and informative.

      Hi Rajiv,

      If you want to use Dept_Id as parameter and empid is your key, then you can use something as follows:

      If you check the screen shot of $metadata in the blog by Vishnu, one entity type with name Zemployee_Sam_ParParameters is created and corresponding entity set is Zemployee_Sam_Par (which is equivalent to name of CDS).
      Also, a, association from Parameter Set to CDS View Set (Zemployee_Sam_ParSet) is created having Navigation Property Name as "Set".

      Best Regards,

  • Hi Vishnu,

    Which version of SAP is required to run this, we are currently using Release 740 and Service pack level 0004. when go to the SICF T-code navigate to the path my service is not there, Please suggest what should we required.



    • According to Documentation NW 740 would suffice i suppose.

      After creating your CDS and exposing it as OData you must go to T-Code /iwfnd/maint_services to add the Service.Then it would appear in the ICF.



      • Hi Vishnu,

        I am trying to create an Odata services based on a CDS view with parameters on NW 740 with SPS 12. I have created the service via SEGW. But the problem is I cant access the same via the URL.

        My CDS view has an input parameter p_dist which is not part of the SQL view and hence the URL keeps throwing an error.

        Could you please if possible share screen shots of the service that was generated in the system , so I could look at how you have mapped the entities.



  • Hi Vishnu Pankajakshan,

    I have created a CDS view with input parameter and also created service via SEGW. I am following two approaches :

    1. While I am testing the service in gateway client, it returns me 200 and when i execute the uri for metadata , it is working fine. But when i follow step 5 of your blog ie. when i test the service with my parameter value as depicted in your step 5, it throws me error 500. I have tried every possible way and unable to understand where am i going wrong. Should i need to code or redefine any method or what. Please guide me.

    2. When I use  annotation @odata.publish:true in the CDS view it throws me warnings for the cds view as view does not exist and odata exposure is not possible which is restricting CDS view to activate also when I am checking in /iwfnd/maint_service , I am unable to find my service to add it. Or it can be said that I am confused how to find the automatically created service by using this annotation.

    So please guide me and help me  to solve this problem as I am struggling a lot in this and have an urgent requirement for this. Your guidance would be helpful.


    Best Regards,


    • Your metadata seems fine.. i think since you system is ECC and 7.4 NW you need to try the traditional method of  service creation using SEGW where u can create one using CDS Views.I have seen documents explaining those.I came to this conclusion becoz it throws for you while using OData.publish . This was introduced in NW 7.5 System i suppose.



      • Hi Vishnu,

        As I have mentioned earlier in my first comment , I have created my service using SEGW also, the service is working fine with metadata but while I test it with particular input parameter of the CDS view as you are doing in step 5 of your blog i.e URL/zemployee_SAM_PARSET(p_empid=2,empid=2). For my case URL/SANKYSet(yfvglobcc=50290), it is giving me 500 error. So I need to know where am I going wrong.. Should i need to code or redefine any method or what?Could you please help me and guide me.


        Best Regards,


  • Hi Vishnu,

    How will you pass the non-key attribute as a parameter in odata URL?

    it will be helpful if you share the information.


    Thanks & Regards,


  • Hi Vishnu,

    I have followed the same steps for creating the OData from the CDS view by using the OData.pulish:true.

    Last week it was working fine, suddenly the metadata of the service got changed. Now the metadata data is loading without the parameters Entity Type and without the Entity Set of an Entity Type without sap:parameter. The same service is giving correct metadata in some other systems(performance system). I have mentioned the metadata links with screenshots below.


    ER9/001 (metadata is wrong ) –$metadata

    CCW/715(loading correct metadata) –$metadata


    Do you have any idea why the metadata is loading without parameters?

    Thanks & Regards,


  • Hi following your ‘How to’ I have managed to create a CDS View and expose oData. I’m able to retrieve the metadata of my service but I cannot execute service from browser request passing parameters.

    Bellow is the metadata for the CDS View service

    Basically what I want to do is to pass date_from and date_to properties and get the response. The other fields that are members of the key cannot really specify a single entry (and also not really define a key) so I don’t want to have the information to pass it into the request URI.

    So I’m trying to call the service with request URI:




    Both returns me the same error

    And the error message for both from /IWFND/ERROR_LOG is


    This is the definition of my parameters in the CDS View


    dats is a data element of type abap.dats Already defined in the system.

    Edit: Also the request URI 


    Results in the following error:

    So, basically I just need to format the date URI properly but I don’t know how. Anyone who could provide me with information or a document on URI format for each type would be welcome! 


    Edit2: As mentioned by Gopalakrishnan Ramachandra the correct way to pass parameters to pass the parameters into the URI, also I was needed to determine the type of argument and fix the format of the datetime so the working URI for my case was


    • This was really helpful.  It's very strange how you have to make the OData with the parameter in the URL with /Set.  I would not have guessed this.  Your comment saved a lot of time.




  • Hi All,



    Kindly follow the below link that would help us to learn how to consume CDS in OData(Reference Datasorce).

    Thanks and Regards,

    Vishnu P



  • Hi Vishu,

    I am getting below error while I am using annotation odata.publish : true

    Model 'ZBRI_VENDOR_CDS' version '0001' not found
    - Service ZBRI_VENDOR_CDS does not exist
    - Class ZCL_ZBRI_VENDOR does not exist
    - Service ZBRI_VENDOR_CDS is not active
    - Default Authorization Values are missing for Service ZBRI_VENDOR_CDS 0001
    - View has generated Objects
    - Entity CDS-ZBRI_VENDOR: Parameter vendor_name has no data element

  • Very nice blog Vishnu!

    I'm struggling to run this oData service from S/4HANA Cloud:$metadata

    It has 3 parameters, but I cannot find a way to make it work. Could you share any insights?

    Regards, Chris