Skip to Content

issue with Binding Smart Table with EntitySet and tableBindingPath of the ABAP ODATA

Hi,

I have ABAP ODATA which i want to bind to SmartTable and please find the below code and i am getting in the screen "Right now, there are no visible columns in the table. Please select the columns you need in the table settings." and not able to bind the ABAP ODATA to SmartTable

1)Component.js

var odataModel = new sap.ui.model.odata.ODataModel("/IS4/sap/opu/odata/sap/ZPDMS_HEALTH_FORCATING_SRV", true);

this.setModel(odataModel, "ODATA");

2)In the View1.view.xml

<smartTable:SmartTable id="idSmartTableAll" tableType="ResponsiveTable" useVariantManagement="false" useTablePersonalisation="true" persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true" demandPopin="true" useExportToExcel="false" class="sapUiResponsiveContentPadding" showFullScreenButton="true" ignoredFields="" initiallyVisibleFields="LocationName"> </smartTable:SmartTable>

3)In the View1.controller.js

onInit: function ()

{

var view = this.getView();

view.setModel(this.getOwnerComponent().getModel("ODATA"));

view.byId("idSmartTableAll").rebindTable();

}

4)When UserClicks on Go Button then the below function triggers

onPressGo:function()

{

var that = this;

var smarttable = that.getView().byId("idSmartTableAll");

smarttable.setModel("ODATA");

var network = "IND-BAN";

var url = "/health_forecastingSet?$filter=LocationName eq '" + network + "'";

smarttable.setTableBindingPath(url);

smarttable.setEntitySet("health_forecastingSet");

smarttable.rebindTable();

}

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Jul 28, 2020 at 10:53 AM

    Hi,

    You can add columns to the table form settings icon in the table toolbar.

    If you can make the columns visible by this setting, that means the binding is working, and you just need lineItem annotation for the OData.

    You can add local annotation,

    https://developers.sap.com/tutorials/odata-04-basic-annotations.html#8e9ed1aa-dc8f-47f9-8867-984a45fdc85e

    or add CDS annotation (if your OData service is based on CDS view).

    https://developers.sap.com/tutorials/abap-environment-text-table.html#e5f9d68d-ec7c-4d49-83c8-66331f93443b

    Regards,

    Mio


    ggyzs.png (1.1 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 28, 2020 at 03:36 PM

    In the <smartTable:SmartTable ....> declaration add the requestAtLeastFields property and specify the fields which you expect to view as default columns in the SmartTable as comma separated values, as below:

    <smartTable:SmartTable ..... requestAtLeastFields="field1,field2,field3,...fieldn"> 
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 02, 2020 at 04:29 AM

    Hi DurgaPrasanth vemula,

    Is your requirement is to show a blank table as default and load the content when user press 'Go' button?

    In that case, set enableAutoBinding to false.

    You can apply filter to the table on beforeRebindTable event.

    Your code would be like below.

    Component.js

    //create odata v2 model (this is a default model).
    var oModel = new ODataModel("/IS4/sap/opu/odata/sap/ZPDMS_HEALTH_FORCATING_SRV");
    this.setModel(oModel);
    

    View

    <smartTable:SmartTable id="idSmartTableAll" tableType="ResponsiveTable" 
    	useVariantManagement="false" useTablePersonalisation="true" persistencyKey="SmartTableAnalytical_Explored" 
    	enableAutoBinding="false" demandPopin="true" useExportToExcel="false" class="sapUiResponsiveContentPadding" 
    	showFullScreenButton="true" ignoredFields="" initiallyVisibleFields="LocationName"
    	entitySet="health_forecastingSet" beforeRebindTable="onBeforeRebindTable"> 
    	<smartTable:customToolbar>
    		<Toolbar>
    			<ToolbarSpacer/>
    			<Button text="Go" press="onPressGo"/>
    		</Toolbar>
    	</smartTable:customToolbar>
    </smartTable:SmartTable>
    

    Controller

    onInit: function () {
    },
    
    onBeforeRebindTable: function (oEvent) {
    	var oFilter = new Filter({
    		path: "LocationName",
    		operator: sap.ui.model.FilterOperator.EQ,
    		value1: "IND-BAN"
    	});
    	oEvent.getParameter("bindingParams").filters.push(oFilter);
    },
    
    onPressGo: function () {
    	var oTable = this.byId("idSmartTableAll");
    	oTable.rebindTable();
    }

    Regards,

    Mio

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.