cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to use annotations to add a table to object page in Fiori Elements

TahirLeonenko
Explorer
0 Kudos
1,316

I'm trying to add a table to my object page using annotations. I found this explanation online:

Facet annotation:

<Annotation Term="UI.Facets">
    <Record Type="UI.ReferenceFacet">
        <PropertyValue Property="ID" String="to_Children"/>
        <PropertyValue Property="Target" AnnotationPath="children/@UI.LineItem"/>
        <PropertyValue Property="Label" String="{@i18n>CHILDREN_LABEL}"/>
    </Record>
</Annotation>

LineItem annotation:

<Annotations Target="MyService.Children" xmlns="http://docs.oasis-open.org/odata/ns/edm">
    <Annotation Term="UI.LineItem">
        <Collection>
            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="FullName"/>
            </Record>
            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="Age"/>
            </Record>
            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="EyeColor"/>
            </Record>
        </Collection>
    </Annotation>
</Annotations>

 but what I have tried so far is not working: 

 

<Annotation Term="UI.Facets">
                    <Collection>
                        <Record Type="UI.ReferenceFacet">
                            <PropertyValue Property="Target" AnnotationPath="SAP.I_SalesDocumentType/@UI.LineItem"/>
                            <PropertyValue Property="Label" String="Document Items"/>
                            <PropertyValue Property="ID" String="to_SalesDocuments"/>
                        </Record>
                    </Collection>
                </Annotation>

 

 

 

<Annotations Target="SAP.I_SalesDocumentType">
                <Annotation Term="UI.LineItem" >
                    <Collection>
                        <Record Type="UI.DataField">
                            <PropertyValue Property="Value" Path="SalesDocument"/>
                            <PropertyValue Property="Label" String="SalesDocument"/>
                        </Record>
                    </Collection>
                </Annotation>

 

 

I do get a section in the header with the proper title, but the AnnotationPath or ID does not seem to work as no table pops up. I've also tried inserting the target of my table in my list page/first page (Target="SAP.ZZ1_C_SLCTRCTINFOType"), but it seems like that also does not do anything (although in the first place, would not be a solution I could use). My end result should be to click to the object page, and have a list of Sales Document Items with their associated products and other information that is specific to the line items. Does anyone know I'm doing wrong in my code above? Or know of any other solution to add a table to my object page using code in SAP BAS?

Accepted Solutions (0)

Answers (1)

Answers (1)

TahirLeonenko
Explorer
0 Kudos

The underlying OData service is from a self created CDS view. I did as you answered in the previous question I posted and added an association to a second CDS view:

TahirLeonenko_0-1720555733336.png

I added the _ObjPage column to the main CDS view too:

TahirLeonenko_1-1720555789009.png

where the second CDS view has the proper annotations:

TahirLeonenko_2-1720555838258.png

but when I tried creating a new Fiori app with navigation:

 

TahirLeonenko_4-1720556018554.png

There was no table in the second page. Later I tried adding the xml annotation like this:

TahirLeonenko_6-1720556592137.png

And then the table appeared on the object page regardless of whether _ObjPage is the navigation entity to it or not.
The only difference seems to be that with the navigation entity, you can click on the individual items again, and that brings you to a third page that causes an error, and without the navigation it does not have a third object page:

TahirLeonenko_7-1720557469628.png

There are a couple of issues though with the current solution. One, the rows do not appear in the same order as what the annotations say they should, and two, the table does not appear until you click on the settings button, and add the columns to the table, which has to happen individually any time. 
Do you know if there is anything wrong with my CDS or XML annotations that causes either of these errors? Or anything in general I might've done wrong which might cause general errors?

 

 

junwu
SAP Champion
SAP Champion
0 Kudos
find some tutorial, don't compose your own stuff, you are far from there