How to read an aggregated entity from Odata Service SAP ui5

Lionel Samstag.

In OData Model V2, I'm struggling by reading the odata of my mocked server:

I want to get access to the child entity which is associated with a Parent entity.

From Open_Station I can navigate to_Order_Header:

[{
    "results": [
        {
            "__metadata": {
                "id": "http://WebService/Open_Station(Station='CHE1',Task='5246')",
                "uri": "http://WebService/Open_Station(Station='CHE1',Task='5246')",
                "type": "cds_zui_check_dialog.Open_StationType"
            },

            "Station": "CHE1",
            "Task": "5246",
            "to_Order_Header": {
                "__deferred": {
                    "uri": "http://WebService/Open_Station(Station='CHE1',Task='5246')/to_Order_Header"
                }
            }
        }
    ]
}

]

And from to_Order_Header, I can navigate to Order_Item or Stock:

[{
"__metadata" : {
  "id" : "http://WebService/Order_Header(OrderNumber='00000000100000000853',Station='CHE1',OrderIndicator='')",
  "uri" : "http://WebService/Order_Header(OrderNumber='00000000100000000853',Station='CHE1',OrderIndicator='')",
  "type" : "cds_zui_check_dialog.Order_HeaderType"
},
"OrderNumber" : "00000000100000000853",
"Station" : "CHE1",
"OrderIndicator" : "",
"to_Order_Items" : {
  "__deferred" : {
    "uri" : "http://WebService/Order_Header(OrderNumber='00000000100000000853',Station='CHE1',OrderIndicator='')/to_Order_Items"
  }
},
"to_Stock" : {
  "__deferred" : {
    "uri" : "http://WebService/Order_Header(OrderNumber='00000000100000000853',Station='CHE1',OrderIndicator='')/to_Stock"
  }

} ]

In my controller, I have a metho ReadOdata read data like this:

ReadOdata: function()
{
   var oModel = new sap.ui.model.odata.v2.ODataModel("http://WebService");
   return new Promise(function(resolve, reject)
   {
       oModel.read("Open_Station(Station='CHE1',Task='5246')/to_Order_Header", {
           
           success : function (data) {
              resolve(data);
           },
           error: function (oError) {
               reject(oError);
           }
       });
   });
   
},

I always get a failure like this:

Request failed with status code 404: GET Open_Station(Station='CHE1',Task='5246')/to_Order_Header 
- [{"code":404,"message":"Resource not found","persistent":false,"targets":["/Open_Station(Station='CHE1',Task='5246')/to_Order_Header"],"type":"Error"}]
 sap.ui.model.odata.ODataMessageParser

I think the way I want to read the associated entity is wrong. Please help me.

Lionel Samstag.

I found a solution. It was a failure in the annotation of the Path:

Instead of writing:

 oModel.read("**to_Open_Station**(Station='CHE1',Task='5246')/to_Order_Header", {

I was writing:

oModel.read("*Open_Station*(Station='CHE1',Task='5246')/to_Order_Header", {

In the MetaData, the NavigationProperty was called to_Open_Station.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ui5 OData V4 - How to create entity from Form with custom updateGroupId

From Dev

How to read an HTML Input Field from an XML file in SAP Ui5?

From Dev

How to get OData Context from parent Context in UI5

From Dev

Return delta from SAP OData Sample service

From Dev

SAP UI5 access value of oData model

From Dev

How to set Content-Type:application/json in ui5 oData.read() ?

From Dev

OData service authentication with SAP Gateway service OpenUI5

From Dev

Binding an AnalyticMap Model with an OData service in UI5

From Dev

UI5 Odata read call with filter and urlParameters simultaneously

From Dev

How to expose an odata service for a transient entity

From Dev

How to execute integrationtests for own OData service in SAP Cloud SDK

From Dev

How to Add Date / Time from OData Service Correctly to UI?

From Dev

OData: how to get the highest ID in UI5

From Dev

How do I generate a UUID in SAP UI5 code?

From Dev

SAP GATEWAY & UI5: How can reset the CSRF token?=

From Dev

How to set count to a PagingButton in SAP ui5

From Dev

How to select all checkbox in sap UI5

From Dev

How to get view depend on user in sap UI5?

From Dev

How to attach data to an sap.m.StandardListItem from odata binding?

From Dev

How to wait for the response of an OData service's read operation in SAPUI5 before further execution of code?

From Dev

How to create variant without using smart controls in SAP UI5/ SAP FIORI

From Dev

SAP UI5 - How to disable a row in sap.m.Table Multiselect table based on row status

From Dev

How to read users from SAP UME

From Dev

How do I access OData service using the SAP S/4HANA Cloud SDK in existing application?

From Java

How to avoid a DestinationAccessException when sending a POST request to an OData service using SAP Cloud SDK version 3.2.0

From Dev

How to deal with odata service created with 1000 rows of hana table in SAP hana XS app

From Dev

Selecting first item in ComboBox from ODATA call. UI5

From Dev

Need to load the UI5 Module from Other Host in SAP Fiori

From Dev

how to set combo box default value as session logged in user id in sap ui5

Related Related

  1. 1

    ui5 OData V4 - How to create entity from Form with custom updateGroupId

  2. 2

    How to read an HTML Input Field from an XML file in SAP Ui5?

  3. 3

    How to get OData Context from parent Context in UI5

  4. 4

    Return delta from SAP OData Sample service

  5. 5

    SAP UI5 access value of oData model

  6. 6

    How to set Content-Type:application/json in ui5 oData.read() ?

  7. 7

    OData service authentication with SAP Gateway service OpenUI5

  8. 8

    Binding an AnalyticMap Model with an OData service in UI5

  9. 9

    UI5 Odata read call with filter and urlParameters simultaneously

  10. 10

    How to expose an odata service for a transient entity

  11. 11

    How to execute integrationtests for own OData service in SAP Cloud SDK

  12. 12

    How to Add Date / Time from OData Service Correctly to UI?

  13. 13

    OData: how to get the highest ID in UI5

  14. 14

    How do I generate a UUID in SAP UI5 code?

  15. 15

    SAP GATEWAY & UI5: How can reset the CSRF token?=

  16. 16

    How to set count to a PagingButton in SAP ui5

  17. 17

    How to select all checkbox in sap UI5

  18. 18

    How to get view depend on user in sap UI5?

  19. 19

    How to attach data to an sap.m.StandardListItem from odata binding?

  20. 20

    How to wait for the response of an OData service's read operation in SAPUI5 before further execution of code?

  21. 21

    How to create variant without using smart controls in SAP UI5/ SAP FIORI

  22. 22

    SAP UI5 - How to disable a row in sap.m.Table Multiselect table based on row status

  23. 23

    How to read users from SAP UME

  24. 24

    How do I access OData service using the SAP S/4HANA Cloud SDK in existing application?

  25. 25

    How to avoid a DestinationAccessException when sending a POST request to an OData service using SAP Cloud SDK version 3.2.0

  26. 26

    How to deal with odata service created with 1000 rows of hana table in SAP hana XS app

  27. 27

    Selecting first item in ComboBox from ODATA call. UI5

  28. 28

    Need to load the UI5 Module from Other Host in SAP Fiori

  29. 29

    how to set combo box default value as session logged in user id in sap ui5

HotTag

Archive