cancel
Showing results for 
Search instead for 
Did you mean: 

How to check incoming field value is complete Alphabates or Not

Former Member
0 Kudos

Hi all,

I have the requirement like this

I have Two input values 1) Receiving Code 2) Delivery No

If the Receiving Code is Complete Alphabets means i have to concatenate last 3 digits of Delivery No to receiving Code and pass it, else Pass the Receiving code as it is.

For Ex1:

Receiving code = ABCD

Delivery No = 1234

Result shld be ABCD234

Ex2:

Receiving code = AB879

Delivery No = 1234

Result shld be ABCD879

Ex3:

Receiving code = 9999

Delivery No = 1234

Result shld be 9999

Please help me on this

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vamsi,

The String has a matches(), which will tell you whether the string is a regular expression or not.

Try this -

if (myString.matches("[a-zA-z0-9]*"))

// alpha-numeric

else

// Not alpha-numeric;

Change the code as per your requirement.

Let us know if you have more issues with this.

Regards,

Neetesh

Former Member
0 Kudos

Hi Nitish,

Thank you very much for reply

i wrote code like this and it ia returning the Else condition value only even though the string contains Numeric or Alpha Nuemeric

public String LCode(String LCode,String DelNo,Container container){

if (LCode.matches("a-zA-z0-9*"))

return LCode;

else

return LCode+DelNo.substring(7,10);

}

And also it is taking the for the first segment only, it is not checking for all

Regards

Former Member
0 Kudos

i wrote code like this and it ia returning the Else condition value only even though the string contains Numeric or Alpha Nuemeric

>

> public String LCode(String LCode,String DelNo,Container container){

> if (LCode.matches("a-zA-z0-9*"))

> return LCode;

> else

> return LCode+DelNo.substring(7,10);

> }

The matches("a-zA-z0-9*") is checking for alphanumeric, and as I mentioned in my previous post, change the code as per your requirement. I mentioned this method just to let you know that your issue can be handled by this and the code is not exactly as per your requirement.

For checking only the alphabets, use "a-zA-Z".

Remove contexts for taking care of all the values for that field.

Regards,

Neetesh

Former Member
0 Kudos

Hi Nitish,

I checked in this way also

if (LCode.matches("a-zA-Z"))

return LCode+DelNo.substring(7,10);

else

return LCode;

But always it is returning else part only.

Could you please give me the UDF code for my above mentioned requirement please

Regards

Answers (3)

Answers (3)

Former Member
0 Kudos

This Code Solved my Issue

Imports java.util.regex.Pattern;

public String LocationCode(String locationCode,String deliveryNumber,Container container){

if((Pattern.matches(".*
p{Digit}", locationCode)) != true){

int dnLength = deliveryNumber.length();

locationCode = locationCode + deliveryNumber.substring(dnLength - 3, dnLength);

}

return locationCode;

}

Thanks for all your inputs, Especially Satish

Thanks a lot for the support

Former Member
0 Kudos

Hi VAmsi,

In your 2n example:

Ex2:

Receiving code = AB879

Delivery No = 1234

Result shld be ABCD879

The result is wrong. Accorindg to logic you gave it should be AB879. Probably a typo. If yes then the udf which I hv given should work.

Regards,

---Satish

Former Member
0 Kudos

Hi Vamsi,

You need to 2 udfs for this. One for finding whether numeric or string and the other for taking the substring from 3rd position to the end. Because the end length is not same standard function dont support.

First udf: Create a Value udf with two inputs a and b and name it as isRegex. Add this code:

Imports: java.util.regex.*;

Pattern pat=Pattern.compile(b);

Matcher m=pat.matcher(a);

if(m.find())

return m.group();

else

return "true"; //This will return true if the input is string else the input will be returned.

Second udf: Create a Value udf with two inputs a and b and name it as stringfrom3rdposition. Add this code:

Imports: java.*;

int i = Integer.parseInt(a);

String c = b.substring(3,i);

return c;

Now map like this:

Receiving Code (first input to udf1) --> isRegex

[0-9] (second input to udf1 please dont forget[ ] brackets. best copy as it is and when you put you should like this [[0-9]])

output of regex(first input to equals function)-->equalsS(text function)

true (constant)

So output of equals --> if -->

for then: Deliveryno (first argument to udf2)--> length --> stringfrom3rdposition (udf2)

Deliveryno (second argument to udf2)

concat Receivingcode and output of udf2 give to then part

and in else part give Receivingcode. Hope this makes sense.

Receivingcode -->

Deliveryno>length>

udf2 ---> ---> concat

Deliveryno-->

then

Receivingcode -->

isRegex(udf1) --> equalsS (text funciton) --> -->output

[0-9] --> true -->

else

Receivingcode

I tested it and it works fine for me . Give a try and let us know.

Regards,

---Satish

Former Member
0 Kudos

Heyy Satish,

Your code works like charm....:)

One issue is here, From Idoc i have one segment E1ADRM1, that will repeat more times with qualifier.

I have to check if the qualifier = WE then only i have to do this Logic.

If my qualifier is at first segment then only it is working, if my qualifier is at 3 segment or some where else means it is not working.

this is my Mapping screen and i have set the Partner_ID(Receiving Code) context to one upper level.

Even i remove the context it is not working

http://img202.imageshack.us/img202/7000/mapp1.jpg

Please help me

Former Member
0 Kudos

Hi Vamsi,

I cannot see your screenshot becasue it is blocked in my company. So I cannot see that.

But change the context to root and then put a remove context which should take care of supress and see.

Regards,

---Satish

Former Member
0 Kudos

Satish,

I have the contexts to this Receiving Code field is like this

E1ADRM1

- E1EDL20

--IDOC

---ZDELVRY

I set the context ti E1EDL20 and used Remove Context before mapping to Target field.

But no use

Regards

Former Member
0 Kudos

Satish,

please give your inputs on this

Regards

Former Member
0 Kudos

Hi Vamsi,

Did you cahnge the context to idoc and see?

Regards,

---Satish

Former Member
0 Kudos

Changed to Idoc, but no use Satish...

Getting mad on this

Regards

former_member187339
Active Contributor
0 Kudos

Hi Vamsi,

>>i have one segment E1ADRM1, that will repeat more times with qualifier., I have to check if the qualifier = WE then only i have to do this Logic.

This means you need to apply udf only to for qualifier WE? then do like this

IF[ E1EDARM1 - QUALF (dont change context) == WE ] then map field (Partner_ID) else constant (blank). > removecontext> this becomes the first input of formatBy Exampl (see inbuilt node functions), second input is E1ADRM1 (make context to parent of E1ADRM1) > sort (descending order)> collapse context> splitby Value(each value)-> UDF.--> and further steps

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

What ever you are saying is not possible here, because iam using 2 udf's as per the Satish's Suggession.

Please check the Screenshot of My Mapping

Iam able to get the values till Target side field, but to Target field its not reaching.

Please help me on this to get this valu inside the target field.