cancel
Showing results for 
Search instead for 
Did you mean: 

Read entitysets of odata-sources in sap ui5

Former Member
0 Kudos

Hi everybody,

i'm trying to learn how dynamically I can use OData in SAP UI5 Applications.
My scenario is the following: I have an unknown number of OData-Sources defined in manifest.json. I want to get the metadata of the sources and read all available entitysets to have them as a list in a table.

Example:

odata_srv1 has the entitysets "businesspartners" and "loans"

odata_srv2 has the entitysets "cars" and "bikes

the table I want to have:

bikes

businesspartners

cars

loans

I want a table that lists all the entitysets of the defined odata-services, no matter if there is one or five services defined. Is this even possible?
Is there a method to get the defined data-sources in the manifest.json? Is there a method to read the entitysets from the sources?

Thank you so much!
Sidney

Accepted Solutions (1)

Accepted Solutions (1)

former_member484715
Contributor
0 Kudos

Hi Sidney Weiher,

How are you reading your service data. Is it from the manifest or the component file or from the controller itself. In any case you can use the getServiceMetadata() method with your model reference object, or you can use the $metadata query parameter to access all your service metadata.

Former Member
0 Kudos

Hello Arjun,

i tried the getServiceMetadata and it worked, but i dont know how to instantiate the dataSources dynamically. they are defined in my manifest as destinations. is there something like a method "get all defined destinations from manifest"?

thanks for your help!

former_member484715
Contributor

Hi Sidney Weiher,

Could you try with :

this.getOwnerComponent().oModels  // inside your controller's init method

As per my experimentation, you get an object which contains all the models defined in your manifest file.

Hope this helps,

Regards.

Former Member

Thats what i needed. Thanks so much!

Answers (1)

Answers (1)

Joseph_BERTHE
Active Contributor
0 Kudos

You can read the metadata loaded from your services, then you will be able to look for entitisets (look at this Link)