I am confused on the date format to be used while invoking OData read operation where parameters are mentioned within entityset brackets. Would be great if you can paste your answer against each
How to use ODataModel's
read()
method if we have values to be passed within the entity set parameters?var sPath ="/EMP_DETAILSSet(Empid='50160458'/*, ...*/)"; oBackEndModel.read(sPath, { success: this._fGetDetailsSuccess.bind(this), error: this._fBackEndInvocationError.bind(this) });
Is this the approach to be followed? Or do we have any other approach?
How to set date as entity set key parameter with OData? Please correct the below code snippet (which gives me bad request error at runtime) where
dBegDate
anddEndDate
are JS standard date objects.var sPath ="/EMP_DETAILSSet(Empid='50160458',Begdate="+ dBegDate.toJSON() + ",Enddate=" + dEndDate.toJSON() + ",HAFId=' ')"; oBackEndModel.read(sPath, { success: this._fGetDetailsSuccess.bind(this), error: this._fBackEndInvocationError.bind(this) });
How to execute multiple expand operation along with the entityset parameters mentioned above? Please fix the error in the below code as it is not working for me.
var sPath ="/EMP_DETAILSSet(Empid='50160458',Begdate="+ dBegDate.toJSON() + ",Enddate=" + dEndDate.toJSON() + ",HAFId=' ')"; oBackEndModel.read(sPath, { urlParameters: { $expand: "NAVTODETAIL,NAVTOPROFILE,NAVTOREPORTEES" }, success: this._fGetDetailsSuccess.bind(this), error: this._fBackEndInvocationError.bind(this) });
Further updates
I have followed the suggestion b Sunil. sPath
looked as follows at runtime:
"/EMP_DETAILSSet(Empid='50160458',Begdate=datetime'2014-03-11T14:49:52',Enddate=datetime'9999-12-31T14:49:52',HAFId=' ')"
When I tried this, it gave me the following error:
2018-06-13 10:56:31.872300 The following problem occurred: HTTP request failed404,Not Found,{"error":{"code":"005056A509B11EE1B9A8FEC11C21D78E","message":{"lang":"en","value":"Resource not found for the segment '49:52',Enddate=datetime'9999-12-31T14:49:52',HAFId=''."},"innererror":{"transactionid":"5B20F78A93457852E10000000ACD4014","timestamp":"20180613052610.2725590","Error_Resolution":{"SAP_Transaction":"Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis ..."}}}}
Do you know why?
Please note that the following URL works fine and returned the result when executed from SAP Gateway Client: /sap/opu/odata/XXX/YYYY_SRV/EMP_DETAILSSet(Empid='50160458',Begdate=datetime'2014-03-11T14:49:52',Enddate=datetime'9999-12-31T14:49:52',HAFId=' ')?$expandNAVTODETAIL,NAVTOPROFILE,NAVTOREPORTEES&$format=json