cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi

I am trying to create a smartform attached to a odata service with cds view. I am able to create smartfilter and table successfully using annotations and metadata.xml but am stuck up in smartform. The view renders fine with smartfields but the catch is that I have to define entitySet for each of the smartfield whereas in sample applications I checked this was not required.If I remove the entity set from smartfield the smartfield is not rendered. Here is the sequence of steps I followed

Step1: I imported odata service and created a default model.

Step2: Created local annotations file based on data service and it looks as below:

<Annotations Target="ZCustomService.ZCustomServiceType"> <Annotation Term="Common.SemanticKey"> <Collection> <PropertyPath>abc</PropertyPath> </Collection> </Annotation> </Annotations>

In metadata same property exists as below:

<Property Name="abc" Type="Edm.String" MaxLength="4" sap:display-format="UpperCase" sap:creatable="true" sap:updatable="true" sap:label="Purchase Order"/>

In my view, I am using smartform as below:

<sap.ui.comp.smartform:SmartForm xmlns:sap.ui.comp.smartform="sap.ui.comp.smartform" xmlns:sap.ui.comp.smartfield="sap.ui.comp.smartfield" id="__form1"> <sap.ui.comp.smartform:groups> <sap.ui.comp.smartform:Group label="Group title" title="Group title" id="__group0"> <sap.ui.comp.smartform:groupElements> <sap.ui.comp.smartform:GroupElement id="__element0"> <sap.ui.comp.smartform:elements> <sap.ui.comp.smartfield:SmartField id="__field0" value="{abc}" entitySet ="ZCustomService"/> </sap.ui.comp.smartform:elements> </sap.ui.comp.smartform:GroupElement> </sap.ui.comp.smartform:groupElements> </sap.ui.comp.smartform:Group> </sap.ui.comp.smartform:groups> </sap.ui.comp.smartform:SmartForm>

Request your expert advice here..

I have also gone through blogs published on SCN but I dont see these options

https://blogs.sap.com/2016/04/22/how-to-use-smart-templates-with-sap-web-ide-extensibility/

https://blogs.sap.com/2017/06/06/dynamic-field-control-using-annotations-in-sapui5/

View Entire Topic
Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Justin,

I believe your annotation file is missing some UI.DataField elements or UI.DataPoints. Smart Components required this annotations in order to display elements on the screen - No element is displayed by default on any smart control. This is well explained on this blog.

Regards,
Ivan

justin_kemp
Participant
0 Likes

i dont get ui.datafield or ui.datapoints option when I create local annotation file, is this an issue with cds view odata service?

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Likes

Can you share the edmx document for your odata service?

justin_kemp
Participant
0 Likes
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:sap="http://www.sap.com/Protocols/SAPData" xmlns:ux="http://www.sap.com/Protocols/OData4SAP/UX" xmlns:gp="http://www.sap.com/Protocols/SAPData/GenericPlayer" Version="1.0"> <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0"> <Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="ZCustom" sap:schema-version="1" xml:lang="en"> <EntityType Name="ZCustomType" sap:content-version="1" sap:label="Purchase Order Request"> <Key> <PropertyRef Name="Id"/> <PropertyRef Name="s_num"/> </Key> <Property Name="auart" Type="Edm.String" MaxLength="4" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" sap:display-format="UpperCase" sap:label="Service Request"/> <Property Name="ilart" Type="Edm.String" MaxLength="3" sap:display-format="UpperCase" sap:label="Function Location"/> <Property Name="tplnr" Type="Edm.String" MaxLength="40" sap:display-format="UpperCase" sap:label="Asset"/> <Property Name="ktext" Type="Edm.String" MaxLength="40" sap:label="Work Center"/> <Property Name="job_title" Type="Edm.String" sap:label="Job Title"/> <Property Name="scope" Type="Edm.String" sap:label="Scope of Work"/> </EntityType> <ComplexType Name="ZCustomValidationFunction"> <Property Name="IsValid" Type="Edm.Boolean" Nullable="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/> </ComplexType> <EntityContainer Name="ZCustom_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx"> <EntitySet Name="ZCustom" EntityType="ZCustom.ZCustomType" sap:content-version="1"/> <FunctionImport Name="ZCustomAct" ReturnType="ZCustom.ZCustomType" EntitySet="ZCustom" m:HttpMethod="POST" sap:applicable-path="PCA5CD0EEC74BDB164FD51537863EBBD3" sap:action-for="ZCustom.ZCustomType"> <Parameter Name="Id" Type="Edm.Int32" Mode="In"/> <Parameter Name="s_num" Type="Edm.String" Mode="In"/> </FunctionImport> <FunctionImport Name="ZCustomEdit" ReturnType="ZCustom.ZCustomType" EntitySet="ZCustom" m:HttpMethod="POST" sap:applicable-path="P05D289BF56910A8AAAFA1C7749BD8E1B" sap:action-for="ZCustom.ZCustomType"> <Parameter Name="PreserveChanges" Type="Edm.Boolean" Mode="In" Nullable="true"/> <Parameter Name="Id" Type="Edm.Int32" Mode="In"/> <Parameter Name="s_num" Type="Edm.String" Mode="In"/> </FunctionImport> </EntityContainer> <Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm" Target="https://abc.hana.ondemand.com:443/odata/SAP/ZCustom/$metadata"> <Annotation Term="Common.DraftRoot"> <Record> <PropertyValue Property="ActivationAction" String="ZCustom.ZCustom_Entities/ZCustomAct"/> <PropertyValue Property="EditAction" String="ZCustom.ZCustom_Entities/ZCustomEdit"/> </Record> </Annotation> </Annotations> <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="self" href="https://abc.hana.ondemand.com:443/odata/SAP/ZCustom/$metadata"/> <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="latest-version" href="https://abc.hana.ondemand.com:443/odata/SAP/ZCustom/$metadata"/> </Schema> </edmx:DataServices> </edmx:Edmx>
Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Likes

OK, and how exactly you are entering the annotations file for the smart form?

justin_kemp
Participant
0 Likes

I have created a odata service and a model with it. Now I create a local annotations file and add stuff there...but I dont get an option to add UI.DataField elements or UI.DataPoints

If I create a worklist and add selection fields it works fine, but I need a smartform to work