Consuming API from SAP API Business Hub

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Consume the Purchase Order API from SAP API Business Hub

Consume the Purchase Order API from API Business Hub: Exercise Overview

Scenario

You will now enhance your prepared iFlow with purchase order data from the OData service provided via the SAP API Business Hub that was introduced in the previous lesson.

You will set a timer in order to request PO data each time the iFlow is deployed. This means that every time the iFlow runs, the PO data is retrieved via the OData API in the SAP API Business Hub.

Prerequisites

  • You have identified your Purchase Order API.
  • You have a running integration process.

Consume the Purchase Order API from SAP API Business Hub

Task 1: Consume the Purchase Order API From SAP API Business Hub

Steps

  1. Consume the Purchase Order API From SAP API Business Hub.

    1. In your browser, navigate back to theiFlow editor tab.

    2. Select Edit in the upper-right navigation bar if you are not already in edit mode.

    3. You can adjust and position your Integration Process pool box by selecting and then dragging and dropping with your mouse.

      Note
      You can do this throughout the modeling phase to accommodate additional process steps.
    4. Choose the Events menu and select the Timer.

    5. Click into the Integration Process pool box and position the Timer process step at the far left.

      Note
      You can display details of each process step by selecting it and then expanding the lower light blue colored information bar at the bottom right of the screen. You can also use this menu to collapse the detailed view.
    6. In the detailed view, you can change the name of your Timer in the General tab. In the Scheduler tab, you can set a particular schedule for messages. You can optionally change the name of your Timer, but make sure the Scheduler has Run Once selected.

    7. Choose Save on the top right to secure your progress.

      To successfully perform the API call, you will require an APIKey that is submitted via a message header.

    8. Choose the Message Transformers menu and select the Content Modifier.

    9. Click into the Integration Process pool box and position the Content Modifier next to theTimer process step.

    10. Select the Timer process step and connect it with the Content Modifier via drag and drop.

    11. Select the Content Modifier process step and change the name to Set APIKey header in the detailed information and configuration bar.

    12. Navigate to the Message Header tab, choose Add, and enter the APIKey you previously took note of.

      Note
      Providing the APIKey value directly is no problem in this case. However, imagine a productive setting where you are working with a development tenant and a productive tenant. In this case, it is important that you do not edit the integration content as this is bound to cause accidental errors with a potential slew of negative consequences, as well as a hefty time commitment to execute changes. Cloud Integration therefore offers the option to work with externalization in such a case. Externalization enables isolation of the business logic from the integration flow complexity, thus empowering even the business users to easily configure the flow. It is therefore very useful when you have to move your integration flows across tenants, because it enables you to modify the externalized parameters with tenant-specific details without editing the integration flow. You will now do so for the APIKey example.
    13. Choose Externalize to open the externalization editor. Delete the previous value for your APIKey and create a new parameter using the format {{<parameter_name>}}. When you move out of the field, a token is created in the value column of the new parameter.

    14. Choose token in the value column, which opens an Update Value dialog to provide a value for the parameter. Enter your APIKey as Default Value and choose OK.

    15. Choose OK to finish the externalization and Save to secure your progress.

      Result

      You will now be able to change the value of the APIKey via Configure without editing the iFlow itself.
    16. On the top menu, choose CallsExternal CallRequest Reply.

    17. Click into the Integration Process pool box and position the Request Reply next to theContent Modifier process step. Connect both by clicking on the Content Modifier and dragging the connector to the following process step.

    18. Add a Receiver by selecting theParticipant menu on the top of the screen.

    19. Position the Receiver outside of the Integration Process pool. Rename the Receiver as API_Business_Hub.

      Note
      While you are free in your naming choice, the Receiver Name cannot contain any whitespaces.
    20. Create a connection between Request Reply and Receiver, selecting OData → OData V2 as the connector type, since the API you are using delivers its message in OData format.

    21. In the configuration view of the OData connector, select the Connection tab. Enter the Request URL you previously took note of. Deselect the CSRF token fetch.

    22. Select the last part of the URL ("/A_PurchaseOrder"), delete it in the Connection tab, and enter it as the Resource Path in the Processing tab instead without the "/" at the beginning.

      Example

      To narrow down the query, enter the following parameters to the Query Options:

      Code snippet
      $select=PurchaseOrder,CompanyCode,PurchaseOrderType,PurchasingDocumentDeletionCode,PurchasingProcessingStatus,CreatedByUser,CreationDate,LastChangeDateTime,Supplier,PurchaseOrderSubtype,Language,PaymentTerms,CashDiscount1Days,CashDiscount2Days,NetPaymentDays,CashDiscount1Percent,CashDiscount2Percent,PurchasingOrganization,PurchasingDocumentOrigin,PurchasingGroup,PurchaseOrderDate,DocumentCurrency,ExchangeRate,ExchangeRateIsFixed,ValidityStartDate,ValidityEndDate,SupplierQuotationExternalID,SupplierRespSalesPersonName,SupplierPhoneNumber,SupplyingSupplier,SupplyingPlant,IncotermsClassification,CorrespncExternalReference,CorrespncInternalReference,InvoicingParty,ReleaseIsNotCompleted,PurchasingCompletenessStatus,IncotermsVersion,IncotermsLocation1,IncotermsLocation2,ManualSupplierAddressID,IsEndOfPurposeBlocked,AddressCityName,AddressFaxNumber,AddressHouseNumber,AddressName,AddressPostalCode,AddressStreetName,AddressPhoneNumber,AddressRegion,AddressCountry,AddressCorrespondenceLanguage&$filter=PurchaseOrder eq '4500000011'
      Copy code
      As previously indicated, you are now only requesting information concerning purchase order 4500000011. You could also make use of externalization here and provide the PO number as a parameter – the flow can then be easily configured to handle multiple different purchase orders.

    23. Enter APIKey as Request Header in the HEADER DETAILS and METADATA DETAILS sections.

    24. Choose Save on the top right to secure your progress.

      Note
      At the moment, you can not test this iFlow, because the required End Message event is missing. This will be added in the exercise: Configure Outbound Communication.

Result

You have now configured a connection to the SAP API Business Hub to get information about PO 4500000011. The call will be executed every time the iFlow is deployed due to the Timer process step.

Save progress to your learning plan by logging in or creating an account