cancel
Showing results for 
Search instead for 
Did you mean: 

OData binding issue

Former Member
0 Kudos

Hi Friends,

It is an OData binding issue.

I am trying to display data of salesorderitems in the sap.m.table but was not able to bind using bind aggregation.

what i am trying to achieve is , for a given business partner there will be multiple sales order and each order will have multiple sales order items i want to bind those items in the sap.m.table using bind aggregation.

URL:https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/BusinessPartners(%270100000008...

i have attached a screenshot in which i have marked the section which contains the data i need to read. that will be available in the above link.

code snippet for binding :

var model =sap.ui.model.odata.ODataModel("proxy/https/sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/",true,'username','password'); 

App.setModel(model);

  pastOrder_S3.bindAggregation("items","/BusinessPartners('"+businessPartnerId+"')/SalesOrders?$expand=SalesOrderItems",oTemplate_S3);

  new sap.m.Text({

          text:"{SalesOrderItems\ProductName} \n {SalesOrderItems\ProductId}"

         }),        

         new sap.m.Text({

          text:"OrderId: {SalesOrderID} \n {DeliveryDate} \n {TotalSum}{Currency}"

         }),

         new sap.ui.core.Icon({

  src :"sap-icon://slim-arrow-right",

  size:'15px',

  color:'gray'

  })

         ]

  });

It will be helpful if any one can guide me.

Regards, Santosh.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes, we tried to fetch the details of the sub structure by using expand and by making an ajax call but was not able to get the solution.

can you share your ideas on how can we fetch the sub structure or any other way that we can solve this issue.

Regards,

Santosh.

Former Member
0 Kudos

Hi Sakthivel Elango,Sergio Guerrero,

Thanks for the reply.

The code is not breaking and the data is also displaying, but it is not displaying the exact data which i need.

Sergio Guerrero : and the two text and one icon are inside a template which is binded to table and table is added to pages content.

code snippet:

var oTemplate_S3= new sap.m.ColumnListItem({

  type: sap.m.ListType.Active,

  cells: [

                     new sap.m.CheckBox("chkValue",{

                  

                    select: function(e) {

                    debugger;

                     if (e.getParameters().selected) {

                         var row = e.getSource().getBindingContext().sPath;

                         var data=row.lastIndexOf("/");

                       var iDvalue=  row.substring(data+1);

                       idData.data.push(iDvalue);

                       }

                     else {

                         var row = e.getSource().getBindingContext().sPath;

                         var data=row.lastIndexOf("/");

                       var iDvalue=  row.substring(data+1);

                       for(var i=0;i<idData.data.length;i++)

                       {

                       var temp =idData.data[i];

                       if(temp==iDvalue)

                       {

                        idData.data.splice(i,1);

                       }

                       }

                    }

                    }

                    }),

                   

         new sap.m.Text({

          text:"{SalesOrderItems/ProductName} \n {Note}"

         }),   

         new sap.ui.core.Icon({

  src :"sap-icon://drill-up",

  size:'15px',

  color:'gray',

  press: function(oEvent) {

  /*var myView1 = sap.ui.view({

  type:sap.ui.core.mvc.ViewType.JS,

  viewName:"my.own.view"

  });

  var myView2 = sap.ui.view({

  type:sap.ui.core.mvc.ViewType.JS,

  viewName:"my.own.view2"

  });*/

  // extend the Dialog instance with an individual function

  oDialog.changeView = function() {

  debugger;

  this.removeAllContent();

  }

  oDialog.open();

  }

  }),

         new sap.m.Text({

          text:"OrderId: {SalesOrderID} \n {DeliveryDate} \n {TotalSum}{Currency}"

         }),

         new sap.ui.core.Icon({

  src :"sap-icon://slim-arrow-right",

  size:'15px',

  color:'gray'

  })

         ]

  });

  pastOrder_S3.bindAggregation("items","/BusinessPartners('"+businessPartnerId+"')/SalesOrders?$expand=SalesOrderItems",oTemplate_S3);

url: https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/BusinessPartners('0100000000')...

url for json format : https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/BusinessPartners('0100000000')...

here we are trying to get all sales order items of all sales order of business partner whose id is 0100000000.

json structure:

"d":{

      "results":[

         {

            "SalesOrderID":"0500000000",

            "NetSum":"21737.00",

            "Tax":"0.00",

            "Currency":"EUR",

            "ChangedAt":"\/Date(1432623600000)\/",

            "Note":"EPM DG: SO ID 0500000000 Deliver as fast as possible",

            "CreatedAt":"\/Date(1432623600000)\/",

            "TotalSum":"25867.03",

            "Status":"N",

            "CustomerName":"SAP",

            "BusinessPartnerID":"0100000000",

            "SalesOrderItems":{

               "results":[

                  {

                     "QuantityUnit":"EA",

                     "Tax":"181.64",

                     "NetSum":"956.00",

                     "TotalSum":"1137.64",

                     "ProductName":"EPM DG: SO ID 0500000000 Item 0000000010",

                     "ProductID":"HT-1000",

                     "Position":"0000000010",

                     "SalesOrderID":"0500000000",

                     "Currency":"EUR",

                     "Quantity":"1.000",

                     "DeliveryDate":"\/Date(1433228400000)\/",

                     "Product":{

                        "__deferred":{

                           "uri":"https://sapes1.sapdevcenter.com:443/sap/opu/odata/sap/ZCD204_EPM_DEMO_SRV/SalesOrderItems(Position='..."

                        }

                     },

                     "SalesOrderHeader":{

}



]

}

if you see the above json structure,  i am able to read child nodes like Notes , SalesOrderId etc. but there is a node named SalesOrderItems

which has sub child elements like "QuantityUnit":"EA". these are the elements which i want to display but not able to do.


i am missing out in reaching the sub child element as i am able to display the child element for "d".

Thanks.

SergioG_TX
Active Contributor
0 Kudos

since Sales Orders items contains a substructure you need to include the path SalesOrderITems/results/ YOUR_PROPERTY etc.  you need to make sure you follow the correct path like you do with the other properties

Former Member
0 Kudos

Can you check your console for any errors & post it ?

SergioG_TX
Active Contributor
0 Kudos

did you declare App?

is your odata service url correct?

you have two text controls and one icon control. how are they being added to the aggregation? seems like you have the closing of an array and you are comma-separating them. where is this array being added to?