cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.String.format

Former Member
0 Kudos

Hi all,

I found a little problem here. I need to map a field to another formatting it as char(10) completed with "0" at left. To do this, I wrote this simple line of java code in a user defined function (PI 7.0)

return String.format("%10s", value).replace(" ", "0");

I was surprised when I found it didn't work in Integration Repository! It works on Eclipse and others Java IDE's. The error I got in IR was this one

cannot resolve symbol symbol : method format (java.lang.String,java.lang.String) 
location: class java.lang.String return String.format("%10s", value).replace(" ", "0");

Some tip about it?

Thank you!

roberti

Message was edited by:

Waldemar Roberti

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I believe "String.format" is a new functionality with Java 1.5.

The current version of XI still uses 1.4.

You will have to devise another method to do the same

Regards,

Bill

Former Member
0 Kudos

thanks William.. it worked for me... keep posting..

Answers (2)

Answers (2)

former_member214364
Active Contributor
0 Kudos

Hi,

format method would be in java.text.Format package.you need to use import statement "java.text.*;"

and also check format method parameters.

Cheers,

Jag

Former Member
0 Kudos

Hi,

instead of return use result.addValue();

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi people,

thank you for your tips!

<b>Maheshwari</b>, why would I use result.addValue instead return? Both seems the same to me.

<b>Jag</b>, it really works (not so easier and faster as the String.format), thanks.

<b>Bill</b>, you are right. The problem is the java version. I couldn't imagine PI 7.0 uses java 1.4 instead 5.0! Hope SAP upgrade it soon

cheers!

roberti