cancel
Showing results for 
Search instead for 
Did you mean: 

How to set OData annotations: sap:display-format and sap:filter-restriction?

Former Member
0 Kudos

Hi everyone.

I am building a Gateway project in the Gateway Service Builder (SEGW). I would like to assign values to the following two specific property annotations in the data model of my project:

sap:display-format

sap:filter-restriction

My Gateway project type is "2 - Service with vocabulary-based annotations". I have also imported each of the available vocabularies from the repository.

Many annotations are available in my project, but I am unable to find sap:display-format and sap:filter-restriction.

Can anyone steer me in the right direction? In which vocabulary should the definition of these specific annotations reside?

Thank you!

Chad

Accepted Solutions (0)

Answers (2)

Answers (2)

didier_bueno
Explorer

Hello Chad:

I had same issue and I couldn't find how to solve it using the SEGW. I think it's not a complex tool and it doesn't have all the annotations. I have used the MPC_EXT class for adding the annotations that I couldn't add with SEGW. Here you have an example:

1. Go to DEFINE method on your service MPC_EXT class

2. Add something like this to your code:

method DEFINE.

     DATAlo_entity_type          TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
                lo_property             TYPE REF TO /iwbep/if_mgw_odata_property,
                lo_annotation   TYPE REF TO /iwbep/if_mgw_odata_annotation. "#EC NEEDED

     FIELD-SYMBOLS: <lo_property> LIKE LINE OF lt_properties.

     super->define( ). "Ensure you call the parent metadata
     lo_entity_type = model->get_entity_type( iv_entity_name = 'PosicionPedido'). "Entity name
     lo_property = lo_entity_type->get_property( iv_property_name = 'Audat'). "Property to be annotated
     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 = 'display-format' iv_value = 'Date' ). "Add new annotation.


endmethod.


Done, you will see the new sap:display-format="Date" on your service metadata.


I hope to be helpfull,


Didier 

0 Kudos

Hi Chad,

Have you found a solution to this? I have the same problem. Looking forward to your response. Thank you.

Regards,

Tejas.