cancel
Showing results for 
Search instead for 
Did you mean: 

2 fields driving same segment

Former Member
0 Kudos

Hi.

I have 2 fileds in my source structure that are to drive the same segment in the target structur.

I have the following example of source.

<header>
   <date1/>
   <date2/>
</header/

If I have a value in date1 the segment in the target shoudl be created and if i have a value in date2 the segment shoudl be created, if both of the date fields has values I should get 2 segments in the target structure.

So an target structure should look as follow with both date fileds having values.

<target>
   <segment> "Driven by date1 field"
      <date> "With value from date1 field"
   </segment>
   <segment> "Driven by date2 field"
      <date> "With value from date2 field"
   </segment>
</target>

BR

Kalle

Accepted Solutions (1)

Accepted Solutions (1)

former_member223322
Active Participant
0 Kudos

Hi,

I believe you have to decide the 'segment' occurences based on the date1, date2 field values. If this is the case you can use the below UDF to achieve the same.

if (Date1[0].equals(""))

{

}

else

{

result.addValue(""Date1[0]"");

}

if (Date2[0].equals(""))

{

}

else

{

result.addValue(""Date2[0]"");

}

You need to map the date1 and date2 fields to this UDF and map it to the 'segment' and 'date' nodes in the target structure. Also while mapping to the 'date' in the target you need to add the 'SplitbyValue' standard function. Hope this solves your problem.

~Vaas

Former Member
0 Kudos

Hi VaasPal.

Just solved it with the same solution as you describe.

Thanks for the input.

BR

Kalle

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Kalle,

> So an target structure should look as follow with both date fileds having values.

>

<target>
>    <segment> "Driven by date1 field"
>       <date> "With value from date1 field"
>    </segment>
>    <segment> "Driven by date2 field"
>       <date> "With value from date2 field"
>    </segment>
> </target>

Repeat the target node and map the accordingly.

for mapping check this link

http://www.flickr.com/photos/42898709@N07/4644438730/

Regards

Ramesh

Former Member
0 Kudos

Hi ,

As per my understanding your source str is okay in your target strucuture you have to duplicate the target segment in order to achieve the desired result .

create in target like this

<target>

<segment>

<date> (as you have created )

</segment>

just in message mapping right click on segemnt then you will find the option duplicate selected segment go for that option .

then mapped both the segment as per your mapping rule and you will get the desired output .

use creatIF function

In source date1 exists >creatif-> segemnt (target )

date2 exists >creatif-> segment ( mapped to duplicated segemnt in target)

if you will do mapping like this you will get the desired output I hope

Regards,

Saurabh

stefan_grube
Active Contributor
0 Kudos

right-click on "segment", chose "duplicate sub-tree" and voilà