Topic
• Latest Post - ‏2013-05-15T16:19:45Z by thorstenhirsch
RPotteti
10 Posts

# Pinned topic Restrict Functional Map Occurances

‏2013-05-10T22:08:03Z | fuctional map

Hi -

Can anyone help with the below WTX problem?

My input message looks like -

<Lines>
<Line>
<LineRef>1</LineRef>
<LineNo>1</LineNo>
</Line>
<Line>
<LineRef>1</LineRef>
<LineNo>2</LineNo>
</Line>
<Line>
<LineRef>1</LineRef>
<LineNo>3</LineNo>
</Line>
<Line>
<LineRef>2</LineRef>
<LineNo>1</LineNo>
</Line>
<Line>
<LineRef>2</LineRef>
<LineNo>2</LineNo>
</Line>
<Line>
<LineRef>3</LineRef>
<LineNo>1</LineNo>
</Line>
</Lines>

And outut should look like this-
<Lines>
<Line>
<LineRef>1</LineRef>
<Quantity>6</Quantity> (Count of occurances of LineRef 1)
<LineNoNote>1, 2,3</LineNoNote> (Line No's of LineRef 1)
</Line>
<Line>
<LineRef>2</LineRef>
<Quantity>3</Quantity> (Count of occurances of LineRef 2)
<LineNoNote>1, 2</LineNoNote> (Line No's of LineRef 2)
</Line>
<Line>
<LineRef>1</LineRef>
<Quantity>1</Quantity> (Count of occurances of LineRef 3)
<LineNoNote>1</LineNoNote> (Line No's of LineRef 3)
</Line>
</Lines>

I am thinking to use a functional map to implement this. I can get count of unique LineRef using Unique and count functions. I want to use this number to restrict the no of times Lines in output.

But I an not sure how to implement this. Please help if you have a solution for this.

Thanks. Raj.

• thorstenhirsch
94 Posts

#### Re: Restrict Functional Map Occurances

‏2013-05-15T16:19:45Z

You might want to use an additional group for grouping lines with the same LineRef in the input. Let's call this group "LineRefGroup". You place it between the Lines element and the Line element. And you add a component rule like this one:

```LineRef:Line:\$ = LineRef:Line:\$[LAST]
```

That way your resulting objects have the following count: