我正在使用全栈 Web IDE 创建简单的表单,该表单将发布 561 初始库存货物移动。就绑定而言,我不确定我缺少什么。控制器似乎正在做它应该做的事情,但生成的 JSON 是不正确的。
正确的 JSON 如下所示:
{
"PostingDate": "2018-08-27T00:00:00",
"GoodsMovementCode": "05",
"to_MaterialDocumentItem": [{
"Material": "MZ-FG-E11",
"Plant": "1710",
"StorageLocation": "171A",
"GoodsMovementType": "561",
"Batch" : "0000000013",
"QuantityInEntryUnit": "12",
"ShelfLifeExpirationDate":"2018-08-27T00:00:00",
"ManufactureDate": "2018-05-27T00:00:00"
}]
}
我在 web ide 中的视图片段如下:
<f:SimpleForm class="editableForm" columnsL="1" columnsM="1" editable="true" emptySpanL="4" emptySpanM="4" id="newEntitySimpleForm" labelSpanL="3" labelSpanM="3" layout="ResponsiveGridLayout" maxContainerCols="2" minWidth="1024" title="{= ${viewModel>/mode} === 'edit'? 'Edit API_MATERIAL_DOCUMENT_SRV': 'New API_MATERIAL_DOCUMENT_SRV'}">
<f:content>
<Label text="Posting Date" required="false"/>
<DatePicker name="PostingDate" value="{ path: 'PostingDate', type: 'sap.ui.model.type.DateTime'}" id="PostingDate_id" enabled="true" visible="true"/>
<Label text="Goods Movement Code" required="false"/>
<Input name="GoodsMovementCode" id="GoodsMovementCode_id" valueLiveUpdate="true" liveChange="_validateSaveEnablement" enabled="true" visible="true" value="{ path: 'GoodsMovementCode', type: 'sap.ui.model.odata.type.String' , constraints:{ maxLength:2 } }"/>
<Label text="Material" required="true"/>
<Input name="Material" id="MaterialDocument_id" valueLiveUpdate="true" liveChange="_validateSaveEnablement" enabled="{= ${viewModel>/mode} === 'edit'? false: true}" visible="true" value="{ **path: 'to_MaterialDocumentItem>Material'** , type: 'sap.ui.model.odata.type.String' , constraints:{ maxLength:10, nullable:false } }" cd:w5g.dt.context="/A_MaterialDocumentItem"/>
<Label text="Plant" required="false"/>
<Input name="Plant" id="Plant_id" valueLiveUpdate="true" liveChange="_validateSaveEnablement" enabled="true" visible="true" value="{ path: 'Plant', type: 'sap.ui.model.odata.type.String' , constraints:{ maxLength:2 } }"/>
在测试此表单时,我从 chrome 开发人员工具收到以下信息,错误为 400 Bad Request:
PostingDate: "/Date(1536642000000)/", GoodsMovementCode: "1",…}
Batch:"7"
GoodsMovementCode:"1"
GoodsMovementType:"5"
Plant:"3"
PostingDate:"/Date(1536642000000)/"
QuantityInEntryUnit:"6"
StorageLocation:"4"
__metadata:
{type: "API_MATERIAL_DOCUMENT_SRV.A_MaterialDocumentHeaderType",…}
type:"API_MATERIAL_DOCUMENT_SRV.A_MaterialDocumentHeaderType"
uri:"/My187/sap/opu/odata/sap/API_MATERIAL_DOCUMENT_SRV/A_MaterialDocumentHeader('id-1536693644259-199')"
我的问题是:
- 如何让绑定生成“to_MaterialDocumentItem”,如经过验证的 JSON 中所示?