【问题标题】:Accessing Data Members after using expand in Odata在 Odata 中使用 expand 后访问数据成员
【发布时间】:2017-07-18 08:20:20
【问题描述】:

我目前有一个包含 2 个实体集的 odata 服务。我正在使用 expand 导航到第二个实体集,并在表中绑定两者的值。

但是,我无法将第二个实体集的数据绑定为 {to_PurchaseOrderItem/PurchaseOrderQuantityUnit}

我做错了吗?

JSON 回复看起来像这样,所以我真的很困惑我做错了什么。

"d": {
    "results": [
      {

        "PurchaseOrder": "4500000001",
        "Language": "EN",
        "PaymentTerms": "0004",
        "CashDiscount1Days": "0",
        "CashDiscount2Days": "0",
        "NetPaymentDays": "0",
        "CashDiscount1Percent": "0.000",
        "CashDiscount2Percent": "0.000",
        "PurchasingOrganization": "1710",
        "PurchasingDocumentOrigin": "9",
        "PurchasingGroup": "001",
        "CompanyCode": "1710",
        "PurchaseOrderDate": "/Date(1468454400000)/",
        "DocumentCurrency": "USD",
        "ExchangeRate": "1.00000",
        "ValidityStartDate": null,
        "ValidityEndDate": null,
        "SupplierQuotationExternalID": "",
        "SupplierRespSalesPersonName": "",
        "SupplierPhoneNumber": "",
        "SupplyingSupplier": "",
        "SupplyingPlant": "",
        "PurchaseOrderType": "NB",
        "IncotermsClassification": "",
        "InvoicingParty": "17300001",
        "ReleaseIsNotCompleted": false,
        "PurchasingCompletenessStatus": false,
        "IncotermsVersion": "",
        "IncotermsLocation1": "",
        "IncotermsLocation2": "",
        "ManualSupplierAddressID": "",
        "AddressCityName": "",
        "AddressFaxNumber": "",
        "PurchasingDocumentDeletionCode": "",
        "AddressHouseNumber": "",
        "AddressName": "",
        "AddressPostalCode": "",
        "AddressStreetName": "",
        "AddressPhoneNumber": "",
        "AddressRegion": "",
        "AddressCountry": "",
        "AddressCorrespondenceLanguage": "",
        "PurchasingProcessingStatus": "02",
        "CreatedByUser": "CB9980000025",
        "CreationDate": "/Date(1468454400000)/",
        "Supplier": "17300001",
        "PurchaseOrderSubtype": "",
        "to_PurchaseOrderItem": {
          "results": [
            {

              "PurchaseOrder": "4500000001",
              "OrderQuantity": "100",
              "PurchaseOrderQuantityUnit": "ES",
              "OrderPriceUnit": "ES",
              "OrderPriceUnitToOrderUnitNmrtr": "1",
              "OrdPriceUnitToOrderUnitDnmntr": "1",
              "NetPriceAmount": "0.21",
              "DocumentCurrency": "USD",
              "NetPriceQuantity": "1",
              "TaxCode": "",
              "PriceIsToBePrinted": true,
              "PurchaseOrderItem": "1",
              "OverdelivTolrtdLmtRatioInPct": "10.0",
              "UnlimitedOverdeliveryIsAllowed": false,
              "UnderdelivTolrtdLmtRatioInPct": "10.0",
              "ValuationType": "",
              "IsCompletelyDelivered": false,
              "IsFinallyInvoiced": false,
              "PurchaseOrderItemCategory": "0",
              "AccountAssignmentCategory": "",
              "MultipleAcctAssgmtDistribution": "",
              "PartialInvoiceDistribution": "",
              "PurchasingDocumentDeletionCode": "L",
              "GoodsReceiptIsExpected": true,
              "GoodsReceiptIsNonValuated": false,
              "InvoiceIsExpected": true,
              "InvoiceIsGoodsReceiptBased": false,
              "PurchaseContract": "",
              "PurchaseContractItem": "0",
              "Customer": "",
              "ItemNetWeight": "0.000",
              "ItemWeightUnit": "",
              "TaxJurisdiction": "0508525201",
              "PurchaseOrderItemText": "RAW15,PD",
              "PricingDateControl": "",
              "ItemVolume": "0.000",
              "ItemVolumeUnit": "",
              "SupplierConfirmationControlKey": "",
              "IncotermsClassification": "EXW",
              "IncotermsTransferLocation": "VENDOR",
              "EvaldRcptSettlmtIsAllowed": false,
              "PurchaseRequisition": "",
              "PurchaseRequisitionItem": "0",
              "IsReturnsItem": false,
              "Plant": "1710",
              "RequisitionerName": "",
              "ServicePackage": "0",
              "EarmarkedFunds": "",
              "EarmarkedFundsItem": "0",
              "IncotermsLocation1": "VENDOR",
              "IncotermsLocation2": "",
              "Material": "RM15",
              "ManufacturerMaterial": "RM15",
              "ServicePerformer": "",
              "ProductType": "1",
              "StorageLocation": "",
              "DeliveryAddressID": "",
              "DeliveryAddressName": "",
              "DeliveryAddressStreetName": "",
              "DeliveryAddressHouseNumber": "",
              "DeliveryAddressCityName": "",
              "DeliveryAddressPostalCode": "",
              "DeliveryAddressRegion": "",
              "DeliveryAddressCountry": "",
              "MaterialGroup": "L002",
              "PurchasingInfoRecord": "5300000201",
              "SupplierMaterialNumber": ""

我正在尝试访问具体的订单数量。

谢谢!

【问题讨论】:

  • 需要先绑定表items,再绑定UOM。
  • 我遇到了问题。发生这种情况是因为 1:N 映射,而不是 1:1。因此,结果集更像是带有聚合的聚合,当我使用 Master Detail 而不是我自己的 UI 时,效果很好。

标签: odata sapui5


【解决方案1】:

我认为您在绑定控件时缺少“结果”。请看下面并尝试

{to_PurchaseOrderItem/results/0/PurchaseOrderQuantityUnit}

【讨论】:

  • 我认为您正在尝试对控件进行属性绑定。如果您尝试聚合绑定,那么这将不起作用。
  • 只有当我使用 $format=json 时才会出现结果。但如果我通过浏览器打开它,OData 响应中就不存在它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-01
  • 1970-01-01
相关资源
最近更新 更多