cancel
Showing results for 
Search instead for 
Did you mean: 

adding entity set

Former Member
0 Kudos

Hi friends, actually i am new to odata and sap ui5.Can someone tell me how to add an entity set to an already existing odata service or url?

Accepted Solutions (1)

Accepted Solutions (1)

former_member184867
Active Contributor
0 Kudos

There are many possibilities, the option to choose for depends on your need. May be you can consider the following options to clarify your requirement. First You need to answer

1. You have an OData service, you want to add a new EntitySet in the same service

2. You have an OData service, you want to add a new EntitySet using this service and create a new OData service


If you have clarified the above questions, then consider the following

3. You have an OData service, you want to add a new EntitySet in the same service based on some existing Entity

4.You have an OData service, you want to add a new EntitySet in the same service based on a new entity

Now you need to think,

5. If you create a new service then do you need the same old OData service URL or you want a new URL(so that you do not need to change the Fiori OData service).

There may be more aspects to think that I may be missing here

Former Member
0 Kudos

Hi Atanu,

Thank you for answering.



In my scenario I have an OData service and i want to add a new EntitySet in the same service based on some existing Entity and i need the same old odata service url.


So is there some code that i have to write in my ui5 or should i make any changes in odata?


former_member184867
Active Contributor
0 Kudos

You can do it by using service builder. You need to go to the EntitySet node under the Data Model and create a new Entity set from the context menu option.

The other option can be to write code manually in the DEFINE method of Model Provider Extension class(*_MPC_EXT). The code may look like


Data:   lo_entity_type    TYPE REF TO /iwbep/if_mgw_odata_entity_typ,    

lo_entity_set     TYPE REF TO /iwbep/if_mgw_odata_entity_set.

SUPER->DEFINE( ).

lo_entity_type = model->get_entity_type( iv_entity_name = 'ENTITY NAME' ).

lo_entity_set = lo_entity_type->create_entity_set( 'NEW ENTITYSET NAME' ).

lo_entity_set->set_creatable( abap_false ).

lo_entity_set->set_updatable( abap_false ).

lo_entity_set->set_deletable( abap_false ).

lo_entity_set->set_pageable( abap_false ).

lo_entity_set->set_addressable( abap_false ).

lo_entity_set->set_has_ftxt_search( abap_false ).

lo_entity_set->set_subscribable( abap_false ).

lo_entity_set->set_filter_required( abap_false ).

You can also find similar code in the Model Provider Class.

However if you are using service Service Builder to create your service, then you need to directly write the code in the above mentioned code in  DEFINE method of the Model Provider Class.  In this case you need not write SUPER->DEFINE().

After you make the changes, you need to clear the metadata cache by transaction /IWBEP/CACHE_CLEANUP and /IWFND/CACHE_CLEANUP.

At this stage you will see the entity set in the $metadata.

However you need to write code in Data Provider class(or Data Provider Extension class) to provision data for the entityset.

Former Member
0 Kudos

Thank you Atanu.I got it using the above procedure

Answers (0)