cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle random item number format?

Former Member
0 Kudos

Hi,

In Message-Mapping I map item number to item no.

The source item number format are random, sometime in char, i.e., ABC123, ABC-23-A... sometime in digit, i.e. 123, 425...

The target system is sap and accepts just C(18) with captial characters.

I think, i need a UDF.

1. tell whether source field is digit or characters.

2. if digit then FormatNum into 0000000000000000

3. if characters then toUpperCase.

Is it correct? how to make it?

thanks

Rene

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Better to ask bussiness system about max possibilities of number,based on that you can write logic.

Former Member
0 Kudos

Hi, Raj,

thank you for your prompt reply!

I understand your tip not yet. The possibility of number of source system is high. Part of item number are digit and the rest are characters.

How to realize my logic in UDF? Best with some example codes.

Regards

Rene

anupam_ghosh2
Active Contributor
0 Kudos

Hi Rene,

Could you please let us know the output you expect for the following inputs

abc3455,16, abc, 000A10000000000,abc-23-0000a23 .

regards

Anupam

Former Member
0 Kudos

Hi, Anupam,

I need the following results:

abc3455 --> ABC3455

16 --> 000000000000000016

abc --> ABC

000A10000000000 --> same, without change

abc-23-0000a23 --> ABC-23-0000A23

Regards

Rene

Former Member
0 Kudos

chk this:

Input is "var"

Execution type: Single value



int num = 0;
boolean flag = false;

for (int i = 0; i < var.length(); i++) {
char a = var.charAt(i);

if (Character.isDigit(a))
{
flag =true;
}

else {
var = var.toUpperCase();
flag=false;
break;
}
}
if(flag)
{
while(var.length() < 18) {
var= "0" + var; 
}
return var;
}
else{
return var;
}


rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

your requirement very simple,

first check whole string is having characters or not,if not then use format number else use toUpperCase standard function to convery capital letetrs.

Regards,

Raj

Former Member
0 Kudos

Hi, Amit,

it works perfectly!

thanks

Rene

Answers (1)

Answers (1)

rajasekhar_reddy14
Active Contributor
0 Kudos