Skip to Content

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

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:

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')"; 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,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 06, 2017 at 05:01 AM

    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
    Add comment
    10|10000 characters needed characters exceeded