Now we have to do below configuration after first part.

Please click on the selected button and do the below configuration.

31.JPG

Now we have to do the below mapping.

32.JPG

Step 14: Now we have to do the mapping for the node SalesOrderItemCollection.

Open the node and select as below.

33.JPG

And then provide below details in the pop up.

Target System

Local

Data Source Type

Remote Function Call

Data Source Name

BAPI_EPM_SO_GET_DETAIL

34.JPG

And now we have to do the mapping. Now open the ITEMDATA node and do the below mapping.

35.JPG

We have to add one more row as below and do the below mapping.

36.JPG

Now we have to press generate button to generate the run time objects.

37.JPG

To test the service open the selected node and double click and press the Gateway Client button.

38.JPG

And after providing the query as below and execute the requested query, we will get information like below.

39.JPG

Step 15: Now we have to do the ASSOCIATION , please provide the below details in the required input fields.

And in the required fields we have to provide below information.

Name

SalesOrderSalesOrderItems

Principal Entity

SalesOrder

Principal Entity Cardinality

1

Dependent Entity

SalesOrderItem

Dependent Entity Cardinality

M

40.JPG

Step 16: Now we have to create referential constraint for the association. To do so, please do the below, double click on the Referential Constraints.

And make a entry like below.

41.JPG

Now generate the project once again.

Step 17: Expand the node as below.

42.JPG

And double click on the Navigation Properties and do the below configuration.

Name

SalesOrderItems

Relationship Name

SalesOrderSalesOrderItems

43.JPG

Now re-generate the project and test with below query and get result as below.

44.JPG

Step 18: Now we will consume our OData service into SAP UI5 application.

Create one SAP UI5 Application and do the below coding in the view.

createContent : function(oController) {

var sServiceUrl = this.getUrl(“/sap/opu/odata/SAP/ZGW100_XX_SO_SRV”);

var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,true,“Service-User”,“Password”);

//Create an instance of the table control

var oTable2 = new sap.ui.table.Table({

title: “Table OData Example”,

visibleRowCount: 7,

firstVisibleRow: 3,

selectionMode: sap.ui.table.SelectionMode.Single,

navigationMode: sap.ui.table.NavigationMode.Paginator,

id:‘table1’

});

//Define the columns and the control templates to be used

oTable2.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: “So Id”}),

template: new sap.ui.commons.TextView().bindProperty(“text”, “SoId”)

}));

oTable2.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: “Currency Code”}),

template: new sap.ui.commons.TextView().bindProperty(“text”, “CurrencyCode”)

}));

oTable2.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: “Gross Amount”}),

template: new sap.ui.commons.TextView().bindProperty(“text”, “GrossAmount”)

}));

oTable2.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: “Net Amount”}),

template: new sap.ui.commons.TextView().bindProperty(“text”, “NetAmount”)

}));

oTable2.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: “Tax Amount”}),

template: new sap.ui.commons.TextView().bindProperty(“text”, “TaxAmount”)

}));

oTable2.setModel(oModel);

oTable2.bindRows(“/SalesOrderCollection”);

oTable2.placeAt(“content”);

}

getUrl : function(sUrl) {

   if (sUrl == “”)

return sUrl;

   if (window.location.hostname == “localhost”) {

return “proxy” + sUrl;

   } else {

return sUrl;

   }

}

Now we have to do few modification into web.xml file. Please add the below snippet of the xml tags into web.xml

45.JPG

<context-param>

<param-name>com.sap.ui5.proxy.REMOTE_LOCATION</param-name>

<param-value>http://<host of Gateway Server>:<port></param-value>

</context-param>


Now we have to run the application, to fetch the data from SAP ECC via OData in SAP UI5 application.

After run we will get screen like below.

46.JPG

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply