Jul 30

SAP NetWeaver Gateway : A Step-by-Step Guide for Beginners

By Guest Blogger Kenny Sutherland, SAP Technical Intern, DataXstream

In three-tier architecture, SAP Gateways make up the middle or application tier. This middle layer is essential for communication between the frontend and the backend. The use of multi-tier architecture to implement a data processing system adds a valuable level of modularity and flexibility to the system by being able to develop and maintain each tier individually.  The purpose of this tutorial is to create a Gateway that will extract data from the flight carrier database table, which will be accessed from the Gateway Client. The Gateway will be able to retrieve a list of carriers as well as individual carriers.  Let’s get started…

Creating a New Project

  • First, navigate to the Gateway Service Builder with the T-Code “SEGW”
  • Click the “Create Project” button

Screen Shot 2015-07-07 at 3.42.25 PM

  •  Give the Gateway project a name and a description
  • Save the project and assign it to the appropriate package. For the purpose of this demo the project will be saved as a local object ($TMP or click the button “Local Object). The Gateway project has now been successfully created

Screen Shot 2015-07-09 at 4.18.25 PM

Creating an Entity & Entity Set

  • What is an Entity and Entity Set?
  • An Entity is a structure that can be defined by the user or defined as an ABAP Data Dictionary structure.  An Entity Set is simply a collection or table of Entities.
  • Right click Data Model and select “Import” -> “DDIC Structure” to use an ABAP Data Dictionary structure

Screen Shot 2015-07-07 at 3.30.20 PM

  • Type “SCARR” for ABAP Structure and press enter. A list of properties should appear
  • Make “Carrier” the object name for the entity
  • Change the “Usage” of the property “MANDT” to “Ignore” and click the check mark at the bottom right


  • Double click the folder “Entity Sets”
  • Click “Insert Row” and name the Entity Set

Screen Shot 2015-07-07 at 3.42.25 PM

  • The naming convention is to either make the Entity Set name the plural form of the name of the entity or append “_Set” to the Entity name. For training purposes, name the entity set “Carriers” or “Carrier_Set”. “Carriers” will be used for the remainder of this tutorial
  • Use the Entity name, “Carrier”, for “Entity Type Name”. Make sure to save and the Entity and corresponding Entity Set have successfully created

Screen Shot 2015-07-07 at 3.47.51 PM

How to Generate ABAP Classes

  • Click on the “Generate Runtime Objects” button towards the top left of the IDE

Screen Shot 2015-07-07 at 3.40.44 PM

How to Activate Gateway Service

  • Navigate to the “Activate and Maintain Services” page, “/iwfnd/maint_service”, and click “Add Service”

Screen Shot 2015-07-09 at 9.47.43 AM

  • Set System Alias to “LOCAL” and Technical Service Name to the name of the Gateway

Screen Shot 2015-07-09 at 9.49.04 AM

  • Click “Local Object” and then the check button to save

Screen Shot 2015-07-09 at 9.52.08 AM

  • Go back to the “Activate and Maintain Services” page, click on the service name, and click on “Gateway Client”

Screen Shot 2015-07-09 at 10.08.45 AM

  • To test the service, verify the “HTTP Method” is set to “GET” and then click “Execute”. There should now be some auto-generated XML

Screen Shot 2015-07-09 at 10.22.04 AM

  • In order to view the entity and its properties add a URI option to the end of the URI. Click “Add URI Option” and use “$metadata” and “sap-ds-debug=true”

Screen Shot 2015-07-09 at 10.23.05 AM

  • Now we can see the Entity Type as well as its properties

Screen Shot 2015-07-09 at 10.25.49 AM

Congratulations! You have made a usable Gateway Service. Now the backend functionality of the Gateway must be coded in order to make it useful.

Implementing GetEntitySet

  • Navigate back to the gateway service builder, expand the “Service Implementation” folder, and expand the entity set. There will be a few auto-generated methods
  • Right click “GetEntitySet”, click “Go to ABAP Workbench”, and ignore the popup that follows. This will take bring up the Class Builder

Screen Shot 2015-07-09 at 10.34.41 AM

  • In the left menu, expand the “Methods” folder, right click on the “GET_ENTITYSET” method, and select “Redefine”

Screen Shot 2015-07-09 at 10.38.09 AM

  • Under “Signature”, what the method is exporting to the frontend service can be seen, “ET_ENTITYSET”. This exporting table needs to be populated with data from the backend database
  • It is generally bad practice to select all the records from a database table because it can be extremely inefficient and redundant so instead of using “SELECT *”, only select the first 100 records from the database using the following statement…
  • Activate the method
  • To debug this code, set an external breakpoint. Session breakpoints will not work using the Gateway Client. Now the method needs to be tested

Screen Shot 2015-07-09 at 10.55.42 AM

Testing GetEntitySet

  • Reenter the “Activate and Maintain Services” or if it is already in a window click “Refresh Catalog”
  • Open the service again using the Gateway Client
  • Append the name of the Entity Set to the end of the URI, verify “HTTP Method” is set to “GET”, and execute. There should now be multiple Carrier entries

Implementing GetEntity

  • To get an individual Carrier, the Get_Entity method must be implemented
  • In the Class Builder, right click CARRIERS_GET_ENTITY and select “Redefine”
  • Add the following code,
“DATA: ls_key_tab LIKE LINE OF it_key_tab.     READ TABLE it_key_tab INTO ls_key_tab WITH KEY name = 'Carrid'.     SELECT SINGLE carrid carrname currcode url FROM scarr       INTO CORRESPONDING FIELDS OF er_entity       WHERE carrid = ls_key_tab-value.”
  • The above code will select a Carrier using the Carrid that will be passed into the URI
  • Activate this method and open the Gateway Client one more time
  • Make sure HTTP Method is “GET”, type “/sap/opu/odata/sap/Z_GATEWAY_DEMO_SRV/Carriers(‘AF’)” for the URI, and press execute
  • There should now be an individual Carrier using the Carrid that was just passed in the URI


Congratulations! You have made your first Gateway Service.

Kenny Sutherland is a current Christopher Newport University student working towards a degree in Information Systems.

This summer, Kenny is focused on an individual learning assignment under the direction of a senior consultant that deals directly with DataXstream’s OMS+ Solution software. His work primarily focuses on the back-end payment functionality of OMS+. Kenny is showing true leadership skills and DataXstream is proud to extend an offer for full-time employment upon completion of his studies at CNU. Kenny brings a lot to the table, including skills in JavaScript, HTML, and several other programming languages. He recently took home first place at CNU’s Software Fair!

We welcome prospective interns to contact us about starting your journey at DataXstream!

Visit our Jobs page or email our Director of Human Resources chibbard@dataxstream.com for more information.


Cassandra Hibbard Podskalny

About The Author

Marketing & Human Resources


  1. Avatar
    July 27, 2017 at 11:46 pm · Reply

    Thanks a lot Cassandra.You made it so simple 🙂

  2. Avatar
    September 24, 2018 at 5:36 am · Reply

    Great Post. The information provided is of great use as I got to learn new things. Keep Blogging.

    • Avatar
      Kaelibeth Caviness
      December 4, 2018 at 11:19 am · Reply

      We’re so glad we could help you expand your knowledge, thanks for reading!

Leave a reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.