Transform GenIL objects into OData services – Fast and Easy!
OData Service – You must have heard the buzzword umpteen times. And, if that is so you also would be aware of all the benefits it boasts of – Ease of consumption, Industry standard, Open specification promise and many more.
The more important question, however, is how do you build one without going through the complexity or learning curve? Especially if you have worked with SAP Business Suite frameworks like GenIL / BOL, you already have the business logic wrapped in those Object Oriented APIs. While building your application you just want to access the business logic bundled in those APIs via an OData Service. Have you ever wondered, if it were possible to achieve this
ü With least knowledge about OData specification
ü Without the need to know, how and what to map between GenIL and OData
ü And to top it all, without writing a single line of code
Sounds unbelievingly amazing, right? Well then, without much ado, let me show you how you can do it!
SAP NetWeaver Gateway Service Builder – Redefine GenIL Wizard
Our latest offering from SAP NetWeaver Gateway, “Service Builder” (transaction “SEGW”) comes loaded with capabilities wit respect to developing OData services for SAP Business Suite Data. Overall introduction to service builder is available at (http://scn.sap.com/community/netweaver-gateway/blog/2012/09/07/the-new-gateway-service-builder-how-to-build-odata-services-from-sap-business-suite-data-in-3-quick-steps).
In order to create an OData Service directly from a GenIL object, you have to use the wizard “Redefine -> GenIL Service” from Service Builder tool. You can locate it in the context menu of “Project -> Data Model -> Redefine”.
Pre-requisite:
GenIL Integration with Gateway requires the following software components:
1. IW_GIL 100
2. IW_BEP 200 SP4
3. WEBCUIF 7.0 SP3(minimum release of WEBCUIF)
4. IW_FND 250(Gateway Hub) SP3
NOTE: Software components mentioned in point 1, 2 & 3 need to be deployed on the same system.
As you can see from the menu, in a similar fashion you can also generate an OData service directly from SPI framework (ABBIDs) or from BW (MDX and Easy Query). In this blog I will focus on GenIL.
Step 1 of Wizard: Select the GenIL component
I want to create an OData service for CRM Account. In the first step of the wizard I choose the GenIL component “SAMPLE” which contains Account object. An input value help lists all the GenIL components available locally in the system.
I choose Next.
Step 2 of Wizard: Generate OData service
Second step of the wizard prompts me to enter the Transport attributes and names for all runtime artifacts. I keep default name proposals derived from the project name and add service description.
When I choose next, in the background, the GenIL objects are transformed into corresponding OData artifacts. The metadata information is available in Model Provider Class whereas the runtime implementation is generated in Data Provider Class. This operation will consume some time. Model transformation is successful and in the next screen I see the OData model generated from SAMPLE GenIL component.
Step 3 of Wizard: Redefine the generated model
Details about the operations supported, mapping between GenIL and OData Model etc. can be found in the SAP Help Portal documentation.
In my service I want to only show basic details of Account and the related OrderPartners. So, in the 3rd screen, I chose entity Account from the entire tree. Also I have chosen association between Account and OrderPartner. I press Finish button.
A model gets created with selected entity, properties and associations. In addition the missing ends of association are also pulled in, in case they are not already selected. So even though I had chosen only Account, entity OrderPartner has also been added to the model along with its properties. Apart from this the related Entity Sets, Association Sets, Navigation Properties, Referential constraints are also added to the model.
In a nutshell, I provided minimum requirement in the form of Entity, Property and Association selection, whereas the tool programmatically created a complete OData model by calculating dependencies.
Step 4 (Optional): Redefine Names and Labels
Many a time the backend names which are automatically taken over to create Service are not very user friendly. In those cases developer can go ahead and change the name too. In addition labels can also be added to the artifacts.
At the end of Step 3 of wizard as mentioned above the model is created in service builder project. However, all the artifacts are in read-only mode. In order to enable edit functionality on Name and Label, I select the appropriate cell, or the row, or multiple rows and choose the Redefine button from toolbar at the top of mass edit view.
This will switch the selected cells to edit mode and I can enter a desirable name or label.
I can use the Undo button to undo my changes. In addition, Undo Identical button
will switch the cells which did not undergo any change into read-only mode again. This is especially helpful in mass operations. I save my changes.
Step 5: Register Service
Now that I am done with my changes I need to register once more the service since it has been redefined. In order to do this I select the Generate button from the main menu on top of navigation tree.
I get a pop-up dialog with name proposal for redefined MPC/DPC classes.
I see if I do not need to retain the original service created in Step 2 I can go ahead with Overwrite Option.
However, in my case I want to retain the original service which contains all the GenIL objects as a parent OData service and have different projections of it. So I uncheck the Overwrite box and give a new service name. Next time, when I have to create another service with a different set of fields from the same GenIL component, I can directly do it via Redefine -> GW Service.
Step 6: Service Activation
The last step remaining in this development process is to activate the registered service in Gateway Hub system. To do this I expand the Service Maintenance node. I see the list of GW Hub systems connected. I choose the only available system and click Register button.
Once my service is registered successfully, I can see the traffic light green.
My service is now ready to execute. I call the browser to see all collections are returned successfully. THAT’S IT!!!
So you see, I did not write a single line of code, and yet created a full-fledged working service in few clicks.
Redefine Gateway Service Wizard
Sometimes you are not done with your complete selection in the first attempt. In that case you can go ahead and extend your current model by adding artifacts from the same GenIL Component using this wizard.
The items you had previously added appear disabled to let you know what is already in.
Other Redefine Options
Apart from this there are two other options available for redefinition.
1. OData services from SAP Service Provider Infrastructure (SPI) framework– All the steps are same as GenIL. Details about prerequisites, mapping and constraints can be found in SAP Help Portal documentation
2. OData Services from SAP BW framework – Details about prerequisites, mapping and constraints can be found in SAP Help Portal documentation
Nice to see the GenIL redefinition available now in Gateway. I remember taking a class last year at Teched and asked about consumption of the GenIL layer and the instructor had told me that was not though of yet!
I'm glad to see this made available as for CRM the other options for building gateway services are not really that useful since we already had the BOL/GenIL built.
Take care,
Stephen
Wow, great post! makes everything sound much simpler!
Very good and helpful blog. Thanks for sharing 🙂
Interesting and very helpful.
Hi,
I'm looking for more info concerning odata services based on genil model since we will use it.
1) We can not create services from within the SEGW, but have to use /IWGIL/GENIL_SRV_GEN, losing the features mentioned in all blogs.
2) Is SAP further improving this solution ? Especially concerning the restrictions.
- not allowing the same entity multiple times. Maybe:
-> allowing to set 1 default
-> generate some kind of copies of entities, iin combination with the unique relation,so
they can be used multiple times
- CUD on non-root entities. Why not possible for the moment ?
- How to query dependent object ?
- How to use the test tool ( starting 'Gateway Client' from within /IWFND/MAINT_SERVICE ) for CUD (http request) ?
- Generate model based on Component Set instead of 1 Component only.
- Assign different queries based on an entity ? E.g. the BT component has many different queries which are object type dependent.
These are a few of my first concerns while trying to implement a solution.
Appreciate your help.
Kr,
Jan
Hi Jan,
For 1) the same transaction has been integrated into the "Redefine" command I described here. So it is the same functionality that you get.
2) You cannot have 2 same entities in the data model definition, and that is OData specification. I think what you need is 2 different entity sets on the defined entity type in order to achieve your use case. Kindly read the CSDL & spec document for OData v2 from www.odata.org
How do I map import parameters like max_hits?
Hi Robbe,
MAX_HITS can be provided as $top option in the query. Ex - "...?$top=20". Internally, $top value is taken in the max_hits query parameter.
For other import parameters, you can use $filter system query option.The attributes with the identical names in the query attribute structure and the root/access object attribute structure are marked as "filterable" in the metadata. So, only the properties which are filterable, can be passed in the query.
Best regards,
Aakash
Very helpful and blog/post, thanks for sharing.
Warm Regards
Hemendra
Hi Suparna,
Thanks for a very useful Post.
I have a question, what to do if the option 'GENIL' is not present under Redfine menu?
I checked with IT and they assured that all the components are installed on the server and rather are part of NW740 SAP_BASIS.
Still when I check in the system, neither the Transaction mentioned above, /IWGIL/GENIL_SRV_GEN, nor the Redefine option is available in the system. Is there some Switch to be activated for this feature.
I am trying to test this in the CRM Infinity landscape, i.e. AG3 system.
Any tips would be helpful.
Cheers,
Sumit