The parameter to input variable values for an ODATA service is: /sap/opu/odata/sap/<query name>_SRV/<query name>(VAR1='value1',VAR2='value2')/Results
If VAR2 is a range variable, both VAR2='from value' and VAR2To='to value' needs to be filled.
A query is defined with variables. In transaction RSRT, the query is run as below:
Variable GL_CALYR_RANGE is a range variable, although the 'to' field is leave as blank, in query execution, it is automatically filled as range from 2011 to 2011.
It is defined as an easy query and ODATA service GL_ODATA2_SRV is generated according to steps in Steps to Create an ODATA service for a BW Query
Although both variables are optional, they have to be filled when access the ODATA service. When run URI: /sap/opu/odata/sap/GL_ODATA2_SRV/GL_ODATA2Results to access the data in transaction /n/iwfnd/gw_client, error ”Incomplete URL; parameter or mandatory filter missing“ (BW_BICS_EQ/132) is hit:
To access the query results in the ODATA service, variable input has to be provided as Parameters for the ODATA service as: <query name>_SRV/<query name>(Parameters)/Results.
To find out the parameter names, run URI: /sap/opu/odata/sap/GL_ODATA2_SRV/$metadata, all parameters listed in the key section for entity <query name>Parameters has to be filled accordingly:
For an interval variable, it generates 2 parameters for both From and To fields. The naming convention is <var name> for from field and <var name>To for to field. However for some system on a low version or SP, the To field may have a different name, always check $metadata to see what is expected.
So for this query, the correct URI to access query result is:
As the URI is usually not an end user tool to access query result in ODATA service, the syntax check of parameters are strict. To use the URI successfully, pay close attention to the points below:
- The parameter for the ODATA service is case sensitive, please always use the exact parameters as listed in $metadata (most cases are capitalized letters except 'To'). Both query name and variable name.
If the query name is in lower case, error “Resource not found for the segment 'xxxx'.”，“The request URL or the metadata definition is incorrect. (/IWFND/MED167)“ as below is hit:
If the variable name is in lower case when it should not be, error “Invalid key name in key predicate. Expected name is 'XXX, YYY' ( /IWFND/CM_CONSUMER122, /IWCOR/CX_DS_URI_SYNTAX_ERROR)”as below is hit:
- The variable values must all indicate with quotation mark ' '
If quotation mark is missing, error “Invalid key predicate type for 'XXXX'. Expected type is 'Edm.String' (/IWFND/CM_CONSUMER122, /IWCOR/CX_DS_URI_SYNTAX_ERROR)” as below is hit:
The expected variable values data type can be also found in $metadata:
- For interval variable, both From and To fields must be provided as parameters, although in other front end tools to To fields can be leave blank.
If the 'To' field is not provided, or any variable input required in Key section of <query name>Parameters entity is missing, error "The request URI contains an invalid key predicate (/IWFND/CM_CONSUMER122, /IWCOR/CX_DS_URI_NOT_MATCHING)" as below is hit:
- Please don't add any blank between variables in the parameter string.
If there is blank between different variables, error “Invalid key name in key predicate. Expected name is 'XXX, YYY' ( /IWFND/CM_CONSUMER122, /IWCOR/CX_DS_URI_SYNTAX_ERROR)” as below is hit:
Here ' GL_CALYR_RANGE' is took as parameter name instead of 'GL_CALYR_RANGE' .