cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping answer

Former Member
0 Kudos

Hello experts I have a requirement where my source and target fileds are almost same.

source:

<A>

<B>

<C>

<E>

<F> 0...unbounded

<G>

<H>

Target:

<I>

<J>

<K>

<M>

<N> 0...unbounded

<O>

<P>

My requirement is if B = X then O = first occurance of G. and its the same for all N unbounded occurances.

I tried using an if condition and copy of value(0) for my putput , but for exmaple say i have three occurences of N I see my desired output only in the first occurance , the other two occurances don't have the O filed.

Any Mapping tips

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sudheer,

Your requirement is not clear. Can you try to explain it using some example ?

Thanks,

Pooja

Former Member
0 Kudos

Hi I will try explain my problem again

i need to use a if condition to check for the value of a field in source

Source:

<QUOTATION_HEADER_IN>

<ORDCOMB_IN>X</ORDCOMB_IN>

</QUOTATION_HEADER_IN>

<QUOTATION_ITEMS_IN>

<item>

<REASON_REJ>R1</REASON_REJ>

</item>

<item>

<REASON_REJ>R2</REASON_REJ>

</item>

<item>

<REASON_REJ>R3</REASON_REJ>

</item>

</QUOTATION_ITEMS_IN>

Target Exactly the same one to one mapping but IF ORDCOMB_IN = X then all the REASON_REJ fileds must have hte value R1 ( whihc is the first value)

I am trying to achieve this what I have tried is

if ORDCOMB_IN (TextEquals) X then REASON_REJ ( copyvalue (0) ) to REASON_REJ( target side) .

But the problem i face is out of the three calues of REASON_REJ in the Item node only one is being populated. I can't see the remaining two.

This works when i chnage the if condition to say some constantX eualsto constantX , but doesn't work when i use the field ORDCOMB_IN. I tried using ORDCOMB_IN with all contexts , and removed context and coallapsed but none works .

Any ideas?

Thanks a lot

Former Member
0 Kudos

Hi sudheer

To the most i understand that you are checking for a field as X and if true then you want then you are copying a value.

It works fine for me without changing context



ORDCOMB_IN ->(EqualS(X)) -> ifWithoutElse (REASON_REJ in then)->  REASON_REJ 

Another way



public String checkArgument(String ORDCOMB_IN,String REASON_REJ,Container container){
 if (ORDCOMB_IN.equalsIgnoreCase("X"));
return REASON_REJ;
}

Thanks

Gaurav

Former Member
0 Kudos

Hi,

You can try following mapping with UDF.

Mapping:

                ORDCOMB_IN -->
                                UDF --> SplitByValue --> REASON_REJ(Target Field).
REASON_REJ --> RemoveContext -->

UDF:

Execution Type : Context.

1st param : ORDCOMB_IN

2nd param : REASON_REJ

if(ORDCOMB_IN.length > 0)
{
  if(ORDCOMB_IN[0].equals("X"))
  {
    for(int i = 0;i<REASON_REJ.length;i++)
    {
      result.addValue(REASON_REJ[0]);
    }
  }
}

-Rohit.

Former Member
0 Kudos

Hi Rohit I ahve tried your UDF , but ia m having same problem as using IF condition , If i had Item as two times , then in the target strucutr only the first Item element is being populated with R1. the second Item doesn't even has the REASON_REJ field.

Thanks

Former Member
0 Kudos

hurrah

I had to inser splitby value before the target element. to get it in the second one too .

Rohit full credits to you , thank you .

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank you

Former Member
0 Kudos

I just need a little tweak for my requirement .

What rohit suggested with UDF works fine with the IF condition , I need to make an else as well , i want to assign REASON_REJ as it is if the condition is not met.

Any ideas

Thank you .

SudhirT
Active Contributor
0 Kudos

Hi,

you can try with node functions like removeContext or spitByValue. or provide more detail on requirement.

thanks.

Former Member
0 Kudos

I don't get exactly what you're trying to do, but I guess you should work with different contexts there. Right-click the attribute in your graphical mapping and follow the contexts option. Try a little bit, maybe you'll get the solution quickly.