cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameters using an odata in Web IDE

Former Member
0 Kudos

Sorry if this has been discussed before but I searched and couldn't find an answer. I'm new to Web IDE and trying to build a project from a template in Web IDE. Another developer created an OData which I connected to and tells me I have to pass in the invoice number to retrieve the data. I've tried creating a New Configuration and adding the invoice parameter and value in there but it doesn't work. He's saying the URI should be something like the ones below but how do I pass in the invoice number to get the invoice details when I run the project?

/sap/opu/odata/sap/ZMM_PO_DTLS_SRV/POHeaderSet('3000040127')

/sap/opu/odata/sap/ZMM_PO_DTLS_SRV/POHeaderSet(Purchaseorder='3000040127')

/sap/opu/odata/sap/ZMM_PO_DTLS_SRV/POVendorSet(Purchaseorder='3000040127',VendorFlag='X')

/sap/opu/odata/sap/ZMM_PO_DTLS_SRV/POItemSet?$filter=Purchaseorder eq '3000040127'

Thanks,

Arya

Accepted Solutions (0)

Answers (2)

Answers (2)

jamie_cawley
Advisor
Advisor
0 Kudos
Former Member
0 Kudos

Hi Jamie,

Is there no way to do this in Web IDE when I run my project? Here's what I've done:

1. Create a project from a template (master/detail)

2. Connect to our OData backend

3. Run the project, it doesn't return any data

4. Create a new run configuration adding a URL parameter called Purchaseorder and value of 3000040127. Run the new configuration but that doesn't return any data either.

If I go into SAP Activate and Maintain Services, select the OData and go to the Gateway Client I can use the URLs in my original post to retrieve the invoice information. I just don't know how to pass in a parameter when running my project and I don't quite understand the code in the link you provided. Sorry, I'm new to all of this so forgive me if I'm misunderstanding anything.

Thanks,

Arya

jamie_cawley
Advisor
Advisor
0 Kudos

To use url parameters you would need to first modify the list definition in the master view, removing the aggregation declaration which would be something like.

items="{/POHeaderSet}"

Then create two functions in the controller and have the onInit function call bindView


bindView: function(){

  var oTemplate, aFilter, oList; 

  var sParam = this.getUrlParameterValue("Your Parameter Name");

  if(sParam){

  aFilter =[ new sap.ui.model.Filter("The field you want to filter", sap.ui.model.FilterOperator.EQ, sParam)]; 

  }

       oList = this.getView().byId("list"); 

       oTemplate = oList.getItems()[0].clone(); 

       oList.bindAggregation("items", { 

            path:'/POHeaderSet', 

            template:oTemplate, 

            filters:aFilter 

       }); 

  },

  getUrlParameterValue: function(sParam)

  {

  var sPageURL = window.location.search.substring(1);

  var sURLVariables = sPageURL.split('&');

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

  {

  var sParameterName = sURLVariables[i].split('=');

  if (sParameterName[0] == sParam)

  {

  return sParameterName[1];

  }

  }

  return null;

  },

Regards,

Jamie

SAP - Technology RIG

0 Kudos

Hello Arya,


I am not sure I am fully understood your use case. Do you have navigation between 2 entity sets or no?

if yes,  please verify that they are working.

Basically, URL parameters are parameters that added to URL after the "?" mark sign and they are not replacing the standard ODATA navigation mechanism.

In standard master detail template the navigation between master to details is with hash parameters, for example: 

#&/detail/SalesOrders('SalesOrderNumber%202')


Thanks Alex

michal_keidar
Active Contributor
0 Kudos

Hi , Former Member, ,

Can you please see if you can assist here?

Thanks,
Michal.