1

In our context we are using a custom OData interface on S/4 side which is generated from a CDS view, which again has annotations. The resulting EDMX is of the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
    <edmx:DataServices m:DataServiceVersion="2.0">
        <Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="vdmerror">
            <EntityType Name="TestEntity">
                <Key>
                    <PropertyRef Name="TestEntityID"/>
                </Key>
                <Property Name="TestEntityID" Nullable="false" Type="Edm.String"/>
                <Property Name="SomeField" Type="Edm.String"/>
            </EntityType>
            <EntityType Name="FieldValues">
                <Key>
                    <PropertyRef Name="FieldValuesID"/>
                </Key>
                <Property Name="FieldValuesID" Nullable="false" Type="Edm.String"/>
                <Property Name="SomeAdditionalProperty" Type="Edm.String"/>
            </EntityType>
            <EntityContainer Name="default" m:IsDefaultEntityContainer="true">
                <EntitySet EntityType="vdmerror.TestEntity" Name="TestEntity" sap:searchable="true"/>
                <EntitySet EntityType="vdmerror.FieldValues" Name="FieldValues" sap:searchable="true"/>
            </EntityContainer>
            <Annotations Target="vdmerror.TestEntity/SomeField" xmlns="http://docs.oasis-open.org/odata/ns/edm">
                <Annotation Term="Common.ValueList">
                    <Record>
                        <PropertyValue Property="Label" String="Value Help for Field"/>
                        <PropertyValue Property="CollectionPath" String="FieldValues"/>
                        <PropertyValue Property="SearchSupported" Bool="true"/>
                        <PropertyValue Property="Parameters">
                            <Collection>
                                <Record Type="Common.ValueListParameterInOut">
                                    <PropertyValue Property="LocalDataProperty" PropertyPath="FieldValuesID"/>
                                    <PropertyValue Property="ValueListProperty" String="FieldValuesID"/>
                                </Record>
                            </Collection>
                        </PropertyValue>
                    </Record>
                </Annotation>
            </Annotations>
            <atom:link rel="self" href="/api/odata/v2/vdmerror/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />
            <atom:link rel="latest-version" href="/api/odata/v2/vdmerror/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

In SDK versions < 3.6 this worked fine in that also for the ValueEntity entity set a FluentHelper was generated. Afterwards not anymore. Debugging the generation process we found out that the allowed functions which are checked for generating the FluentHelper are identified in the AllowedFunctionsResolver, which has two different sources for the allowed functions: either from the annotations or the sap-attributes on the entity sets.

In our case, the annotations are used because they are present. But unfortunately it keeps the allowed functions in a map were the key is derived from the target attribute in the annotations element (in our case ValueField, see AllowedFunctionsResolver.readOdataSpecFromMetadataFile(...)). Later on in the process however when iterating over the entity sets, the entity name is used as the key for the lookup in the map of allowed functions, where it of course finds no entry and does not generate the FluentHelper interface (s. NamespaceClassGenerator.processEntitySet(...)).

If instead the PropertyValue of the CollectionPath attribute would be used, this would work since it contains the reference to the entity set. So the question is whether the current behaviour is really the intended one?

Our current workaround is to delete the Annotations from the EDMX prior to generation, however this is a bit error prone, although also this could be automated of course.

5
  • Hi Tim, I assume the behaviour you describe above relates to the current version 3.9.0, right?
    – Emdee
    Commented Dec 10, 2019 at 12:39
  • Hi Emdee, yes it is for the current one (3.9.0).
    – Tim L.
    Commented Dec 11, 2019 at 9:31
  • Hm, that's unexpected. With version 3.9.0 this should be fixed. Can you provide us an minimal minimal reproducible example so that we can reproduce (and fix) the issue? Commented Dec 11, 2019 at 9:57
  • Hi, replaced example in the application with a minimum reproducible example. Hope this helps.
    – Tim L.
    Commented Dec 11, 2019 at 16:10
  • Hi Tim, thank you very much. I could now reproduce the issue and am now investigating a fix. I will provide an answer once I can tell you more. Commented Dec 13, 2019 at 15:11

1 Answer 1

4

Version 3.11.0 of the SAP Cloud SDK fixes this issue.

This means the generator now better understands to which Entity an annotations block belongs (or doesn't, like in your case).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.