on 08-01-2020 7:52 AM
Hello Experts,
I am fairly new to the world of SAP UI5, I am trying to pass Date parameters from UI5 to Odata URL but it is giving me bad request . I want to create below URL for Odata service
/ZGW_OMNI_TRACK_SRV/etResultSet?$filter=SoDate ge datetime'2020-07-16T00:00:00' and SoDate le datetime'2020-07-23T00:00:00' .
Above URL is working fine in gateway client
To achieve this I have written below code
var date = this.byId("idFromDate").getValue();
var date2 = this.byId("idToDate").getValue();
var oDateFormat = sap.ui.core.format.DateFormat.getInstance({
pattern: "yyyy-MM-ddTHH:mm:ss"
});
var oDate = oDateFormat.format(oDateFormat.parse(date));
var oDate2 = oDateFormat.format(oDateFormat.parse(date2));
// var fromDate = this.getView().byId('idFromDate').getValue();
// var toDate = this.getView().byId('idToDate').getValue();
var date = new Filter({
path: "SoDate",
operator: FilterOperator.BT,
value1: oDate,
value2: oDate2
});
//Build Odata Service
var sServiceUrl = "/sap/opu/odata/sap/ZGW_OMNI_TRACK_SRV";
//var url = sServiceUrl.concat(date);
var oModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl, false);
var sUrl = "/etResultSet?$filter=SoDate ge datetime'" + oDate + "' and SoDate le datetime'" + oDate2 + "' ";
oModel.read(sUrl, {
//filters: [date],
success: function (success, oResponse) {
// debugger;
alert("READ SUCCCESSFULLY");
},
error: function (err, oResponse) {
// debugger;
alert(err.statusText);
}
});
I even tried passing filter in read method, but still I am not able to achieve this, please let me know what I am missing .
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.