Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Introduction


In a recent partner workshop I was asked how one can add annotations to an OData service when your system runs on top of SAP NetWeaver 740.

While with SAP NetWeaver 750 and higher you can add annotations within the CDS DDL source code there is no such support available for SAP NetWeaver 740.

Nevertheless customers and partners can leverage CDS views as a datasource for OData services already in SAP NetWeaver 740 if they are using service implementation using CDS views as mapped datasources.

So you can start building CDS views for your OData services in 740. To add support for annotaions in 740 backends you can used code based implementation.

I found however that there is not much information available around this topic ... so I decided to write this blog.

The use case as mentioned above for this scenario are customers and partners that want to build  OData services based on SAP NetWeaver 740 where no support for annotations in CDS views is available.

When upgrading to SAP NetWeaver 750 or higher you can move your implementation into CDS as well.

The following screen shot shows the first screen of the resulting SAP Fiori application which is based on the List Report Page and Object Page from Fiori elements (aka Smart Templates).

This app uses the OData service that I have described in my blog

https://blogs.sap.com/2016/05/31/odata-service-development-with-sap-gateway-code-based-service-devel...

 

 

From the entity set SalesOrderSet we show the columns Salesorder, Customer and Gross amount together with the Currency by default. The header of this list is named SalesOrders.



 

When clicking on on list entry we are using the navigation property ToItems and the details of the selected sales order is displayed on the object page.



Here some information from the sales order header such as Salesorder number, Customer number, lifecycle status and the last change date is shown in the header of the object page (red).

The gross amount is highlighted as a data point (green) whereas the title of the object page is titled as SalesOrder (blue).

 

Coding explained


In order to create these annoations we are going to implement the DEFINE method of the model provider extenstion class (MPC_EXT) of our OData service implementation. In the Service Builder we expand the folder Runtime Artifacts, select the class with the extension MPC_EXT class and select Go to ABAP Workbench from the context menue.



 

This opens the ABAP Development Tools in Eclipse



where we can start to redefine the DEFINE method.

After calling the DEFINE method of the superclass the code starts with some definitions.

 
 
DATA: lo_ann_target TYPE REF TO /iwbep/if_mgw_vocan_ann_target. " Vocabulary Annotation Target
DATA: lo_ann_target2 TYPE REF TO /iwbep/if_mgw_vocan_ann_target. " Vocabulary Annotation Target
DATA: lo_annotation TYPE REF TO /iwbep/if_mgw_vocan_annotation. " Vocabulary Annotation
DATA: lo_collection TYPE REF TO /iwbep/if_mgw_vocan_collection. " Vocabulary Annotation Collection
DATA: lo_function TYPE REF TO /iwbep/if_mgw_vocan_function. " Vocabulary Annotation Function
DATA: lo_fun_param TYPE REF TO /iwbep/if_mgw_vocan_fun_param. " Vocabulary Annotation Function Parameter
DATA: lo_property TYPE REF TO /iwbep/if_mgw_vocan_property. " Vocabulary Annotation Property
DATA: lo_record TYPE REF TO /iwbep/if_mgw_vocan_record. " Vocabulary Annotation Record
DATA: lo_simp_value TYPE REF TO /iwbep/if_mgw_vocan_simple_val. " Vocabulary Annotation Simple Value
DATA: lo_url TYPE REF TO /iwbep/if_mgw_vocan_url. " Vocabulary Annotation URL
DATA: lo_label_elem TYPE REF TO /iwbep/if_mgw_vocan_label_elem. " Vocabulary Annotation Labeled Element
DATA: lo_reference TYPE REF TO /iwbep/if_mgw_vocan_reference. " Vocabulary Annotation Reference

 

Next we add references. Please note the alias 'UI' which is later reused in the code.

 
 
lo_reference = vocab_anno_model->create_vocabulary_reference( iv_vocab_id = '/IWBEP/VOC_UI' iv_vocab_version = '0001').
lo_reference->create_include( iv_namespace = 'com.sap.vocabularies.UI.v1' iv_alias = 'UI' ).

 

We first specify the target entity type for our annations which is in this case the entity type "Salesorder". Important here is to set the correct namespace of our OData service.

Next we add the header information which is shown on the first page ('SalesOrders') to describe the entries of the list
and the details on the object page ('SalesOrder').

Then we are creating a collection of entries that specify the columns of the entity set that are shown in the list by default. These are the UI.LineItem annotations.
    "annotations for entity type Sales Order
lo_ann_target = vocab_anno_model->create_annotations_target( 'SalesOrder' ).
lo_ann_target->set_namespace_qualifier( 'ZE2E100_XX_3_SRV' ). "change the namespace to the SRV namespace

" Header Info
lo_annotation = lo_ann_target->create_annotation( iv_term = 'UI.HeaderInfo' ).
lo_record = lo_annotation->create_record( ).
lo_record->create_property( 'TypeName' )->create_simple_value( )->set_string('SalesOrder').
lo_record->create_property( 'TypeNamePlural' )->create_simple_value( )->set_string( 'SalesOrders').

" Columns to be displayed by default
lo_annotation = lo_ann_target->create_annotation( iv_term = 'UI.LineItem' ).
lo_collection = lo_annotation->create_collection( ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Salesorder' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Salesorder' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Customer' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Customer' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Gross amount' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Grossamountintransaccurrency' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Currency' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Transactioncurrency' ).

 

The columns that are displayed in the header of the object page are annotated using the 'UI.Identification' annotation.

 
    " Columns to be displayed in the object page
lo_annotation = lo_ann_target->create_annotation(
EXPORTING
iv_term = 'UI.Identification' ).
lo_collection = lo_annotation->create_collection( ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Salesorder' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Salesorder' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Customer' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Customer' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Lifecycle status' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Salesorderlifecyclestatus' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Last changed at' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Lastchangeddatetime' ).

 

The gross amount that shall be shown as a data point is annotated next.

 
    " Gross amount to be displayed as a data point
lo_annotation = lo_ann_target->create_annotation(
EXPORTING
iv_term = 'UI.DataPoint'
iv_qualifier = 'Grossamountintransaccurrency' ).
lo_record = lo_annotation->create_record( iv_record_type = 'UI.DataField' ).
lo_record->create_property( 'Value' )->create_simple_value( )->set_path('Grossamountintransaccurrency').
lo_record->create_property( 'Title' )->create_simple_value( )->set_string( 'Gross amount' ).

 

Then we specify the facets for the header and the details of the object page using the annoation path '@UI.Identification' .

To let the gross amount show up in the header as a data point we have to set the annotation pathe '@UI.DataPoint#Grossamountintransaccurrency'.

 
    "Header Facets
lo_collection = lo_ann_target->create_annotation( iv_term = 'UI.HeaderFacets' )->create_collection( ).

"Facet for Sales Order Header Details on object page
lo_record = lo_collection->create_record( iv_record_type = 'UI.ReferenceFacet' ).
lo_record->create_property( 'ID' )->create_simple_value( )->set_string( 'GeneralInformation' ).
lo_record->create_property( 'Label' )->create_simple_value( )->set_string( 'General Information' ).
lo_record->create_property( 'Target')->create_simple_value( )->set_annotation_path( '@UI.Identification' ).

"Facet for Gross amount
lo_record = lo_collection->create_record( iv_record_type = 'UI.ReferenceFacet' ).
lo_record->create_property( 'ID' )->create_simple_value( )->set_string( 'GrossAmount' ).
lo_record->create_property( 'Label' )->create_simple_value( )->set_string( 'Gross amount' ).
lo_record->create_property( 'Target')->create_simple_value( )->set_annotation_path( '@UI.DataPoint#Grossamountintransaccurrency' ).

"Facet for Sales Order Header Details on object page
lo_collection = lo_ann_target->create_annotation( iv_term = 'UI.Facets' )->create_collection( ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.ReferenceFacet' ).
lo_record->create_property( 'ID' )->create_simple_value( )->set_string( 'ItemList' ).
lo_record->create_property( 'Label' )->create_simple_value( )->set_string( 'Item List' ).
lo_record->create_property( 'Target')->create_simple_value( )->set_annotation_path( 'ToItems/@UI.LineItem' ).

 

We can finally add the annoations that specify the columns of the sales order item list which is shown on the object page.
These are again 'UI.LineItem' annotations. But this time the target of our annotations is a new object that points to the 'SalesOrderItem' entity type.

 
    "add annotations for sales order line items
lo_ann_target2 = vocab_anno_model->create_annotations_target( 'SalesOrderItem' ).
lo_ann_target2->set_namespace_qualifier( 'ZE2E100_XX_3_SRV' ). "change the namespace to the SRV namespace

" Columns to be displayed by default
lo_annotation = lo_ann_target2->create_annotation( iv_term = 'UI.LineItem' ).
lo_collection = lo_annotation->create_collection( ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Salesorder' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Salesorder' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Item' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Salesorderitem' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Gross amount' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Grossamountintransaccurrency' ).

lo_record = lo_collection->create_record( iv_record_type = 'UI.DataField' ).
lo_property = lo_record->create_property( 'Label' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_string( 'Currency' ).
lo_property = lo_record->create_property( 'Value' ).
lo_simp_value = lo_property->create_simple_value( ).
lo_simp_value->set_path( 'Transactioncurrency' ).

 

The  resulting  annotations can be found in the $metadata files:

 
 <Annotations Target="ZE2E100_XX_3_SRV.SalesOrder" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="UI.HeaderInfo">
<Record>
<PropertyValue Property="TypeName" String="SalesOrder" />
<PropertyValue Property="TypeNamePlural" String="SalesOrders" />
</Record>
</Annotation>
<Annotation Term="UI.LineItem">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Salesorder" />
<PropertyValue Property="Value" Path="Salesorder" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Customer" />
<PropertyValue Property="Value" Path="Customer" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Gross amount" />
<PropertyValue Property="Value" Path="Grossamountintransaccurrency" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Currency" />
<PropertyValue Property="Value" Path="Transactioncurrency" />
</Record>
</Collection>
</Annotation>
<Annotation Term="UI.Identification">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Salesorder" />
<PropertyValue Property="Value" Path="Salesorder" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Customer" />
<PropertyValue Property="Value" Path="Customer" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Lifecycle status" />
<PropertyValue Property="Value" Path="Salesorderlifecyclestatus" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Last changed at" />
<PropertyValue Property="Value" Path="Lastchangeddatetime" />
</Record>
</Collection>
</Annotation>
<Annotation Term="UI.DataPoint" Qualifier="Grossamountintransaccurrency">
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="Grossamountintransaccurrency" />
<PropertyValue Property="Title" String="Gross amount" />
</Record>
</Annotation>
<Annotation Term="UI.HeaderFacets">
<Collection>
<Record Type="UI.ReferenceFacet">
<PropertyValue Property="ID" String="GeneralInformation" />
<PropertyValue Property="Label" String="General Information" />
<PropertyValue Property="Target" AnnotationPath="@UI.Identification" />
</Record>
<Record Type="UI.ReferenceFacet">
<PropertyValue Property="ID" String="GrossAmount" />
<PropertyValue Property="Label" String="Gross amount" />
<PropertyValue Property="Target" AnnotationPath="@UI.DataPoint#Grossamountintransaccurrency" />
</Record>
</Collection>
</Annotation>
<Annotation Term="UI.Facets">
<Collection>
<Record Type="UI.ReferenceFacet">
<PropertyValue Property="ID" String="ItemList" />
<PropertyValue Property="Label" String="Item List" />
<PropertyValue Property="Target" AnnotationPath="ToItems/@UI.LineItem" />
</Record>
</Collection>
</Annotation>
</Annotations>
<Annotations Target="ZE2E100_XX_3_SRV.SalesOrderItem" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="UI.LineItem">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Salesorder" />
<PropertyValue Property="Value" Path="Salesorder" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Item" />
<PropertyValue Property="Value" Path="Salesorderitem" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Gross amount" />
<PropertyValue Property="Value" Path="Grossamountintransaccurrency" />
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Label" String="Currency" />
<PropertyValue Property="Value" Path="Transactioncurrency" />
</Record>
</Collection>
</Annotation>
</Annotations>
28 Comments
0 Kudos
Thanks Andre, great blog !

Regards,
SureshB
Associate
Associate
0 Kudos
Hi Andre,

Excellent Blog, This is the information I was looking for.

Kind Regards

Suresh
SyambabuAllu
Contributor
0 Kudos
Hi Andre,

Good Blog with well wersed code explanation.

 

Thanks,

Syam
Former Member
0 Kudos
Hi Andre,

Nice to see this info at one place.

 

Regards,

Vijay
Former Member
0 Kudos
Hello,

We want to extend Fiori Application HR Travel Request Approval. We found out that it's implemented with UI Annotations and annotations are defined as code based in  DEFINE method of CL_TRV_ATR_MPC_EXT class which is model provider class for TRV_ATR service. So we created our own service since we need additional entities and redefined the service. In the DEFINE method of our model prodiver class we call super->define() which generates the annotations defined in standard service.Then we call create our annotations for the entities we create like you have written in this blog.  When we called the metadata we got error:
"A row already exists with this keyThe error occurred on the application server ."

When I get deeper in ST22 I see this error message:

"An attempt was made to insert an entry into table
"\CLASS=/IWFND/CL_MED_MDL_PROVIDER\METHOD=CREATE_CLUSTERED_MODEL\DATA=LS_VOCA
_MODEL-ANNOTATION_TARGETS". Updating
unique table key "PRIMARY_KEY" resulted in a duplicate entry however. The key
in
question could be either the primary key or a secondary key."

I think it's not the correct way to redefine DEFINE method to extend annotations programatically. What is the best practice to extend the annotations of standard service?

Kind Regards,
Ümit Coşkun Aydınoğlu
former_member338076
Discoverer
0 Kudos
Hi All,

 

I am working on Smart template which is based on Annotation. in my entitySet i have some key field which is useful for navigation , but i have to want to show in my Smart template anywhere..

 

Could you please help me where i can put some hidden:true kind of property... and i am not using CDS ...

 

Regards

Virendra
0 Kudos
Hi, did you by any chance found a solution for this?
Former Member
0 Kudos
Hi,

 

Thanks for the information provided. Further I need to define some annotations which are not specified in this blog. Example I need to mark some fields mandatory in the smart filer in the smart table and and define one input field like a range. How can i find methods / functions / documentation related to this.

 

Thanks,

Chinthaka
gleiss
Employee
Employee
0 Kudos
Hi Andreas,

this is a great blog! I have one question: Is it also possible to change existing annotations in the vocab_anno_model, e.g. annotations coming from CDS-views?

It seems to me that the vocab_anno_model provides only "create"-methods.

 

Thanks and best regards,

Eric
praveen_gupta2
Explorer
0 Kudos
Hi andre.fischer,

Very nice blog on Annotations.

I am facing 1 problem in my OData where i have implemented vocabulary based annotation.

I would like to achieve below requirements.

  1. Label property of entity type in selection criteria.

  2. Selection field mandatory.

  3. Sorting enabled for some field in result set.


I have done changes in SEGW in annotations "com.sap.vocabularies.Common.v1" and "com.sap.vocabularies.UI.v1".

When i load metadata of the service, i can see all the annotation for the property. But when i execute my fiori application it is not reflected.

Could you please suggest ? what is missing here ? Or needed to set any property/parameter for the changes to reflect in UI

 

Regards,

Praveen Gupta
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
What do you mean by "I have done changes in SEGW in annotations “com.sap.vocabularies.Common.v1” and “com.sap.vocabularies.UI.v1” ?

Have you tried to create an annotation project and are you using SEGW as an editor for annotations?

I would not recommend this and can only recommend to create annotations as described above using code based implementation or by using the annotation modeler in Web IDE.

 
che_eky
Active Contributor
Hi Andre,

Nice blog! I have a question for you. I have a CDS which I have imported as a Reference into an OData service. I would like to make the OrderValue field an aggregated field based on Year and WeekNo. I did this originally using annotations in the CDS and it worked but I found I could not use many other features like virtual elements because the CDS was classed as analytical due to the aggregation annotation. Therefore I have removed the aggregation annotation from the CDS and it no longer shows as analytical in the service. Can you show me how to add annotations in the DPC/MPC class to make the OrderValue field an aggregated field based on Year and WeekNo?

I have read many blogs and posts but there is no complete answer. I am hoping that I can add code to the DPC/MPC class to set semantic: aggregate and then add anotations for the fields OrderValue as Measure, Year and WeekNo as Dimensions. Can you show me how to do this with code?
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
lo_entity_type = model->get_entity_type( gc_salesorderfulfillmentissueq ). 
lo_entity_type->set_semantic( /iwbep/if_ana_odata_types=>gcs_ana_odata_semantic_value-query-aggregate ).

lo_property = lo_entity_type->get_property( ls_property-external_name ).
lo_annotation = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lo_annotation->add( iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).

I found the above mentioned code snippets in old mail thread.

But I have never tried them out myself.

Best Regards,

Andre

 
che_eky
Active Contributor
Thanks Andre that looks promising. I will give it a go.
che_eky
Active Contributor
It worked great, see below all properties have been annotated as dimension apart from Value and Amount which are measures:


Here is the code if it helps anyone:
    "Set the entity type we wish to annotate
lo_entity_type = model->get_entity_type( 'YOUR_ENTITYType' ).

"Annotate as aggregate
lo_entity_type->set_semantic( /iwbep/if_ana_odata_types=>gcs_ana_odata_semantic_value-query-aggregate ).

"Fetch all the properties of the entity type
DATA(lo_properties) = lo_entity_type->get_properties( ).

"Loop over all properties and annotate as required
LOOP AT lo_properties INTO DATA(ls_properties).
CASE ls_properties-name.
WHEN 'YOURPROPERTY1'
OR 'YOURPROPERTY2'.
"Annotate as measure
DATA(lo_property) = lo_entity_type->get_property( ls_properties-external_name ).
DATA(lo_annotation) = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lo_annotation->add( iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-measure-measure ).

WHEN OTHERS.
"Annotate as dimension
lo_property = lo_entity_type->get_property( ls_properties-external_name ).
lo_annotation = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation( /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
lo_annotation->add( iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).
ENDCASE.
ENDLOOP.

 

Annotated Entity Type

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
Great to hear that it worked out for you.

Any many thanks for posting your code here !

That's real community spirit.
former_member333755
Discoverer
0 Kudos

Hello andre.fischer,

I have created an analytic list page based on annotation from the backend SEGW. Everything works fine till I navigate to the object page. When I come back from the object page to the first page some of the datafields are blanked and also the entry is removed from the chart.

 

This stops happening if the entityset linked to the chart and table is not set to sap:samantics “aggregate”. But then this creates issues with the visual filter not working when I change the value of the filter and try to display the table

former_member669165
Discoverer
Hello, andre.fischer ! Please, help me with the next problem: My metadata.xml file contains the correct set of annotations, however they are not reflected in the client side. The client side itself is not built with WebIde tools.

Please, tell me what settings you need to specify in the client side to parse the metadata file and display the structure specified by annotations.

Thanks.
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
I don't understand your problem.

If you are not using SAP Tooling I don't see how I can help you here. The annotations are available as plain text and you would have to write you own parser.

 
0 Kudos
Hi Che Eky,

I am working on similar scenario, I have added the above code(dimensions or measure) for all fields in the entityset except for Generated_ID, i have done mapping at entityset level and i have implemented IF_SADL_GW_QUERY_CONTROL~SET_QUERY_OPTIONS.

I am not able to populate/generate GENERATED_ID in entitySet method. Let me know if i have missed any steps to generate/populate GENERATED_ID field.

Thanks,
Anil.




che_eky
Active Contributor
0 Kudos
Hi Anil,

How is your service defined? Did you create an Entity Type and then create a Service Implementation and Mapping? Also the Entity Type must only have one property ticked as the key and the ABAP Field Name must be GENERATED_ID.

 
che_eky
Active Contributor
0 Kudos
Also make sure that the code is not annotating the GENERATED_ID as a dimension.

0 Kudos
Thanks for the response Che EKy.

Yes i created EnityType using structure, implemented MPC_EXT define method, EnitytSet, followed by Mapping and IF_SADL_GW_QUERY_CONTROL~SET_QUERY_OPTIONS method.

And yes ID is just key and not having any annotations in metadata.

And when the Analytical table is loaded call is going to EnitySet and SET_QUERY_OPTIONS method.

But id is not getting generated.
former_member709241
Discoverer
0 Kudos
so I followed the blog but in webide when I create an app with the template, there is a step where you specify the annotation it doesn't show up by default, so i added it from the service url manually using the metadata url and on the next step the entity or the object collection doesn't show up on the binding. Is it because it only works for the lower version of NW. Mine is already higher than 750.  Thanks!
Karan_Chopra_
Active Participant
0 Kudos
Hello andre.fischer ,

Very informative blog for building Fiori app when system is 7.4.

Is there also a possibility to use Filters and search helps based on ODATA based annotations as we use with CDS UI and Objectmodel annotations?  Like -
@ObjectModel.foreignKey.association

@Consumption.valueHelpDefinition: 

 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
No, this is not possible in 740.

 
juergenhess1
Discoverer
0 Kudos
Hi Andre Fischer,

 

could you please provide coding example for smartfilterbar selection fields in method "Define" of

class *mpc_ext.

 

Thanks and regards

Jürgen
Sathees_P
Participant
0 Kudos

Hello andre.fischer,

Using this concept, we able to build app with List Report + Object Page. Create, Update, Delete  operations are visible by doing entityset operation CUD checked. Delete operation is working, but Create / Update(Edit) not showing fields which are displayed in object page. Entitytype -> we enabled fields with Create and Update flags

Initial Display

Object Page Display

If [Edit] button is clicked 

Edit button is clicked, no fields are shown