cancel
Showing results for 
Search instead for 
Did you mean: 

sap:display-format="Date" on xsodata

andrefernandes
Participant
0 Kudos

We are using XS Classic to expose a XSoData service with a few calculation views, which consume data from HANA database tables.

From the SAP HANA Web-based Development Workbench, I can set a few semantic parameters, such as sap:aggregation-role, sap:label, sap:unit and sap:semantics. However, in order to display date input fields as DatePicker, I need the sap:display-format. Is there a way to set it using the Workbench or Eclipse?

gregorw
Active Contributor

thomas.jung might know.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

What do you mean by setting the semantic parameters? Are you using the Odata4SAP annotation in the XSODATA definition? That's the main way you activate all the additional sap:* supported values in the XSODATA metadata.

annotations { enable OData4SAP;}
andrefernandes
Participant
0 Kudos

Hi thomas.jung, thank you for the reply. I am indeed using annotations{ enable OData4SAP; } (otherwise the other sap values would not even show up).

My problem is that I can't find any place on the Workbench to implement sap:display-format="Date". I can implement the others I mentioned, but there isn't any option for the display format.

esjewett
Active Contributor
0 Kudos

I had the same question a while ago. I believe, per the documentation here (https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.03/en-US/ff3aa12ba90247c8b7c326199d53978a.html) your only option is to make the adjustment to the field type in the calculation view.

andrefernandes
Participant
0 Kudos

Hi db48526ccb71414183a64aa46e31e784, thank you for your input. By opening he calculation view with the Text Editor (instead of Calculation View Editor) I could see how some pieces of the document you showed are reflected on the code. For instance the <descriptions defaultDescription="Property Label"/> for the labels. However the part that mentions sap:display-format is not very helpful, as it doesn't show the equivalent code that should be inserted on the Calculation View code.

If possible, could you please share what changes you made to the code to add the property to an attribute?

Best regards,
André

esjewett
Active Contributor

You just need a field with Data Type of DATE. I'd usually use the visual editor and created a calculated field that converts your existing field value into a DATE field.

BR,

Ethan

andrefernandes
Participant
0 Kudos

db48526ccb71414183a64aa46e31e784 , it worked! Thank you a lot for the input!

andrefernandes
Participant

Hi db48526ccb71414183a64aa46e31e784, apparently I was too eager to celebrate. Even though the calculated view with DATE type made the sap:display-format="Date" show up, this didn't solve my ultimate goal of making the filter input a DatePicker instead of MultiInput. I was debugging the code in FilterProviderdbg.js (https://sapui5.hana.ondemand.com/1.54.6/resources/sap/ui/comp/smartfilterbar/FilterProvider-dbg.js ), which apparently determines the filter input control for each property in the metadata. It seems the key semantics is the sap:filter-restriction, which according to the document you linked can only be added to input parameters, not calculated attributes.

Would you know by any chance how to add that semantic to either an attribute or calculated attribute?

Best regards,
André

esjewett
Active Contributor

Hi André,

In my experience, this setting does enable the date picker, however because it is a multi-combo selector, you first have to launch the help dialog and then within that dialog the date picker is enabled. This is because the field supports both multiple selection and greater than/less than/range selection by default.

If you want a date picker that just selects a single date, then yes, you need to use the OData v2 sap:filter-restriction="single-value" annotation. However as you point out, there is no way to do this in xsodata for a regular column. But the Smart Filter bar documentation also says you can use an OData v4 FilterExpressionType annotation, so I suggest you enable an annotation file for your service if you have not already and try this annotation. Documentation is here: https://sapui5.hana.ondemand.com/#/api/sap.ui.comp.smartfilterbar.SmartFilterBar/annotations/FilterE...

When possible, we are using OData v4 annotation with our xsodata services because of the issues with specifying OData v2 annotations on those services. I do admit, however, that I have not tried this exact one.

Thanks,

Ethan

andrefernandes
Participant
0 Kudos

Hi db48526ccb71414183a64aa46e31e784, my bad. I could indeed see the date picker inside the multi-combo selector. It's working like a charm!

I checked the SmartFilterBar annotations on the API Reference and apparently we are supposed to use the annotation com.sap.vocabularies.Common.v1.FilterExpressionRestriction to define single/multi value fields. However, upon checking opening the annotation on https://wiki.scn.sap.com/wiki/display/EmTech/OData+4.0+Vocabularies+-+SAP+Common#FilterExpressionRes..., we can see that the annotation is already Deprecated, being replaced by Capabilities.FilterRestrictions. Unfortunately, that annotation doesn't mention anything about single/multi values https://www.odata.org/blog/introducing-a-capabilities-vocabulary/.

When you said to use OData v4 annotation, you mean adding an annotation to a project in WebIDE and work on it from either Code Editor or Annotation Modeler, correct?


Anyway, this is already outside the scope of my original question. Thank you again for all the help!

Best regards,

André

Answers (0)