cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple if conditions in Source to create one target

Former Member
0 Kudos

Hi All,

Scenario is proxy to IDoc . (Multimapping to use two different Idocs in Target)

The condition from Proxy is to check 3 nodes if it exists and check for a particular field value to map to one IDoc at a time.

can some one  please give input how we can map this to target side.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I cant print from my machine the exact xml...

Node1

Node2

Node3

at a point of time only one node will come.

if Node1 comes need to pass A to target field xyz

if Node2 comes need to pass B to target field xyz

if Node3 comes need to pass C to target field xyz.

i know we can use exists and if function ...but this is one for one check only. I need to do 3 checks simultaneously and pass only one value to target ....

Any inputs will be helpfull

Thanks in advance.

former_member184720
Active Contributor
0 Kudos

Hi Jan - Is it a node or field on the source? and the A,B,C are constant values?

Former Member
0 Kudos

it is occurence of node ..only one node occur at a time.

and A,B,C are constant values...

former_member184720
Active Contributor
0 Kudos

Edited ....

Did you try this

I just noticed that i was having multi mapping.. Please use the below mapping

for the field mapping don't use remove context

Message was edited by: Hareesh Gampa

Former Member
0 Kudos

Thanks for your help. It worked.

Answers (2)

Answers (2)

Former Member
0 Kudos

thanks amit for inputs...it kind of worked.

But while testing found out that it is working only for one occurence of field.

if i duplicate subtree for multiple times and test it it is allways taking the first value and creating one target filed only, where as i need to create equal number fields as coming in source to target.

I know it is some thing to do with context changes ....

any inputs on how to handle this ?

thanks much in advance.

former_member184720
Active Contributor
0 Kudos

Hi Jan - Can you share the input xml and expected output.

It would be easy to suggest.

atleast provide with the display queue screenshots and the expected output..

former_member184720
Active Contributor
0 Kudos

Hi Jan - Any specific reason in going for multi mapping?

Have a look at the below blog -

http://scn.sap.com/people/rajasekhar.reddy14/blog/2011/02/24/multi-mapping-without-bpm-for-idoc-scen...

what happens if you map it to create if? it should work i guess...

Also you said there are two IDOC's at target but you seems to be having 3 conditions so can you confirm how the IDOC's have to be created?

However i think you can also have separate mappings and in the interface determination use the xpath filter logic to execute the respective mapping

you can simply select the xpath in the condition editor..exists and equals are easy to validate using xpath

Former Member
0 Kudos

thanks for the input now  i changed design to handle on condition in ID.

Now in mapping:

From Source we will get 3 fields and one of them will have value and remaining do not occur...

can we handle it using UDF we take three input fields and to udf and pass the one which is not null:

I tired this udf but facing errors, can some one give inputs:

if{

( var1 =! null);

return var1;}

else

{

(var2 =! null);

return var2;}

else

{

(var3 =! null);

return var3;

}

Former Member
0 Kudos

Hello,

Why do u want to use UDF in mapping?

I mean using xpath conditions in ID u can filter our which mapping to execute, and in ESR just create different mappings for insert, delete and update?

To Exist Or Not to Exist is the Question - Process Integration - SCN Wiki

Thanks

Amit Srivastava

Former Member
0 Kudos

in ID i am filtering out which receiver interface it needs to go to.Now i have two message mappings.

But when in mapping source Structre will still contains 3 nodes we dont know which one will occur in runtime.

So i need to check 3 fields and pass only which does have value.

Former Member
0 Kudos

if (var1 ! = null)

{

return var1;

}

else if (var2 ! = null)

{

return var2;

}

else if (var3 != null)

{

return var3;

}

i am trying some thing like this in UDF to pass the value which actully exisits but getting syntax errors...

Former Member
0 Kudos

Hello,

>>But when in mapping source Structre will still contains 3 nodes we dont know which one will occur in runtime.

U want to use UDF just to output a filed value?

Use below UDF:

Execution type: all values of a context

Input value: var1, var2, var3

if (!var1[0].equals(""))

{

result.addValue(var1[0]);

}

else if (!var2[0].equals(""))

{

result.addValue(var2[0]);

}

else if (!var3[0].equals(""))

{

result.addValue(var3[0]);

}

Mapping:

Filed1-------MapWith Default()

Field2-------MapWith Default()----------UDF---Target

Field3-------MapWith Default()

Thanks

Amit Srivastava

Thanks

Amit Sriavstava