Search

API Flow’s advanced features

Business Problem

What about if your Purchase Order Lines have a different currency compared to the financial system? With API Flow’s advanced features, API gateway, and ION we can create a solution that solves this problem.


Components

Requirements

  • Access to ION API Gateway
    • Security role: IONAPI-Administrator
    • Security role: IONAPI-User
  • Knowledge of API Flow (loop)
  • Knowledge of Python for scripting
  • Knowledge of the module ION Connect

Tutorial

In the real world, we need to integrate different systems with each other, using different technologies to send data to and receive data from, but also the data must be integrated and they need to be managed. Let’s consider the integration between two different systems using different currencies. Using ION components we can achieve this goal in a few steps. See the below solution.

In this integration flow, three connection points (1,3,5), one scripting step (2), and one data merge step (4)

  1. A purchase Order is created by a procurement application and sent to Infor OS ION.
  2. XML to JSON (scripting) convert BOD to JSON object
  3. Exchange Rate (API Flow) converts the PO lines amount into a different currency
  4. Merge (replaces the amount in currency produced by the API Flow
  5. IngestToDataLake (writes the BOD with the new currency values into DataLake

The focal point is the connection point number (3) the API connection point that invokes an endpoint created with the API Flow.

API Flow with do while component to iterate through the PO Lines

The API Flow is composed of Request and Response configuration where you specify the Input and Output format. As input, we have the Purchase Order BOD definition in JSON format, and as output, we have an array of the converted amounts for the Purchase Order Lines.

The first component in the flow is a JQ transformation that returns an array of amounts for each Purchase Order Line provided as input.

if .SyncPurchaseOrder.DataArea.PurchaseOrder.PurchaseOrderLine|type=="array" then .SyncPurchaseOrder.DataArea.PurchaseOrder.PurchaseOrderLine |[.[].TotalAmount] else .SyncPurchaseOrder.DataArea.PurchaseOrder.PurchaseOrderLine |[.TotalAmount] end 

You can use this site https://jqplay.org/ for testing the JQ transformation.

The output of the JQ transformation is passed as input to the do-while flow that is formed by two steps, one more JQ transformation, and one API connector.

The JQ transformation (Objects) takes one element at a time from the received array and passes it to the API connector that invokes the Exchange Rate (Rate) endpoint for converting the amount into a different currency.

This is the output from the previous step,

{
"input": "${LineAmounts.output}",
"iterator": "${DoWhile1.output}.iteration"
}

that produce this result

[
  {
    "@currencyID": "AUD",
    "#text": "4000"
  },
  {
    "@currencyID": "AUD",
    "#text": "5000"
  }
]

and this is the JQ transformation to take one element of the array at a time,

 .input[.iterator - 1]

for each element of the array, you take the currency value and the text value which is the amount of the PO line and you pass it as input to the Exchange Rate API.

The result is passed to another JQ transformation step that collects all results of the API call and sent them to the Output of the API Flow.

The Output contains an array of amounts converted in the currency specified in the Exchange Rate API call.

{"extractedOutput":[
{"amount":4000,
 "base":"AUD",
 "date":"2022-09-23",
 "rates":{"EUR":2697.69}},
{"amount":5000,
 "base":"AUD",
 "date":"2022-09-23",
 "rates":{"EUR":3372}
}
]}

The output of the API Flow, plus the original Purchase Order BOD are passed to the merge component, which uses an advanced merge type (scripting) to replace the original amounts value of the PO Lines with the value of the converted amount coming from the API flow results, producing a Purchase Order BOD with the PO Lines amounts converted in the new currency values.

The result of the merge flow is passed to the data lake ingest component that writes the BOD in Atlas.

This concludes the solution, see the below section for downloading resources.

Downloads