Skip to Content
avatar image
Former Member

date conversions in OData

Hello experts,

i am trying to create a entityset in OData which contains some date fields, but getting conversion errors, because edm.datetime is having length 7.

request your help.

thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 26, 2015 at 06:18 AM

    Perhaps use TIMESTAMPL as data element and do Date formatting at SAPUI5 App.

    TIMESTAMPL is actually UTC Time Stamp in Long Form (YYYYMMDDhhmmssmmmuuun).

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 26, 2015 at 06:31 AM

    OData Dates and Times

    try with this code

    jQuery.sap.require("sap.ui.model.odata.ODataUtils");

    var sPath = "/MyEntitiySet(Id='0815', ChDateTime=" + ODataUtils.formatValue(1436109229000, "Edm.DateTime") + ")";

    1. jQuery.sap.require("sap.ui.model.odata.ODataUtils"); 
    2. var sPath = "/MyEntitiySet(Id='0815', ChDateTime=" + encodeURIComponent(sap.ui.model.odata.ODataUtils.formatValue(1436109229000, "Edm.DateTime")) + ")"; 
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 26, 2015 at 09:37 AM

    Hi,

    We were facing similar issue.What we did was changed code in DEFINE method of model provider ext class like below.

    lo_property = lo_entity_type->create_property( iv_property_name = 'DATEFIELDNAME' iv_abap_fieldname = 'DATEFIELDNAME' ). "#EC NOTEXT

    *lo_property->set_label_from_text_element( iv_text_element_symbol = '100' iv_text_element_container = gc_incl_name ).       "#EC NOTEXT

    lo_property->SET_TYPE_EDM_DATETIME( ).

    lo_property->set_maxlength( iv_max_length = 8 ).

    lo_property->set_creatable( abap_false ).

    lo_property->set_updatable( abap_false ).

    lo_property->set_internal_type( 'P' ).

    lo_property->set_internal_length( 8 ).

    lo_property->set_sortable( abap_false ).

    lo_property->set_nullable( abap_false ).

    lo_property->set_filterable( abap_false ).


    Hope this helps

    Regards

    Add comment
    10|10000 characters needed characters exceeded