cancel
Showing results for 
Search instead for 
Did you mean: 

how to define multiple if conditions in User defined function message mapping

venkatasap
Participant
0 Kudos

Hi Sap All.

I have got a requirement in an Idoc to Webservice interface where I need to check a segment field in the IDOC and based on value I need to send a constant value to the target field.

here I need to use Else if conditions and I wrote the below udf but I am getting the Java Syntax error.

if ( Var1= "Nod" )

{

            var1 = " nodes " ;

}

Else

if ( Var1 = "nod2" )

{

           var1 = "nodes2" ;

}

Else

if ( Var1 = "nod3" )

{

            var1 = "nodes3" ;

}

could any body help me in this.

Regards.

Jagdish

Accepted Solutions (0)

Answers (2)

Answers (2)

sahithi_moparthi
Contributor
0 Kudos

Hi Jagdish,

Modify the code as below.

for(int i=0;i<var1.length;i++)

{

if(var1[i].equals("Nod1"))

result.addValue("node1");

else if(var1[i].equals("Nod2"))

result.addValue("node2");

else if(var1[i].equals("Nod3"))

result.addValue("node3");

else

result.addSuppress();

}

You can also use fix values which is flexible:

Nod1 -> node1

Nod2 ->node2

Nod3 -> node3

Use key as default

yeeloon-khoo
Explorer
0 Kudos

Hi Jagdish,

Why not using FixValues function?

boolean comparison is ==, not = that is assignment.

Regards,

Yee Loon