cancel
Showing results for 
Search instead for 
Did you mean: 

Odata to tree SAPUI5

ibrahimhassan
Explorer
0 Kudos

Hello everyone,

I have a requirement to display the company hierarchy in SAPUI5 from SAP back end, in addition the sub items should be lazy loaded by calling the odata service because of the performance issues, i.e only when the user clicks on the expand the sub items will be loaded,...

So could you please give me some hints or idea on how the model Odata(NW gateway) and also  the binding to a TreeTable (SAPUI5).

Best Regards

Mohamed

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Mohamed,

Since u say there would be large data when u try to get all the company hierarchy related details and it might hamper the performance, for this below would be my suggestions as per my knowledge.


Just an example:

Have a single service with different entities which can get all ur sub item details and list of company codes as well.

1. Have Parent Entity say CompanyData which will hold company code. May be we can call this as header details of the company.

2. Have Child Entity say CompSub1 which will hold your 1st child info ( ur 1st sub node data )

3. Have Child Entity say CompSub2 which will hold your 2nd child node ( ur 2nd sub node data )

4. Create entity sets for all the entity types.

Create Association & Navigation between the entities as per ur needs.

Fire the service as below :

Initially u can display all the company codes :

URL :

/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet ( this would just list all the company codes with out sub node details )

When the user clicks on sub node say he click on a sub node to get data related to CompSub1

( ur 1st sub node data ). Then fire the service as Below :

URL :

/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet(CompCode='0100')?$expand=SubNode1 ( this would just get sub node 1 data alone )

Where SubNode1 is the navigation property.

When the user clicks on sub node say he click on a sub node to get data related to CompSub2

( ur 2nd sub node data ). Then fire the service as Below :

URL :

/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet(CompCode='0100')?$expand=SubNode2 ( this would just get sub node 2 data alone )

Where SubNode2 is the navigation property.

If at all U need both sub node 1 and sub node 2 data in one go then fire as below :

URL :

/sap/opu/odata/sap/SampleServiceCompCode/CompanyDataSet(CompCode='0100')?$expand=SubNode1,SubNode2 ( this would just both node 1 & node 2 details )

This way u can use a single service and fetch item level data as when its required as above example.

U can also use filters as well to pass inputs and achieve the same depending on ur use case.

Please refer :

Expand in Framework and Data Provider - SAP NetWeaver Gateway - SAP Library

U can also use Expand functionality by just implementing Get_Entity and Get_Entity_Set as well.

The above is just an example for a sample scenario.

Its all depends the use case and logic we use for a use case.

Regards,

Ashwin

ibrahimhassan
Explorer
0 Kudos

Hi Ashwin,

thanks alot for your Input.

I managed to achieve this requirment by implementing the get_entityset and i used a json string as importing Parameter. the json string is actually a table and it contains the node that is expanded.

the return of the entityset is a flat table but has the tree structure (object id and parent id).

in the JavaScript side  I converted the table to tree Array and did the binding.

in this way the first call will have an empty Parameter so it will have the root and the first Level. when the user expands one node i will get the node Id and send it to Odata and the Service will generat the table again.

Hope it helps

Best regards

Mohamed

former_member204167
Participant
0 Kudos

Hi Mohamed,

how did you get around the issue that the sap.ui.table.TreeTable only renders a "expand" icon in the tree if at least on child exists?

Regards

Tobias

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Mohamed,

Did you find a solution for this yet? We have a similar scenario.

Regards,

Sanjaya