0% found this document useful (0 votes)
427 views

Building A Gate Way Service Using A SEGW Transaction

This document provides steps to build a gateway service that reads data from a custom table using SEGW transactions in SAP. It involves creating remote function modules to query and read data from the custom table, generating a data model from the table structure, mapping the function modules to service implementations, generating classes, and registering the service. The service can then be called to return all data from the table or a single record by ID.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
427 views

Building A Gate Way Service Using A SEGW Transaction

This document provides steps to build a gateway service that reads data from a custom table using SEGW transactions in SAP. It involves creating remote function modules to query and read data from the custom table, generating a data model from the table structure, mapping the function modules to service implementations, generating classes, and registering the service. The service can then be called to return all data from the table or a single record by ID.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Building a gate way service using a SEGW transaction

In this example we see how to build a gateway service which reads data from custom table. Pre-requisites Create a custom table with sample data in it. In this example i used a custom table which is having below fields.

Create a remote Function module which reads the entire data in the custom table and exports it in a table. (Ex: ZGW_ADD_TAB_QUERY) Create another remote Function module which Exports single record from custom table based on ID. (Ex: ZGW_ADD_TAB_READ)

Function modules.docx

Procedure Login to the system in which SAP Net weaver gateway is installed and go to the transaction SEGW. Click on Create (1) to create a new project and provide the Project name and Description and Package name (2) I save it in local object here (3).

The result is as show below.

Now we have to create a data model, we can create a new data model or we can import it from 1. File 2. DDIC structure 3. RFC/BOR Interface

In this example we are using custom table so we are choosing DDIC structure

Give the table name and click on enter, we can see the structure of the table as shown below click on enter.

Now can see entity type and properties are created, double click on properties to see the properties details on the right side.

No we have to create Entity sets for the entity type which we created. Right click on Entity sets and click on create.

Provide the entity set name and give the Entity name which we created earlier (we can take F4 help) and click on enter.

Along with Entity sets we can see, service Implementations also got created.

Our requirement is reading data from Custom table so right click on GetEntity(Read) -> Map to Data Source.

Now a pop-up screen raises in which we need to provide the Remote Function module which was available (ZGW_ADD_TAB_READ) as shown in the below screen. Since the data is available in our LOCAL system we select local and select Remote Function Call from the drop down and provide the function module name and hit enter.

We can see the screen as shown below. Here we need to map the function module fields with our fields in the entity sets.

We can drag and drop the Data source Parameter from function module to Service Implementation. After mapping the result is as shown below.

Now repeat the same process to the GetEntityset(Query) and map it the field of Remote Function Module ZGW_ADD_TAB_QUERY and the result looks as below.

Up to here we have created Entity types and Entity sets and mapped them to the Respective Function Modules, Now it time to generate the required Class and methods to create the service. Save and select the project and click on Generate Button which u find on the top as shown below

A pop-up raises shown you the classes that are going to be created we can give our own naming convention here or else continue with the same. I saved it in local object.

We can see the in the Runtime Artifacts the classes which are got generated.

Note: if you follow the steps as it is you will get a error in the class ZCL_ZGATEWAY_TEST_DPC go to the class in SE24 check for syntax error and change the Attribute name to zint.

DATA zint4 TYPE int4. activate it again check for syntax errors and make changes as below DATA im_id TYPE zif_zgw_add_tab_read1=>zint4.

Now the service is created and we need to register it. Double click on Service Maintenance (It is GW_HUB in our local system I might differ in your system). Select the system and click on register.

In the pop-up click on yes, and the next screen looks as below, click on local object and continue.

Now you are back to the initial screen with green bulb glowing in it which means the service is registered. Now click on maintain.

You navigate to the Active and Maintain Services select the OData node and click on Call Browser or Gateway Client

Click on execute to see the entity type and entity set as result.

Edit the link as shown below and execute now you should see all the data in the custom table in XML format, which means out function module ZGW_ADD_TAB_QUERY is executed. /sap/opu/odata/sap/ZGATEWAY_TEST_SRV/Data now edit the link as shown below in the braces Im providing the ID, execute it to get the Data from cutom table with ID 3, which means out function module ZGW_ADD_TAB_READ is executed. /sap/opu/odata/sap/ZGATEWAY_TEST_SRV/Data (3)

You might also like