cancel
Showing results for 
Search instead for 
Did you mean: 

Bind Single Value from OData to SAPUI5 Element "sap.ui.commons.TextField"

0 Kudos

Hello and sorry if this long winded - just want to put all the information needed to assist getting the answer.

The following links did not help me:
https://archive.sap.com/discussions/thread/3406353
https://archive.sap.com/discussions/thread/3779809

In SAP (SEGW), I have an OData Project called ZMM_GWS_PO.
I have an Entity Type called PO_Line_Items.
I have an Entity Set called PO_Line_Items_ES.
I have several properties in Entity Type PO_Line_Items, of which I just want to retrieve EBELN and put it into a UI Element in ZPO.view.js.
I have redefined Method PO_LINE_ITEMS_ES_GET_ENTITYSET, of which I can successfully retrieve an entire table of data.
I thought perhaps I needed to redefine Method PO_LINE_ITEMS_ES_GET_ENTITY.

In ZPO.view.js I have:
var L_EBELN = new sap.ui.commons.TextField( "l_ebeln", { width: '10px', maxLength: 10 } );

I want UI Element L_EBELN to be a value retrieved from Entity Type PO_Line_Items's Property EBELN.

So how to do it??

The following 5 things individually did not work and nothing happens when they are executed - I get a blank page:

l_ebeln.bindElement( "/PO_Line_Items_ES('4500000000')/EBELN" );
l_ebeln.bindElement( "/PO_Line_Items('4500000000')/EBELN" );
l_ebeln.bindProperty( "value", "/PO_Line_Items_ES('4500000000')" );
l_ebeln.bindProperty( "value", "/PO_Line_Items('4500000000')" );

var sRead = "/PO_Line_Items_ES(EBELN='4500000000')";
l_odata_model.read( sRead, null, null, true, 
  function(oData, oResponse) {
    l_ebeln.setValue( oData.EBELN );
  }, function() {
    alert("Read Failed");
  } 
);

(I have successfully done Table binding, so that's not what I need to do here - I know how to do that!)
What is the syntax for ONE VALUE in my ODATA to go into ONE UI Element in my View?

A code snippet is best to show me what I'm doing wrong.

Thanks in advance,

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

To anyone who might find this useful, I have found the answer, though surprised it didn't come from a response here.

var l_odata_model = sap.ui.getCore().getModel();  //From the Controller onInit Function
var L_EBELN = new sap.ui.commons.TextField( "l_ebeln", { width: '100px', maxLength: 10 } );

l_ebeln.setModel( l_odata_model );                                              //Connection to SAP OData Project
l_ebeln.bindElement( "/PO_Line_Items_ES(EBELN='4500000000',EBELP='000010')" );  //Entity Set and its Keys
l_ebeln.bindValue( "EBELN" );                                                   //The Field in my Entity I want

Answers (1)

Answers (1)

former_member626746
Discoverer
0 Kudos

Hi Sean,

I am new to UI5/Odata.

Just one question. In the below statement, you have passed key fields as filter. What if I do not have key fields as filter. Can you provide some code for this scenario.

l_ebeln.bindElement("/PO_Line_Items_ES(EBELN='4500000000',EBELP='000010')" );  //Entity Set and its Keys