cancel
Showing results for 
Search instead for 
Did you mean: 

Pass input values of RFC to odata service ?

Former Member
0 Kudos

Hi experts,

I have developed a new Odata service from a BAPI . and it has two values as input parameters. I was able to perform a filter operation and check the values in the browser XML with the generated odata service in service builder .  Please let me know how the input values can be passed in the UI5 layer ro the odata service and check the output.

Accepted Solutions (0)

Answers (1)

Answers (1)

nabheetscn
Active Contributor
0 Kudos

Hi David

You can basically bind the data model to the front end UI elements. You will have to take care of the structure which you are binding. What exactly do you want to achieve?

Nabheet

Former Member
0 Kudos

This is how my odata service URL

http://GatewayHostname/sap/opu/odata/sap/ZSALESORDER_SRV/SalesOrderset/?$filter=DocNumber eq '0000004973'

Please let me know how to bind the Data model to front end UI elements , to develop a UI5 application from odata service ?

nabheetscn
Active Contributor
0 Kudos

Hi David

I am assuming you have created your UI elements and you want to make an Odata call.

Please check this below mentioned code. ID/DESC are my two UI Elements which have some value on UI. I am reading it and then whatever the data in this case items it is passing back via ODATA call i have binded that to front end UI element which is table  POHDR.

var sServiceUrl = "http://DEF.ad.ABC.com:8001/sap/opu/odata/sap/ZTMP_ABV";

var oModel = new sap.ui.model.odata.ODataModel( sServiceUrl , true, "<User name>", "<Pass word>"); 
sap.ui.getCore().setModel(oModel);
var oFilter = new Array();
var ID =  sap.ui.getCore().getElementById('ID').getValue();
var Desc = sap.ui.getCore().getElementById('Desc').getValue();
oFilter[0] = new sap.ui.model.Filter("ID", sap.ui.model.FilterOperator.EQ,"HELP" );

//oFilter[1] = new sap.ui.model.Filter("DESC", sap.ui.model.FilterOperator.EQ, "");

sap.ui.getCore().getElementById('POhdr).bindRows({

  path: '/<entity set to bound>/',

  filters: oFilter

Nabvheet

Former Member
0 Kudos

Thanks Nabheet, for detail reply.

I have created an UI5 project as in screenshot with Ui5 plgin in eclipse. PLease let me know how to create the Odata Ui elements in the project . I came across the SAPUI5 SDK - Demo Kit guide , but very confused how and where to add ui input for the Po number and display the details as a result.

nabheetscn
Active Contributor
0 Kudos

Hi David

Even i have started working on UI5 around 1.5 months back and its fun. I would recommend you to go through this wonderful document and complete all exercises. It will help you in understanding how to create front end element and get your hands on.

This example uses local File data but once you are done you will be able to integrate both

Nabheet

Former Member
0 Kudos

thanks will give a try. Are there pre requisites to be installed in SAP ECC to work with these exercises and UI5.

In the link you mentioned ,

  • Evaluation package for UI development toolkit for HTML5 1.16.3 (available here ...) --I downloaded this, Where to install this ?
  • SAPUI5 Runtime version 1.16.4 - Where can i find the runtime  ?

Below are my eclipse Plugin details

I have xampp installed in my local system .

nabheetscn
Active Contributor
0 Kudos

David

You do not need ECC for those ten exercises as they use local file data. Secondly in order to develop front end you need Eclipse Juno then you just need to install the library the last one in your screen shot that's it

Open the document it has all the system setup steps also.

Nabheet

Former Member
0 Kudos

I have followed the document and got some good information from it.

but the data in the project is hardcoded in model and being referenced every time , but for me should get from Odata . Odata can return in json format also. but how to achieve this dynamically ?

with value from input text box . and then navigate to next screen.

PLease let me know how to achieve this ?

nabheetscn
Active Contributor
0 Kudos

If you check my earlier code i am reading input data from UI(ID and Desc are my UI field id's) then i am making an odata call and after that i am binding the entityset to my frontend table

Nabheet

Former Member
0 Kudos

Hi nabheet madan

PLease check and suggest if i  am doing it in correct way or missing something.

I replaced the Fiori exercise 0 files in my newly created UI5 project . and changing the       master.view .xml and master.controller.js as below

master.view.xml



<core:View

  controllerName="sap.ui.demo.myFiori.view.Master"

  xmlns="sap.m"

  xmlns:core="sap.ui.core" >

  <Page

  title="~MasterPage~" >

      <subHeader>

<Bar>

<contentLeft>

<SearchField

search="handleSearch"

width="100%" >

</SearchField>

</contentLeft>

</Bar>

</subHeader>

  

  <Button id="MyButton" text="Get Sales Order Status" press="doIt"/> 

  

  </Page>

</core:View>




master.controller.js


sap.ui.controller("sap.ui.demo.myFiori.view.Master", {

  doIt : function(oEvent) {

  var sServiceUrl = "http://DEF.ad.ABC.com:8001/sap/opu/odata/sap/ZTMP_ABV";

  var oModel = new sap.ui.model.odata.ODataModel( sServiceUrl , true, "<User name>", "<Pass word>");

  sap.ui.getCore().setModel(oModel);

  var oFilter = new Array();

  var ID =  sap.ui.getCore().getElementById('ID').getValue();

  var Desc = sap.ui.getCore().getElementById('Desc').getValue();

  oFilter[0] = new sap.ui.model.Filter("ID", sap.ui.model.FilterOperator.EQ,"HELP" );

  //oFilter[1] = new sap.ui.model.Filter("DESC", sap.ui.model.FilterOperator.EQ, "");

  sap.ui.getCore().getElementById('POhdr').bindRows({

   path: '/<entity set to bound>/',

   filters: oFilter

  })

  }

});