cancel
Showing results for 
Search instead for 
Did you mean: 

Java question

Former Member
0 Kudos

Hello sdn

If I have a variable

a = A1234

then i want to add a semicolon to it,else if a =A1234; then i dont want to add semicolon to it as it already has a semi colon.

Can i get to know the java code to achieve this?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you could use this:

> if (! (a.lastIndexOf(";") == (a.length() - 1))) {

> a += ";";

> }

Regards

Patrick

Former Member
0 Kudos

Thanks guys ,have awarded the respective points.

Answers (2)

Answers (2)

Former Member
0 Kudos

use below code.



if ( a.indexOf(";") > -1 )  //if not present.
{
  a = a+";";
}

as said above, you can use standard string function indexOf

http://help.sap.com/saphelp_nw04/helpdata/en/c8/98e7d5c1620642973565ea3dd319d1/frameset.htm

Former Member
0 Kudos

u can use fixed value mapping give default value as A1234; and in the input give A1234 and output A1234; ad map it to target.

its the only value which going to come form input or along with this u may have different values as well,the above solution will work for that input value only.

if u r using java mapping then u have to use .equals function to compare the input values.

if(input.equals("A1234;")

{

result (A1234;)

}

else

result(A1234;)

or u can use graphical function constant,equals etc.

chirag