Skip to Content
avatar image
Former Member

Mapping problem.

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Dec 09, 2009 at 01:26 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 09, 2009 at 01:32 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Dec 09, 2009 at 01:39 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 09, 2009 at 01:42 PM

    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

    Add comment
    10|10000 characters needed characters exceeded