cancel
Showing results for 
Search instead for 
Did you mean: 

how to map only the first occurance to the op in graphical mapping

Former Member
0 Kudos

Hi,

i have a record whose occurance is ' * '.But to the output i need to only map the value of the field which comes in the first occurance of the record.Can anyone help me in this.its very urgent.

For ex :

my input is

<header>

-


<inp1>123</inp1>

-


<inp2>hello</inp1>

</header>

<header>

-


<inp1>456</inp1>

-


<inp2>hello</inp1>

</header>

To the output field <op1> i have to Map ' inp1 ' field but it has to take the value of the first inp1 i.e "123" only always.Any help on how to do this.

Thanks in advance,

Bhargav

Message was edited by:

bhargav gundabolu

Accepted Solutions (0)

Answers (1)

Answers (1)

justin_santhanam
Active Contributor
0 Kudos

Bhargav,

Its simple, Just map the records node by node. Don't go far any logic. Just node to node , but is your target root node occurrence is also unbounded, then I would suggest just take an empty constant and map to the root node. Thats it , if its not clear , give the target structure with occurrences.

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

My inp structure is:

<header>

-


<inp1>123</inp1>

-


<inp2>hello</inp1>

</header>

<header>

-


<inp1>456</inp1>

-


<inp2>hello</inp1>

</header>

This has to me mapped to the output structure

<result>

-


</op1>

</result>

After Mapping inp1 to op1 my structure should appear as

<result>

-


<op1>123</op1>

</result>

<result>

-


<op1>123</op1>

</result>

where <Header> node is mapped to </result>.As <result> has to appear as many times as Header appears.But the <op1> value has to be same as that of the <inp1> of the first <Header>

Former Member
0 Kudos

Bhargav,

Another option would be create your own UDF in message mapping with input as source field and assign output to target value.

Code as below in your UDF..

result.addValue(inp1[0]);

So every time it will assign first value frour source data...

Nilesh

Former Member
0 Kudos

Hi Nilesh,

That works only if the inp structure appears like this

<header>

-


<inp1>123></inp1>

-


<inp1>456></inp1>

</header>

It dosent work if input is like this

<header>

-


<inp1>123></inp1>

</header>

<header>

-


<inp1>456></inp1>

</header>

Thanks,

Bhargav

Former Member
0 Kudos

Hi,

I think this is possible if you set context level at above Header Level...probably at messge level.

Nilesh

Message was edited by:

Nilesh Kshirsagar

Former Member
0 Kudos

Gundabolu,

Just map the source field to the target with collapse contexts. Also put the context to the root level.

Source field(context to root node)>collapsecontext>target field.

Regards,

---Satish