cancel
Showing results for 
Search instead for 
Did you mean: 

How to check the source value is in between a string range in mapping

Former Member
0 Kudos

Hi Consultants,

I am working on IDOC to File scenario. I need to implement a specific requirement of our client. i.e. something like below;

Vendor number can be any thing like 1AA000000 / 1AA000001/1AB000000/... ect till 1ZZ999999.

if the vendor number is in between 1AA000000 -1ZZ999999 then the target value should assign as 'Internal' else should assing as 'External'.

How to compare that the value of vendor is in between IAA000000 to 1ZZ999999 in mapping?

Appreciate your help.

Thanks in advance.

Regards,

Nausheen

Accepted Solutions (1)

Accepted Solutions (1)

sunilchandra007
Active Contributor
0 Kudos

Hi Nausheen,

Try this simple UDF with the power of regular expression.


 import java.util.regex.*;
 public static String checkRange(String vendorNumber) {
        if(Pattern.matches("1[A-Z]{2}[0-9]{6}",vendorNumber))
            return "Internal";
        else 
            return "External";
}

Hope it helps !!

Regards,

Sunil Chandra

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Nausheen,

The UDF provided by Sunil will best work for you. For more information on the clas Pattern; you can refer the following thread:

http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html

Also, the value mapping (or fix value) will not be a good idea in this case as you will have to write/provide a very big list of mapping, thats close to impossible.

Former Member
0 Kudos

Hello,

Have the list of possible Vendor Numbers in hand and Implement Values Mapping in your Interface

/people/community.user/blog/2007/01/08/valuemapping-using-the-graphical-mapping-tool

Regards

Former Member
0 Kudos

You can try creating an UDF and using the varName.substring(); method. Then you can compare in separated pieces the string. For example

String var = "1AA000000";
if (var.substring(3).compareTo("000000") < 0 && var.substring(3).compareTo("999999") > 0) 
{
  //compare now the "AA" and "ZZ" with the same logic;
}

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#substring(int, int)

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#compareTo(java.lang.Object)

EDIT: Moreover, those functions are available in the Mapping program creation, but this should give a clue on the order it should be done.

Edited by: Lucas Santos on Mar 29, 2011 7:38 PM

Edited by: Lucas Santos on Mar 29, 2011 7:53 PM