Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to fetch multiple records from Odata service into the output table.

Hi everyone,

As you see in screen shot I have attached in this discussion, I'm trying to fetch data from detail entity set of odata by passing input to it dynamically through master view. In my case the input is BOM number("00000026" as shown in screen shot). I have created a table in my detail.view.xml and trying to do filter & binding in detail.controller.js

when I run follow url in browser it shows expected output in xml format.

http://<host>:<port>/sap/opu/odata/SAP/ZPPBOM_ODATA_SRV/DetailppSet/?$filter= Stlnr eq '00000026'

And when I run project using following code, it neither show any error in consol nor it shows any output in table.

In detail.controller.js there is a variable 'Bomnumber' in which I'm able to get BOM number dynamically from master view.

Please check following xml and js files.

Looking forward for helpful reply.

Regards,

Jagrut Patil.

Detail.view.xml


<Table id="detail1" >

<headerToolbar>

  <Toolbar>

   <Label text="BOM number"></Label>

  </Toolbar>

</headerToolbar>

<columns>

  <Column width="12em">

   <Text text="Item number" />

  </Column>

  <Column minScreenWidth="Tablet" demandPopin="true">

   <Text text="Item Category" />

  </Column>

   <Column minScreenWidth="Tablet" demandPopin="true">

   <Text text="BOM component" />

  </Column>

  <Column minScreenWidth="Tablet" demandPopin="true" hAlign="Right">

   <Text text="Quantity" />

  </Column>

  <Column minScreenWidth="Tablet" demandPopin="true" hAlign="Center">

   <Text text="Unit of measure" />

  </Column>

</columns>

<items>

      <ColumnListItem>

        <cells>

      

          <ObjectIdentifier

            text="{Posnr}" />

        

          <Text text="{Postp}" />

          <Text text="{Idnrk}" />

   <Text text="{Menge}" />

          <Text text="{Meins}" />

      

        </cells>

    

      </ColumnListItem>

    </items>

</Table>

Detail.controller.js

onInit : function() {

var bus = sap.ui.getCore().getEventBus();


bus.subscribe("app", "RefreshDetail", this._refresh, this);


},


_refresh : function(channelId, eventId, data) {

var Bomnumber = data.Bomnumber;

this.getView().byId("bomnumber").getValue(Bomnumber);

var filter = (new sap.ui.model.Filter("Stlnr",

sap.ui.model.FilterOperator.EQ, Bomnumber));

var oModel = new sap.ui.model.odata.ODataModel(

"/sap/opu/odata/SAP/ZPPBOM_ODATA_SRV",

true);


oModel.read("/DetailppSet/?$filter=",filter);

var oTable = new sap.m.Table("detail1");

oTable.setModel(oModel);

},

bom.jpg (163804 B)
Tags:
replied

your code is bad.

1) create odata model in onInit

2) bind table in onInit

3) in _refresh do filter on list binding from table

this.byId("detail1").getBinding("items").filter(filter)

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question