Skip to Content

Save, Filter and Get your needed data in your Integration Flow

Boost your Integration Suite skills leveraging different tasks to store and filter messages travelling through your Integration Flow.
You will learn
  • How to store, get and filter data to prepare your payload for specific request calls within the Integration Flow.
mariajosesapMariajose MartinezNovember 21, 2022
Created by
mariajosesap
October 28, 2022
Contributors
mariajosesap

Prerequisites

  • Step 1
    1. As SAP Cloud Integration works with XML and the expected payload from Open Connector/Stripe is in JSON, you need to add a JSON to XML converter in order to store the initial payload from SAP Build Apps in CPI and retrieve it when the payment transaction is successfully done.

    2. Uncheck the “Add XML Root Element” box. You’ll use the payload with the root as it comes.

      Adding the JSON to XML Converter
    3. Add a Write task to store the initial payload you are going to send from SAP Build Apps. Select it from the cube “Persistence” and “Data Store Operations”.

      Write Task
    4. Add the following:

      • Data Store Name: AppGyverSavedPayload
      • Visibility: Integration Flow
      • Entry ID: message1
      • Retention Threshold for Alerting (in days): reduce it to 1 day.
      • Expiration Period (in days): reduce it to 2 days.
      • Uncheck the “Encrypt Stored Message” box. For this exercise you are not going to encrypt the message.
        Write Task
    5. Add a “Filter” task. This is needed to only send the payment data to stripe.

    6. Add this Xpath Expression in the Processing Tab: /AppGyverSalesOrder/paymentData and select Nodelist as the Valuetype. It is needed to select Nodelist as there is a list in the main payload:

      JSON
      Copy
      {
      "AppGyverSalesOrder": {
          "customer": {
          "ObjectID": "<Object ID from SAP C4C>",
          "BuyerPartyID": <BuyerPartyID from SAP C4C>
          },
          "paymentData": {
          "amount": <Payment transaction amount to be processed in Stripe>,
          "customer": "<stripe customer id>",
          "currency": "<currency selected in stripe account>",
          "source": "<card id>",
          "description": "Test payment via CPI"
          },
          "product": [
          {
              "ProductID": "<Product ID from SAP C4C>",
              "Quantity": <Product quantity to be purchased>
          }
          ]
      }
      }
      

      Note: Bear in mind that the “customer” and “product” objects are included as part of the whole scenario. You’ll need them for requesting SAP Sales and Service Core a sales order creation, which you’ll see in the next tutorial.

      It should look like this:

      Filter Task
    7. Add a XML to JSON converter. Stripe needs a JSON object to create the payment transaction. Make sure you select UTF-8 as the JSON Output Encoding, and check the box “Suppress JSON Root Element”, this is important to be able to enter the data inside the XPath Expression without the “parent” root:

      XML to JSON Converter
  • Step 2
    1. Test on Postman and check the payment transaction is still working, use the Payload structure as it is above, just change it to your data. You should be able to generate the payment transaction.

      Testing it with Postman
    2. Go back to Monitor. Remember you need to enable first the Trace option. Check the trace:

      Checking the trace
  • Step 3
    1. Add a Get task to retrieve the initial payload. You have to put the same name and entry ID as you did in the Write task. Check the “Delete On Completion” box, to delete the stored message when the Integration Flow transaction is completed.
      Get Task

      You can test again if you want to, you should see the whole initial payload as it was saved with the Write task.

      Remember to activate the Trace log after deploying your IFlow. Go to the Monitor Message Processing and Trace.

      Log the trace

    Now, you have successfully retrieve the initial payload using Write and Get task, plus learnt how to filter data using Filter task and XPath expressions.

    Following the Tutorial Series, you now need to configure the SAP Sales and Service Core API consumption to create Sales Orders. For this step, check out the next tutorial: Consume a SAP Sales and Service Core API to create Sales Orders using SAP Cloud Integration.

  • Step 4

    Which of the following tasks work for storing data for later consumption in the Integration Flow?

Back to top