on 06-03-2015 11:25 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
86 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.