简体   繁体   English

使用Edm.Time类型的oData模型的PUT方法

[英]PUT method to oData model with Edm.Time type

i'm trying to implement editable table element with time element (type Edm.Time). 我试图用时间元素(类型Edm.Time)实现可编辑表格元素。 the problem comes when changing value in table and application sends PUT request. 当更改表中的值并且应用程序发送PUT请求时,就会出现问题。

the value of time object is for example "PT11H00M00S" and i've assigned type "Edm.Time" via metadata to avoid "Edm.string" comparision problem. 时间对象的值例如是“ PT11H00M00S”,并且我已通过元数据分配了类型“ Edm.Time”,以避免“ Edm.string”比较问题。 but now oData service is SAP shows as per below. 但是现在oData服务是SAP如下所示。 how the value should be formatted to avoid this problem? 该值应如何设置格式以避免出现此问题? thanks in advance 提前致谢

2015-09-22 09:52:09 The following problem occurred: HTTP request failed400,Bad Request, CX_SY_CONVERSION_NO_DATE_TIME/67AA6842BAA80B7DE10000000A15523C Value PNaNDTNaNHNaNMNaN.NaNS does not represent a valid date/time56003C39FEB4710DE10000000A10010C20150922075209.8761770Run transaction /IWFND/ERROR_LOG on SAP NW Gateway hub system and search for entries with the timestamp above for more detailsSee SAP Note 1797736 for error analysis ( https://service.sap.com/sap/support/notes/1797736 )See SAP Note 1869434 for details about working with $batch ( https://service.sap.com/sap/support/notes/1869434 ) - 2015-09-22 09:52:09发生以下问题:HTTP请求失败400,错误请求, CX_SY_CONVERSION_NO_DATE_TIME/67AA6842BAA80B7DE10000000A15523C值PNaNDTNaNHNaNMNaN.NaNS不代表有效的日期/时间并在上面的时间戳中搜索条目以获取更多详细信息,请参阅SAP Note 1797736进行错误分析( https://service.sap.com/sap/support/notes/1797736 )有关使用$ batch的详细信息请参阅SAP Note 1869434( https: //service.sap.com/sap/support/notes/1869434)-

on SAP side i found following request had received 在SAP方面,我发现已收到以下请求

--batch_6bba-3b1b-e53d
content-type: multipart/mixed; boundary=changeset_3e78-e6a1-305d

--changeset_3e78-e6a1-305d
content-type: application/http
content-transfer-encoding: binary

PUT modelData(pdsnr='000000000130') HTTP/1.1
Accept-Language: EN
Accept: application/atom+xml,application/atomsvc+xml,application/xml
MaxDataServiceVersion: 2.0
DataServiceVersion: 2.0
Content-Type: application/atom+xml
Content-Length: 716

<a:entry xmlns:a="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"><a:author><a:name/></a:author><a:category term="ns.type" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/><a:content type="application/xml"><m:properties><d:pdsnr m:type="Edm.String">000000000130</d:pdsnr><d:fullName m:type="Edm.String"/><d:alias m:type="Edm.String">ABCD</d:alias><d:pernr>95000104</d:pernr><d:direction m:type="Edm.String">P10</d:direction><d:date m:type="Edm.DateTime">2015-09-21T00:00:00</d:date><d:time m:type="Edm.Time">PNaNDTNaNHNaNMNaN.NaNS</d:time></m:properties></a:content></a:entry>
--changeset_3e78-e6a1-305d--

--batch_6bba-3b1b-e53d--

look like it was problem in __metadata property of context providing to model calls. 看起来这是提供给模型调用的上下文的__metadata属性中的问题。

              var obj = oSelectedItem.getBindingContext().getObject();
              var context = oEvent.getSource().getBindingContext().getObject();

              context.ldate    = obj.ldate;
              context.ltime    = obj.ltime;

              oController.onRowUpdate("/modelData(pdsnr='"+context.pdsnr+"')", 
                                      context);

now it works as 现在它像

              var obj = oSelectedItem.getBindingContext().getObject();
              var context = oEvent.getSource().getBindingContext().getObject();

              context.ldate    = obj.ldate;
              context.ltime    = obj.ltime;

              oController.onRowUpdate("/modelData(pdsnr='"+context.pdsnr+"')", 
                                      {ldate:    obj.ldate,
                                       ltime:    obj.ltime,
                                      });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM