cancel
Showing results for 
Search instead for 
Did you mean: 

mapping issue, maybe need UDF

former_member440449
Participant
0 Kudos

Hi Gurus,

I am having a source message like this:

ITEM (1..unbounded)
>SOURCEFIELD (1..1)

Sourcefield is below Item.

In the target side, there is a field called TARGETFIELD (1..unbounded) that needs to be created with next condition:

for each nonrepeteable sourcefield value, one targetfield must be created. For example:

<Item>
   <Sourcefield>1</Sourcefield>
</Item>
<Item>
   <Sourcefield>1</Sourcefield>
</Item>
<Item>
   <Sourcefield>2</Sourcefield>
</Item>
<Item>
   <Sourcefield>2</Sourcefield>
</Item>
<Item>
   <Sourcefield>3</Sourcefield>
</Item>

In this example, 3 TARGETFIELD must be created, since there are only 3 non repeteable values (1, 2 and 3).

Something important to notice is that values will ALWAYS come sorted.

How can I do this in mapping? Should I develop an UDF? Or can I use PI's common functions?

Thanks!

Edited by: chapa_akd on Mar 31, 2011 12:18 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I dont think you need UDF to handle this requirement. Simply use the following node functions in graphical mapping:

Source field > RemoveContext>Sort (not required if you are sure that values will always come sorted)-->SplitbyValue(Value change)

samiullah_qureshi
Active Contributor
0 Kudos

In addition to the puneet's reply use Collapse Context in the end

Source field > RemoveContext>Sort (not required if you are sure that values will always come sorted)-->SplitbyValue(Value change) --> Collapse Context --> Target Field

Answers (5)

Answers (5)

former_member440449
Participant
0 Kudos

Finally, Samiullah was right and his solution was the right one.

I need to do something new inside that.

Will open a new thread since this is already answered and the other one will be a different (and most difficult) issue.

Thanks everyone!!!

former_member333459
Participant
0 Kudos

Hi,

You can use

Source Segment -


>Removecontext--


>Splitby value(Value Change)--


>Target Segment

and

Source Field--->Removecontext


>Splitby value(Each Value)--


>Target Field

Thanks and Regards,

Neethu

former_member440449
Participant
0 Kudos

Thank you all for replies.

Actually, issue is almost solved with Puneet's anwser but there is one concern: the sourcefields got values 1, 2, 2, 2, 2, 3, 4, 5, 6 and 7.

And when targetfield is created, it creates 7 of them (which is CORRECT) but value passed is not 1, 2, 3, 4, 5, 6 and 7; it is 1, 2, 2, 2, 2, 3 and 4.

Is there any way in which I can map corresponding values to that field?

Thanks in advance.

Regards.

0 Kudos

This should get you the correct values as well:

Source field --> SplitbyValue(Value change) --> Collapse Context --> SplitbyValue(Each Value) --> Target Field

Thanks

Pradeep

samiullah_qureshi
Active Contributor
0 Kudos

Have u tried my suggestion in my previous reply?

Former Member
0 Kudos

Hi

The mapping will be like this

SourceField - Removecontexts - Sort - SplitByValue( valuec hange)

Regards

Sandeep

Former Member
0 Kudos

You can use SplitByvalue Node function. This function will insert context change with each value or after value change.

You can use after value change in SplitByValue node function.

I don't have PI system handy so I am not able to give you complete graphical maping but you can do with graphical mapping.