User GuideReference ManualIntegration Scenarios
 

2.3.5. Counter

See: Managing Channels - Message Transformation Functions

You can easily add a counter using a custom drag and drop transformation function.

You can add a counter in a custom drag and drop transformation function. Use the Xpath ' position() ' to implement this local counter in your transformation.

Additionally, it is also possible to keep track of a counter from one transformation to another by implementing it into a lookup table and applying it using the custom function ' lookup table counter '.

To implement a "persistent" counter:

  • Create a lookup table named ' counters ' with two columns named ' name, value '.

  • Add an entry (mycounter, 0).

  • In the transformation screen, add a transformation function type : LookupTable / LookupTable Increment Value.

  • Select the table to ' counters ' and the IN to ' name ' and OUT to ' value '.

  • Now create a new transformation function ' contant string ' with a value of ' mycounter '.

  • Drag the contant string as the argument of the lookup table.

You are now ready to use the counter in you mapping. Each time the counter is used, the value will be incremented by 1.

Example

Make a counter of segments during XML incoming message file transformation.

Example:
SEGMENT A (multiple segments possible)
- FIELD A1
- FIELD A2

In this example, how to make a dynamic counter to count all segments A where the field A1 = "009"?

To count all segments A with field A1='009', use the following custom Xpath function: count(A[A1='009']) and map it to the target segment.

To ignore the loop on the counter that resets this counter, use a custom Xpath function with the following code: 1 + count(preceding-sibling::subelement) + count(../preceding-sibling::element/subelement) where element is the name of element used with loop1 and subelement is the name of element used with loop2.

Do not forget to link the relevant loop to your custom rules in order to access proper relevant data.