In this use case, we want to transfer Amazon MWS Orders into SAP ByDesign Orders. Our aim is to have all information about the orders found in Amazon MWS to be in SAP ByDesign.
Why is this use case interesting?
This case is interesting since Amazon MWS API gives answers in some certain ways:
- When we query the list of orders from Amazon MWS we get only information about orders such as IDs, the total amount of orders, shipping information, etc. But this answer does not include information about specific items included in those orders.
- To get items we need to store the order IDs and then use them to query the items belonging to those orders.
- Then we need to combine both: orders and items together to store this information into SAP ByDesign.
The above-presented scenario can be addressed in two ways: One way is to use several flows (using the sequential mechanism) and make use of external ID to pass the information gradually or using the passthrough to aggregate all the information on-the-fly.
- Using only sequential mechanism
- Solving the dilemma with passthrough
Using only sequential mechanism
The challenge with this scenario is that when we query any list of orders (
listOrders) at Amazon MWS side we get the information (such us IDs, the total amount of orders, shipping information, etc) for orders only not the particular items listed in those orders. To get items we need to query Amazon MWS using the specific order IDs (
listOrderItems). So, without getting order IDs we can't get information about order items.
To address this dilemma in these two functions were included in Amazon MWS component in the past. Meaning it was doing first
listOrders and storing this information then using
listOrderItems to get the items per each order and only then passing this information to SAP ByDesign. However, this complexity of queries is error prone and less scalable.
One could separate those functions and create two integration flows to address this sequentially. Meaning:
- Create one flow with
listOrdersand bring all the information to SAP ByDesign. Record it there and get an ID.
- Use the recorded ID as an External ID in the second flow to match those order IDs with
listOrderItemsand again bring the information about specific items by each order back to SAP ByDesign.
This solution is much better but still, there are problems of synchronisation between these two flows which we usually solve with Rebounds. Meaning, the system tries to get the external IDs of those orders before asking for items. If the IDs are still not there it will try again later and later. However, there is always a limit on how many times the system can try and that many connections can fail if one end of integration reports a timeout.
We need a solution which is less likely to fail and does it in one go!Solution to this dilemma is provided by the passthrough feature.
Solving the dilemma with passthrough
With an introduction of passthrough feature, this scenario of Amazon Orders to SAP ByDesign Orders is very easy to address. For starters, we can now separate
listOrderItems into two separate functions and yet use them in one go without worrying about losing any information along the line of integration flow. Here is the overal integration flow:
In short: we are going to query Amazon MWS to
listOrders, then use the same IDs to query
listOrderItems and then we are going to combine the results (content enrichment) and transfer it to SAP ByDesign Order (
The first trigger of Amazon MWS
listOrders is pretty straightforward, we choose the type of orders from the list and proceed further. This stage does include choosing your appropriate Amazon MWS account from which you are going to query your orders. More about this stage can be consulted from the Amazon MWS component overview document.
Using amazonOrderId to listOrderItems
From the first step of the integration flow, we get all the specific details of the orders (but not the items included in the orders). So we use the
amazonOrderId to get the items:
Testing this step to get the items per order:
When we add the SAP ByDesign to this integration flow we can already see the incoming data from the second stage:
Using the fields from step 1
On step 3 when we start mapping all the incoming data into SAP ByDesign to create order. Apart from the usual field from step 2 now we have new fields to map:
From step 2 we receive all the information about the items, but no Shipping address. The Shipping Address we will use from step 1 in the following way:
Notice that Shipping Address is also an array which we can map with an incoming array from step 1 (more about mapping an array to an array):
The resulting mapping of this particular field would look like:
Notice the first part specifically indicating that the incoming data is from the
step_1.body and it is an array which is being mapped with an outgoing array.
Mapping complexity of multistage queries is not simple when the same initial source needs to be queried for several level data. In the most traditional manner of integration, the problem of parent and child properties is always being solved only by separate asynchronous processes. This method is sometimes error prone and unreliable.
Passthrough feature solves this dilemma by providing a reliable way for the data from several proceeding stages to be accessed, reused and re-mapped along the integration flow.