Hello,
I modeled an OData-Service via SAP Gateway Builder where I wanted to filter by a child collection. Unfortunately I run in multiple problems. This one focuses on the generated sql statement by the SADL framework.
The generated SQL for the following read operation looks like this:
/sap/opu/odata/sap/zbp_scn_srv/BUT000Set?$select=NameLast&$filter=BUT020Set/Addrnumber eq ‘152360489’
SELECT "BUT000Set"."NAME_LAST" AS "NAME_LAST",
"BUT000Set"."PARTNER" AS "PARTNER"
FROM "ZBUTV000" AS "BUT000Set"
WHERE "BUT020SET.BUT020Set"."ADDRNUMBER" = ? AND "BUT000Set"."MANDT" = '099'
WITH PARAMETERS( 'LOCALE' = 'CASE_INSENSITIVE' )
In this case, the CDS-View is used as a normal DDIC view (DDIC-View name used). The association is not available in this kind of query execution out of class CL_SADL_SQL_STATEMENT: EXECUTE_CLIENT_SPECIFIED (LCL_EXECUTOR_HDB).
Did I make a mistake during Gateway Service development? Is this currently not possible or not supported by the SADL framework?
Our system is a NetWeaver 7.50 SP3.
CDS-Views and Gateway Implementation:
ZBUT000 points to database table BUT000 and includes an association to CDS-View ZBUT020 which points to database table BUT020. The DDIC structures of the CDS-Views were imported into Gateway Builder. The Service Implementations of both entity sets (BUT000Set and BUT020Set) where mapped to the related CDS-View.
To drill down from BUT000Set to BUT020Set I added an association in Gateway Builder.
/sap/opu/odata/sap/zbp_scn_srv/BUT000Set?$filter=NameLast eq ‘Guru’ -> Works
/sap/opu/odata/sap/zbp_scn_srv/BUT000Set?$filter=NameLast eq ‘Guru’&$expand=BUT020Set -> Works
What does not work is a filtering on attributes of the child collection (BUT020Set) – e.g.:
/sap/opu/odata/sap/zbp_scn_srv/BUT000Set?$expand=BUT020Set&$filter=NameLast eq ‘Guru’ and BUT020Set/Addrnumber eq '152360489'
Even without expand (something like an EXISTS) does not work:
/sap/opu/odata/sap/zbp_scn_srv/BUT000Set?$filter=NameLast eq ‘Guru’ and BUT020Set/Addrnumber eq '152360489'
The error received from Gateway looks like this:
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>SY/530</code>
<message xml:lang="de">Es ist eine Ausnahme aufgetreten.</message>
<innererror>
<application>
<component_id/>
<service_namespace>/SAP/</service_namespace>
<service_id>zbp_scn_srv</service_id>
<service_version>0001</service_version>
</application>
<transactionid>57B105A899338E6FE10000000A64C954</transactionid>
<timestamp>20160824070707.4963050</timestamp>
<Error_Resolution>
<SAP_Transaction>
Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details
</SAP_Transaction>
<SAP_Note>
See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)
</SAP_Note>
</Error_Resolution>
<errordetails>
<errordetail>
<code>CX_SQL_EXCEPTION</code>
<message>
invalid identifier: BUT020SET.BUT020Set: line 1 col 120 (at pos 119)
</message>
<propertyref/>
<severity>error</severity>
<target/>
</errordetail>
<errordetail>
<code>/IWBEP/CX_MGW_TECH_EXCEPTION</code>
<message>Es ist eine Ausnahme aufgetreten</message>
<propertyref/>
<severity>error</severity>
<target/>
</errordetail>
</errordetails>
</innererror>
</error>
Regards,
Daniel