点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
专家们,
我无法通过标准C4C odata服务来更新SAP C4C系统中的数据。我正在尝试使用PATCH方法来更新c4codata服务的IndividualCustomerCollection节点中的记录。使用V2 OdataModel。
在网络中执行此服务时,该服务显示了帖子,但后端没有更新数据。我也尝试了PUT/POST方法,但没有成功。
它给出错误"由于语法格式错误,无法理解数据服务请求"。 在控制台响应中。
我已经引用了C4C odata api,但是我的代码找不到问题
任何建议将不胜感激。
下面是我的代码
var modelData = this.getOwnerComponent()。getModel(" c4codata"); modelData.setUseBatch(true); //var path ="/img/IndividualCustomerCollection"; var path ="/img/IndividualCustomerCollection" +"('" + objid +"')"; var changedata = []; changedata = { "名字":thatMaster.getView()。byId(" idfname")。getValue(), "姓氏":thatMaster.getView()。byId(" idlname")。getValue(), " GenderCode":thatMaster.getView()。byId(" idgender")。getSelectedItem()。getKey(), " MaritalStatusCode":thatMaster.getView()。byId(" maritalstatus")。getSelectedItem()。getKey(), "移动":thatMaster.getView()。byId(" idmob1")。getValue(), "电子邮件":thatMaster.getView()。byId(" idpermmail")。getValue(), " NoofHomesOwner":thatMaster.getView()。byId(" idhomeowned")。getValue(), " PriorInvestment":thatMaster.getView()。byId(" idinvestment")。getSelectedItem()。getKey(), " HouseID":thatMaster.getView()。byId(" idperm1")。getValue(), " StreetName":thatMaster.getView()。byId(" idperm2")。getValue(), " StreetPostalCode":thatMaster.getView()。byId(" idperm3")。getValue(), " CityName":thatMaster.getView()。byId(" idperm4")。getValue(), "电话":thatMaster.getView()。byId(" idtele")。getValue(), " AlternateMobileNumber":thatMaster.getView()。byId(" idmob2")。getValue(), " HighestEducationSelf":thatMaster.getView()。byId(" ideduself")。getSelectedItem()。getKey(), " HighestEducationSpouse":thatMaster.getView()。byId(" ideduspouse")。getSelectedItem()。getKey(), " SpouseName":thatMaster.getView()。byId(" idspname")。getValue(), " ChildName1":thatMaster.getView()。byId(" idchild1")。getValue(), " ChildName2":thatMaster.getView()。byId(" idchild2")。getValue(), " ChildName3":thatMaster.getView()。byId(" idchild3")。getValue(), " WeddingAnniversary":thatMaster.getView()。byId(" idAni")。getValue(), " DOBSpouse":thatMaster.getView()。byId(" idDP2")。getValue(), " DateOfBirth":thatMaster.getView()。byId(" idDP1")。getValue(), " DOBChild1":thatMaster.getView()。byId(" idDP3")。getValue(), " DOBChild2":thatMaster.getView()。byId(" idDP4")。getValue(), " DOBChild3":thatMaster.getView()。byId(" idDP5")。getValue(), " ProfessionCode":thatMaster.getView()。byId(" idProfself")。getSelectedItem()。getKey(), " CompanyName":thatMaster.getView()。byId(" idcompself")。getValue(), " EmploymentType":thatMaster.getView()。byId(" idtype")。getSelectedItem()。getKey(), " ResidentialStatus":thatMaster.getView()。byId(" idresstatus")。getSelectedItem()。getKey(), "购买目的":thatMaster.getView()。byId(" idPurchasRsn")。getSelectedItem()。getKey(), " SpouseEmailID":{ " schemeID":"", "内容":thatMaster.getView()。byId(" idemailspou")。getValue() }, " TotalAnnualIncomefromallsources":thatMaster.getView()。byId(" idtotalinc")。getValue(), " FavoriteHolidayDestinationDomestic":thatMaster.getView()。byId(" idhilidom")。getValue(), " FavoriteHolidayDestinationInternational":thatMaster.getView()。byId(" idholiint")。getValue(), " PreferredCuisine":thatMaster.getView()。byId(" idCuisine")。getSelectedItem()。getKey(), " CarDriven":thatMaster.getView()。byId(" idcardrivern")。getValue(), " InterestHobbies":thatMaster.getView()。byId(" idhobbiesint")。getSelectedItem()。getKey(), " Internet冲浪":thatMaster.getView()。byId(" idinternet")。getSelectedItem()。getKey(), " SpendTimewithFamily":thatMaster.getView()。byId(" idfamilytime")。getSelectedItem()。getKey(), " SportsActivitiesInterested":thatMaster.getView()。byId(" idsportact")。getSelectedItem()。getKey(), " KidsHobbiesInterests":thatMaster.getView()。byId(" kidshob")。getSelectedItem()。getKey() }; modelData.update(path,changedata,{ 方法:" PATCH", 成功:function(OData,oResponse){ var msgS ="您的个人资料已更新"; sap.m.MessageBox 。表演( msgS,{ 标题:"成功", 图标:sap.m.MessageBox.Icon.SUCCESS, onClose:function(){ this._toggleButtonsAndView(false); thatMaster.formBind(); } }); }, 错误:function(err){ var b = $ .parseJSON(err.response.body); var msg1 = b.error.message.value; sap.m.MessageBox 。表演( msg1, sap.m.MessageBox.Icon.ERROR," Error"); 返回; } });
(170.0 kB)
嗨! 您解决了这个问题吗? 公司帐户的POST方法遇到相同的错误。
最好的问候。
您是否在某些工具中尝试过相同的事情? 像邮递员还是soapui?
假设您使用的是V2 OData模型,则" method"不是更新方法的参数。 参考:
https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/update
在创建模型时,您可能需要更改" defaultUpdateMethod"属性。 请参阅以下选项:
https://sapui5 .hana.ondemand.com/#/api/sap.ui.model.odata.UpdateMethod
一周热门 更多>