cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping problem.

Former Member
0 Kudos

I have the following problem.

Source structure:

<header>
   <segment>
      <value1>A</value1>
      <value2>B</value2>
   </segment>
   <segment>
      <value1>C</value1>
      <value2>D</value2>
   <segment/>
   <segment>
      <value1>E</value1>
      <value2>F</value2>
   <segment/>
</header>

If the field value1 concatenated with value2 is equal to CD somewhere in the source structure then I want to produce the following target.

<header>
   <indicator>X</indicator>
</header>

If the source structure value fileds concatenated is equal to XY then the following target.

<header>
   <indicator>B</indicator>
</header>

Otherwise the following target.

<header>
   <indicator/>
</header>

How would I solve this with a gra

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

In place of UDF you can also use conversion function FixValues.

By passing concatenated value as key and required value in value column it can be done easily.

Example: CD as key and X in value column.

Keep the default value as space to generate the target.

Thanks and regards,

Sandeep Jaiswal

Former Member
0 Kudos

Hi,

value - 1 map with default

value - 2 map with default concatenate --> equalS (CD) --->ifWithOutElse --> Then ---> map a constant 'X' to target field.

Here value1 and value2 should be in the same context.

Regards

Ramesh

Former Member
0 Kudos

It is a very simple logic..

Concatenate (Value1 & 2) --> equalS (CD) --->ifWithOutElse --> Then ---> map a constant 'X' to target field.

same logic for XY.

Regards,

Sarvesh

Former Member
0 Kudos

Tried that.

Only goes on the last segment.

So basicly I always gets space in the result then.

Former Member
0 Kudos

I guess it is context issue. Try using RemoveContext just before you map your result to target field. e.g

(Value1 + Value2 ) --> ifWithoutElse --Then (map 'X') --->RemoveContext -->Target field.

You can try the solution given by Sandeep which is good and by using that you can avide some std function e.g. ifWithoutElse, constant, equalS.

Regards,

Sarvesh

Former Member
0 Kudos

Hi

value - 1 map with default

value - 2 map with default concatenate --> equalS (CD) --->ifWithOutElse --> Then ---> map a constant 'X' to target field.

Here value1 and value2 should be in the same context (context point to the header node)

we used mapwith default because if suppose value1 come and value2 not came then it sends the default ("") value other wise it takes the second segment in value2.

Regards

Ramesh

Former Member
0 Kudos

Here you target header must be getting generated once.

In that case it will take the last value.

Former Member
0 Kudos

value1 and value2 will always come as a pair.

//Kalle

Former Member
0 Kudos

in the target structure:

<header>

<indicator/>

</header>

check the occurence of header...it should be mapped with source header.

Sandeep

Former Member
0 Kudos

Hi Kalle,

Check this link

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

Here PARVW = value1, PFACH = value2 and target = FromName

I have checked this, its working fine.

If target element comes multiple then use split by value other wise you can delete.

Here i used the map with default value, bcz if some times the field value not come then it takes the default value otherwise take some wrong value.

Regards

Ramesh

Former Member
0 Kudos

its better to write a UDF just for checking the condition instead of going for the if else of graphical mapping

jsut pass the value of the concat function to the UDF and in the UDF put a condition

String a =" ";

if( value.equals("CD"))

{

return X;

}

else if (value.equals("XY"))

{

return B;

}

else

{

return a;

}

HTH

Rajesh

Former Member
0 Kudos

Just trying to avoid UDF's.

But if this is the solution then it is.

BR

Kalle