Brian Roby
CDS and Parameters, adding required info to the URL, HOW?
Brian Roby · over 1 year ago · Question
Answered
Brian Roby

Hello everyone,

A custom CDS has been generated by another user and it contains parameters.

When the URL is created, the required information for the parameters is omitted from the URL.

Thus, when trying to use the generated URL within Excel, using the Get Data functionality (Get Data>From Other Sources>From ODATA fee) I get an error reported by Excel stating that the request failed... with part of the error message indicating that the YY1_... source "was not found".

Searching around, I have found a SAP Knowledgebase article # 2600276 that attempts to explain possible solutions to my problem.

Trouble is, being very new to this SAP development stuff, I don't know how to really interpret the information given in the SAP Note.

The information in the note states the following:

Reproducing the Issue

  1. Using your S/4HANA Cloud account, login to your Fiori Launchpad
  2. Expose a custom CDS view based on the standard view provided by SAP that has few parameters.
     
    Note: If the parameters are hidden, make them unhidden and republish your CDS view
     
  3. Create an OData communication arrangement scenario using the application Maintain Communication Arrangements
  4. Call your OData Service using for example POSTMAN as follow https://<URL>/sap/opu/odata/sap/YY1_<ODATA-SERVICE>
  5. User gets list of EntitySets
  6. Call any of the EntitySets error occurs

Cause

Calling an OData EntitySets with parameter like that, <URL>\YY1_<ODATA-SERVICE>\EntitySets is not correct. Refer to the resolution section

Resolution

To call the correct Entitysets with parameter, do the following:

  1. Get the metadata first, <URL>\YY1_<ODATA-SERVICE>\$metadata
  2. In the metadata locate your EntitySets and check its Entity type, it will be something like this: 
     <EntitySet Name="YY1_<NAME>" EntityType="YY1_<ODATASERVICE>.YY1_<NAME>Parameters" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false" sap:content-version="1"/>
  3. Then locate the the <EntityType Name="YY1_<NAME>Parameters" as shown below
    <EntityType Name="YY1_<NAME>Parameters" sap:semantics="parameters" sap:content-version="1">
                    <Key>
                        <PropertyRef Name="P_1"/>
                        <PropertyRef Name="P_2"/>
                    </Key>
  4. Under the Parameters EntityType find the following:
     <NavigationProperty Name="<RESULTSNAME>" .../>
                </EntityType>
  5. Now the user can form the URL as follow https://<URL>/sap/opu/odata/sap/YY1_<ODATA-SERVICE>/YY1_<NAME>(P_1='<WHATEVER-VALUE>',P_2='<WHATEVER-VALUE>')/<RESULTNAME>
    1. <RESULTNAME>: Whatever the name is from step 4
    2. YY1_<NAME> is the EntitySet Name from step 2
    3. P_1, P_2: Name of parameters from step 3, If the parameters list has X numbers of parameters, they need to be listed
  6. Note: If the result is very large, we can add $top=1 for testing purposes like that:
    https://<URL>/sap/opu/odata/sap/YY1_<ODATA-SERVICE>/YY1_<NAME>(P_1='<WHATEVER-VALUE>',P_2='<WHATEVER-VALUE>')/<RESULTNAME>?$top=1 

No idea what they are referring to with regards to the "EntitySets" in the first part and the $metadata tag referred to in point 1 in the Resolution section.

Can anyone please offer some advice/guidance to a beginner in this area?

I have been given an ODATA feed url that I have used in another project, but that one did not contain a Parameterised CDS query.

Thanks in advance,

Brian.

Comments

Comments
Alumni