Рубрика: Odata

SetHours for Date in sap ui5, how do if date reduce -1 day, or you filter not working

Blog, Odata, What???


First situation when in the backend server you saw rhat date less on -1 day!
What happend? It odata sevices do crayzy date!
What you can do?

just try use that:
var conv = function(conv_date){
var dateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern : "yyyy-MM-ddTKK:mm:ss" });
var lv_date_val = new Date(conv_date);
var dateStr = dateFormat.format(lv_date_val);
return dateStr;

in you data request use
odata.validdate = conv(odata.validdate);

second situation, when you use filter,
and you neded use setHours on the date.
How you can understund how match hours set?

Try use that
var sHours = new Date().getHours() - new Date().getUTCHours();

var value = new Date();



//Create model

var url = ""; //your services url
var OdataInfo = new sap.ui.model.odata.v2.ODataModel(url, true);

//Create success and error function
var suc_func = function(obj){
var er_func = function(obj){

//Create filters
var filt;

function(Filter, FilterOperator) {
filt = new Filter({
path: "areaId",
operator: FilterOperator.EQ,
value1: '0000000116'

//Made Request
var rr = OdataInfo.read("/MY_INFO",
filters: [filt],
success: suc_func}



Sap Abap!!!


    data: lv_filter_options type /iwbep/t_mgw_select_option .

    lv_filter_options = io_tech_request_context->get_filter( )->get_filter_select_options( ).



if you want create Entity, this we have one secrets ) Thanks for SAP for use our brain to open code

var url = «********/ZSEM_SRV/»;

var OdataInfo = new sap.ui.model.odata.v2.ODataModel( {serviceUrl:url} );

//Create success and error function

var suc_func = function(obj) { debugger; };

var er_func = function(obj) { debugger; };

var oData = { IdSource: «23123», Source: «fdffasdffsadfasdfasdfsadfsdfsdfsfddfsdfsdf», Title: «rrr», Type:»sdf» };

var sPath = ‘/ZSEM_SOURCESet’;

OdataInfo.create(sPath, oData, {success: suc_func, error: er_func});

and now in your class you must use structure for get keys

    try .
        data ls_s type html_sourc.   //<<you must set this or you could have a dump!!!

           es_data    = ls_s
      catch cx_root into data(lo_cx).
        data(lv_t) = lo_cx->get_text( ).