cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping tweak

Former Member
0 Kudos

Hello all

My mapping requirement is

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> 0 to ..unbounded

<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 the value R1 ( which is is the first occurance)

I am trying to achieve this. what I have tried is

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]);

}

}

}

I got this advice from rohit , It worked like charm , But now i need an else block with the If condition . If the the condition that ORDCOMB_IN is notequla to X then REASON_REJ must be mapped as it is to the target strucutre . How can tweak the code to achievbe this ?

When i tried the same with IF with else function , it works only for one instance of ITEM structure , if there are more than one ITEM structure it doesn't work .

Any ideas?

Thanks a lot

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Sudheer,

try this :

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]);
}
}
else
for(int i = 0;i<REASON_REJ.length;i++)
{
result.addValue(REASON_REJ<i>);
}


}

It should fix your problem.

Thanks

Pooja Pandey

Former Member
0 Kudos

Hi Pooja

I have already tried that , but it gives me syntax error saying

addValue(java.lang.String) in com.sap.aii.mappingtool.tf3.rt.ResultList cannot be applied to (java.lang.String[]) result.addValue(REASON_REJ); ^

I guess result.addValue statement mush have an array with a number.

Former Member
0 Kudos

Check the latest reply...

result.addValue(REASON_REJ<i>);

not

result.addValue(REASON_REJ);

It will work . I just tried it.

Pooja

Former Member
0 Kudos

I tried it Pooja , It worked , Great stuff , full credits to you .

Thanks a lot

Former Member
0 Kudos

Wonderful... Enjoy.

Answers (0)