cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

6 IF-THEN and OR conditions for one target field mapping

Former Member
0 Kudos

Hi Mapping experts,

I have a validation condition involving 2 source fields and 1 target field only, however the number of conditions is 6 (OR)

Source Fields:

TYPE

PONUM

Target Field:

BELNR

If TYPE = 1st value then BELNR = PONUM substring (0, ๐Ÿ˜Ž 0=start position, 8=character count

OR

If TYPE = 2nd value then BELNR = PONUM substring (2, ๐Ÿ˜Ž

OR

if TYPE = 3rd value then BELNR = PONUM substring (4, ๐Ÿ˜Ž .......... up to the 6th Validation Condition.

When I do this using graphical mapping only (multiple IF-THEN and OR's) the validation is successful only on the 1st IF-THEN statement, then it passes the substringed value to the 1st OR function..... When I "Display Queue" the 1st OR function the substringed value is taken as null (or:in1 <null>) Is this because OR function is expecting Input as "True or False" value only and not a string value?

For my requirement above, can I achieve this using graphical mapping only? or do I have to use UDF for this?

If it's better to use UDF for this, would anyone give me a jumpstart on the code? (I have no experience yet in UDFs)

Thanks, and hoping that somebody will respond accurately and completely.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can achieve this using Graphical mapping. No need of UDF. Also no need of OR Function.

Use If then Else.

In If use first condition. In Else, use second 'If then Else' Function.

Now for this 2nd 'If then Else' Function, Use Second condition as input to If and 3rd 'If then else' as input to Else.

Like this carry on till you finish all yr conditions.

I hope its clear..

-Gouri

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes. IF-THEN statement requires a TRUE / FALSE input. If you want to compare two strings in the graphical mapping use standard function "equalS". Pass the output of this function to IF-THEN ELSE statement.

Regards,

TK

Former Member
0 Kudos

Create UDF with two inputs as TYPE & PONUM and use bleow code there..

 String out = "";

if( TYPE.equals("1"))
{
out = PONUM.substring(0,8);
return out;
}
else if( TYPE.equals("2"))
{
out = PONUM.substring (2,8);
return out;
}
else if( TYPE.equals("3"))
{
out = PONUM.substring (4,8);
return out;
}
else if( TYPE.equals("4"))
{
out = PONUM.substring (4,8);
return out;
}
else if( TYPE.equals("5"))
{
out = PONUM.substring (4,8);
return out;
}
else if( TYPE.equals("6"))
{
out = PONUM.substring (4,8);
return out;
}
return "";

Note: change the substring range as per your need in above code.

Now do your mapping as shown below

TYPE ------>|
            | -----> UDF ---> BELNR
PONUM----->|

Former Member
0 Kudos

Hi HJ,

You can achieve this mapping in both ways either by creating UDF or by standard mapping functions

I am sending you UDF code. Try it

var1 is the TYPE and var2 = BELNR (these are your input parameters)

String posnum = "12345678"

if( var1.equals("1"))

{

var2 = posnum.substring (0,8);

return var2;

}

elseif( var1.equals("2"))

{

var2 = posnum.substring (1,8);

return var2;

}

esle......so on

Let me know if you have any issues

Hope it helps

Regards,

Shradha

Edited by: Shradha_thapliyal29 on Oct 22, 2010 12:09 PM