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”.
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
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