cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue: from unbound node to two single fields

Former Member
0 Kudos

Hello,

I have a source message with a node that is 0... unbounded.

The node contains a field named "component_name" with occurence 1..1.

The target message contains only two single fields (component1, component2) and the task is to provide the first two occurences to these fields.

node occ.1

component <modul beta> -> component1

node occ.2

component <modul omega> -> component2

We can expect to have any case like these:

node is 0 -> no components provided

node is 1 -> one component provided (usual case) , so second field will be empty

node is 2 -> two components provided

node is > 2 -> need to pick the first two components to provide them to the target fields.

Does anybody here have an idea how to solve this mapping issue?

Your ideas are really welcome!

Best regards

Dirk

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos



       constant(1) \
node - index - equalA  - ifwithoutelse - mapwithdefault(empty) - component1
                      component /


component2 similar.

Answers (2)

Answers (2)

Former Member
0 Kudos

Stefan's solution is very good, alternatively, if you are sure that you will always have at least two items you can do

source -> copyValue[0]-> target

source -> copyValue[1]-> target

please note: if you don't have at least two items in your source the copyValue function will throw an exception

0 Kudos

Better to create a UDF as suggested earlier,

Pass the entire queue of the field and then check if the value exist then pass otherwise move to next value.

/Adi

VijayKonam
Active Contributor
0 Kudos

A UDF should solve your issue. Take the fields complete queue as the input. Check for the first occurance in code and return it. Similarly check for the second occurance and return. Should work.

VJ