Transform functions – Simple looping

The DTC looping functions

Among the pre-defined functions in the TaskCentre Data Transformation Component (DTC), there is a group that is used to apply looping in a data transformation.

There are three looping functions:

  • Simple
  • Split-by-type
  • Interleaved merge

We will briefly look at looping in general before focusing on the simple looping function.

The purpose of the looping functions

A loop is used to iterate through all the specified elements in a set or array. The iteration is repeated until all the conditions specified for the looping have been met.

The looping functions are used in TaskCentre task design to carry out various kinds of looping during the transformation of data between the data input and the tool input schema.

Looping can affect the flow of data or even, in the case of split-by-type and interleaved merge, change the structure of the data.

Focus on the simple looping function

You access the simple looping function from the Looping category in the Functions pane of the DTC.

To use the function, you drag an instance of it into the Transformation Mapping area.
You can then drag connectors into place between the function icon and the required elements in the data and tool input schemas.

You can also open the function’s dialog box by double-clicking the function icon. This lets you set or check various options.

pic1

Using the simple looping function

A simple looping is a straightforward linear iteration through a set of elements until the conditions for the looping have been met.

Typical designs where simple looping might be used include sales orders, purchase orders, invoices and similar cases where a header row and associated lines are present.

In these situations, the source data typically contains many orders, and each order many rows or lines.

pic2

The example above shows a mapping in the DTC for the Web Service Connector tool in a simple sales order scenario.
pic3

Above: The simple loop incorporated in this transformation connects two folders, an input from the salesOrderListEntry node and output to the salesOrderInfo folder.

This loop iterates for each unique order that is present in the source XML (the Data Input) and calls the tool (the Tool Input) for each order.

The tool input calls another operation, SalesOrderInfo, which then returns the order lines for each order.

pic4

Above: This shows another sales order example where simple looping is being applied to a data mapping.

In this example, the source data schema consists of many orders with many lines; we wish to flatten the XML in preparation for converting it into a record set. As an analogy, you can think of this as taking structured XML and producing a flat file.

This is a useful technique for restructuring data where the source system uses XML but the destination system has no method of using XML and instead uses record sets.

pic5

Above: Two simple loops are involved in this transformation.
Note particularly the nodes that the loops are mapped from.

One loop is mapped from the SalesOrder node; the other loop from the salesitems node. This means we are looping through XML that contains many orders of many lines each.

You have to be careful to place the loops on the correct folder nodes in order to retain the correct structure.

Simple looping: In summary

A loop is a function that iterates through all the specified elements in a set or array. The iteration is repeated until all the conditions specified for the looping have been met. Looping may affect the flow of data or even the structure of the data it acts on.

TaskCentre provides three looping functions in the data transformation component to carry out various kinds of looping: simple, split-by-type and interleaved merge.

Simple looping is a simple iteration through a set of elements that continues until the conditions for the looping have been met. It is typically used in transforming sales order, purchase orders, invoices and the like.

You access the function in the Functions pane of the DTC. To apply a looping to a data transformation, you drag an instance of the function to the mappings pane. You then add connectors between it and nodes or elements in the data input and tool input panes. You can also open the function’s dialog box and check or set various options there.

Links to related DTC articles