Skip to Content

Call an External API and Parse the Response in SAP BTP ABAP Environment

Requires Customer/Partner License
Call an external API SAP BTP ABAP Environment and parse the response using JSON or XML
You will learn
  • How to connect to an external RESTful API, in this case the Overpass street map service:, by creating the necessary communication artifacts
  • How to work with HTTP requests in your ABAP code
  • How to query the service
  • How to parse the information in an ABAP class using either JSON and SAP’s XCO Library or using XML and a simple transformation
  • How to create an executable class and display the output in the ABAP console


This tutorial enables you to work with data from an external RESTful API in your ABAP applications.

Throughout this tutorial, object names include the suffix 000. Always replace this with your group number or initials.

This tutorial was written for SAP BTP ABAP Environment. However, you should also be able to use it in SAP S/4HANA Cloud Environment in the same way.

  • Step 1
    1. In ABAP Development Tools (ADT), select your ABAP Cloud Project and choose New > ABAP Package from the context menu.

    2. Enter the following and choose Next:

      • Name = Z_API_OVERPASS_000
      • Description = Get map data using Overpass map service API
      • Add to favorite packages = Yes
      • Package type = Development
    3. Choose Create new transport request, enter a description, such as Get data from API Overpass, then choose Finish.

  • Step 2
    1. Select your ABAP package and choose New > Other Repository Object from the context menu; then enter Outbound Service, then choose Next.

    2. Enter the following and choose Next.

      • Outbound service: Z_API_OVERPASS_OB_000
      • Description: Get data from Overpass map service
      • Service type: HTTP Service
    3. Choose the transport request you just created, then choose Finish.

      The outbound service appears.

    4. Enter the Default Path Prefix /api/interpreter.

    5. Choose Save (Ctrl + S).

  • Step 3
    1. Again, choose New > Other Repository Object from the context menu; then enter Communication Scenario.

    2. Enter the following and choose Next.

      • Name: Z_API_OVERPASS_CSCEN_000
      • Description: Communication Scenario: Get data from Overpass map service
    3. Choose the transport request you just created, then choose Finish.

      The communication scenario appears in a new editor. Ensure the following have been entered:

      • Communication Scenario Type: Customer Managed
      • Allowed Instances: One instance per client
    4. On the Outbound tab, ensure that the authentication method Unauthenticated ticked.

    5. Add your outbound service, by choosing Add….

    6. Choose Browse, choose your outbound service, Z_API_OVERPASS_OB_000, then choose Finish.

      The suffix REST has added to the outbound service name automatically.

    7. Finally, Save your communication scenario, then choose Publish Locally.

  • Step 4

    Now, you need to create the necessary communication artifacts in Fiori Launchpad, starting with the Communication System. This artifact specifies hostname and port of the targeted remote API.

    1. In the Fiori Launchpad home page, choose Communication System, then choose New.

    2. Enter the following and choose Create.

      • System ID: Z_OVERPASS_000_CSYS
      • System Name: Z_OVERPASS_000_CSYS
    3. Enter host name:

    4. Under Users for Outbound Communication, enter the option None.

    5. Leave the other default settings as they are and choose Save.

  • Step 5

    A communication arrangement establishes a specific communication route by combining one communication scenario and one communication system.

    1. Go back to the Fiori Launchpad home page and choose Communication Arrangement, then choose New.

    2. Browse to, then select your Communication Scenario, Z_API_OVERPASS_CSCEN_000 (created in ADT). The Communication Arrangement name is filled automatically.



    3. In the main editor, select the Communication System, Z_OVERPASS_000_CSYS.
      The Service URL, port etc are filled automatically.



    4. Choose Save.
      You can now check the connection.



  • Step 6
  • Step 7

    Now, you will create an ABAP class that will call your destination, and which you can run in the console.

    1. Select your package and choose New > ABAP Class from the context menu.

    2. Enter the following for your class and choose Next. Remember to change 000 to your group number.

      • Name: ZCL_OVERPASS_XML_000
      • Description: Get map data using Overpass + XML
      • Interfaces: IF_OO_ADT_CLASSRUN (using Add…)
    3. Choose or create a transport request, then choose Finish.

    The skeleton class is displayed in a new editor.

  • Step 8
  • Step 9
    1. Check your syntax (Ctrl+F2).

    2. Format (Ctrl+F1), save (Ctrl+S) and activate (Ctrl+F3) your class.

  • Step 10

    Run your class in the console (F9). The output should look something like this.

  • Step 11

    When working with ABAP for Cloud Development, what do you use to parse XML into ABAP data (and vice versa)?

  • Step 12

    Where is the target host name for an outbound HTTP call maintained?

Back to top