OData and SAP Netweaver Gateway. Part II. Create your first OData Service |In the Part I post Introduction to SAP Netweaver Gateway and OData, we learned about the definition, terminologies and concept of SAP Netweaver Gateway, OData and HTTPs. Now we have a fair idea of the RESTful and STATEless concept. In this article, we will do a hands- on exercise and generate our first OData Service in SAP and play around with the different URIs of the service. These URIs are the endpoints of Server side of OData which the outside world (Client side) would need to call using HTTP(s) in order to update/extract data to/from SAP. In SAPUI5 applications, we need to consume these URIs to connect to SAP and play with its data. We will re- define the standard methods and add our custom ABAP logic to meet our requirements. A. Define Data Model. Go to t- code SEGW (SAP Gateway Service Builder). Remember it like SE3. Instead of 3. 8, add GW for Gate. Way. So our friendly t- code for today’s topic is SEGW. Hit the Create Icon and provide the name of the Project, description and package (or local) and save it. The project gets created with four folders, namely Data Model, Service Implementation, Runtime Artifacts and Service Maintenance. Please take note that Data Model further has three sub- folders viz Entity Types, Associations and Entity Sets. All the folders are empty by default. Before you ask yourself, what is Entity Types and Entity Sets, let me answer it quickly. After all, SAPYard is here to hand hold you and help you cross this SAP Gateway learning curve smoothly. Entity Type is our very own structure (or a work area (holds just one row)). And you guessed it right, Entity Set is an internal table (holds more than one entity/rows). ABAPers, are you gaining confidence? You just learned two new terms. Let us create our first structure; oops!! Entity Type (right term in Gateway terminology). Right click on Entity Types folder and select “Create”, provide the name you like and do not forget to tick the checkbox “Create Related Entity Set”. Diese Sammlung von gut 500 Funktionsbausteinen ist eine Mischung aus Funktionsbausteinen, die sich in der eigenen Programmiererpraxis bewährt haben und aus den. Uploading a PDF file in an Adobe Form offline scenario. By Phani Diwakar, YASH Technologies. This document provides the idea of how to upload the PDF file data into SAP. For our example, POHeader is the structure(work area) while POHeader. Set is our internal table. Check the Service Implementation folder has POHeader. Set Operations auto generated. These are ABAP Methods which would be triggered when the relevant endpoints would be called. Now we need to define the fields of the structure/work area and internal table. Doble click on the Properties folder, hit the create icon and then start adding the field names and the type and length. In the example, we have added Ebeln and Bukrs. So on and so forth, we need to build our Entity Type. Also Read: SAP HANA from Space Level. Doesn’t it look too tiresome to add one field at a time in the Entity Type? There has to be a better way. The above steps are just to let you know such thing exists. In real projects, you would like to use the below method. Delete the POHeader Entity Type and POHeader. Set Entity Set by right clicking and hitting delete. Let us create them again. Right click on the Data Model folder and Import the DDIC Structure. Give the Entity Type name and ABAP structure whose fields you want to import to your Entity Type. Do not forget to click the checkbox for Entity Set (unless you are sure you will not need an internal table). Hit Next and choose the fields from EKKO (our example) structures which you want to add to your Entity Type. Next, choose the Key for your structure/entity type and entity set. For our example it is Ebeln. After you hit finish hit the save button and check the Properties and Service Implementation folder. They would have the structure and operations respectively. At this point, let us import one more Entity Type called POItem from EKPO using the steps just mentioned above. From the above image, it is clear that every Entity Types will have its own Properties and Navigation Properties Folder. And every Service Implementation Entity Set will have its own Operations (Create, Get. Entity, Update, Delete etc). As of now, we have a Header Table and an Item/Detail Table. Let us assume we do not need any more Entity Types. B. Implement/Register the Service. Let us go ahead and generate and register our service. Hit the Generate icon and hit ok. Provide the package and transport number or save it as local. You should get the success message as shown below. Please note the Technical Service Name is the actual Service which the external system needs to call. Two classes, Model Provider Class (MPC) and Data Provider Class (DPC) are also generated along with Base and Extended Class. Model Provider Class inherits from /IWBEP/CL_MGW_ABS_MODEL and Data Provider Class inherits from /IWBEP/CL_MGW_ABS_DATA. The below image shows the relationship between the generated classes and their superclasses (parents). FYI: Data Provider Class provides the Gateway Service functionalities. Model Provider Class defines the Gateway Service interface. DPC and MPC are not connected by any coding. They talk to each other via Configuration. C. Add Service to Service Catalog (Register the Service to Gateway Hub)We have implemented the Service, now we need to add the service to the Service Catalog. Most of the tutorial present on the internet shows that the Service Maintenance folder would have an entry with System details and the Register/Maintain buttons are active (as in above image). If you see an entry in Service Maintenace folder, it means your system has “Embedded Deployment“. SAP Netweaver gateway components are installed as add- ons on the SAP backend system itself in the Embedded Deployment option. Both the OData modeling and the exposing of the Services to the outer world is done from the backend system. The advantage of Embedded Deployment Strategy: i. Saves cost as there is no need of any dedicated Gateway Hubii. It is faster as the runtime overhead due to remote calls in case of two separate systems (separate front end and back end) is avoided. Disadvantages of Embedded Deployment Strategy: i. There is no single point connection to the backend via Gateway Hub; instead, back end system is directly exposed to the outer world (consumers), so better security measures need to be in placeii. Back end system upgrade would follow a different cycle than Netweaver Gatewayiii. If the landscape has multiple SAP Business Suite backend, then each system needs to have its own installation and configuration of Netweaver Gateway components. If you have Embedded System, hit the Register and Maintain buttons and you are good. The above image is not from our sap system. Our system does not show any entry in Service Maintenance folder. Our architecture is “Hub Deployment with Development in the Backend System“. In this strategy, the SAP Netweaver Gateway is installed on separate SAP machine called as Gateway Hub. Gateway Hub would be the window for the outer world to SAP. Gateway Hub would register and expose the OData Services, but the development would still happen in the SAP backend system. The advantage of Hub Deployment with Development in the Backend System Strategy: i. Better security as it has only one point of access to SAP Backend system for outer space via Gateway Hubii. Although Gateway components are in different SAP system, it still has direct access to Backend DDIC and business data for OData Model/Servicesiii. Gateway Hub can be in advanced newer version NW 7. Backend still can be in the lower release. Gateway on new release would support SAPUI5. Disadvantage: More cost and maintenance effort along with the runtime overhead due to remote calls. Coming back to our screen. We are in our Backend system, therefore by default, we do not get the option to maintain and register our service in our backend system. We need to go to our front end system where we have the Netweaver Gateway i. Gateway Hub. Go to your Gateway Hub (Front- end system) and execute t- code /n/IWFND/MAINT_SERVICE. Save this t- code in your favorite list or remember it by heart. You will need it for all your OData services. Our service is still not added to the Service Catalog. After we add the service to the Service Catalog, only then is our service available for the outer world to access. Hit the Add Service button, provide your backend system alias and external service name (our case ZGW_PO_SRV). You will get the service you created in the backend. Click on it and it would show the Service (technical/external) name along with the Technical name of the Model (ZGW_PO_MDL) and hit save. Go back to the Service Catalog screen. Find your service, click on it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2018
Categories |