cancel
Showing results for 
Search instead for 
Did you mean: 

Format Number

Former Member
0 Kudos

Hi,

I have a input value like 20070913 and i need to change it to the format 2.0070913E7. I am using arithmetic function FormatNum for this. I gave the Number format as 0.#######E0. Its working fine for all conditions but when the input value is something like 00010101, its results in 1.0101E4..I require the output as 0.0010101E7.

Pls help me solving this issue.

Regards,

Radhika

Accepted Solutions (0)

Answers (4)

Answers (4)

andresousa
Advisor
Advisor
0 Kudos

Hello Radhika,

I think this problem can be solved with a simple UDF, with one parameter, like:

Regards,

Andre Sousa

double d = Double.parseDouble(a);

double resultado = d;

int shiftCount = 0;

int pos = 0;

if (a.length() > 0) {

while (a.charAt(pos) == '0') {

shiftCount++;

pos++;

}

}

while (d >= 10) {

shiftCount++;

d = d / 10;

}

String givenNumber = a;

givenNumber = givenNumber.replaceFirst("[.]+","");

String result = new StringBuffer(givenNumber).insert(1, ".").toString();

return result + "E" + shiftCount;

Edited by: Andre Sousa on Jan 8, 2008 4:11 PM

Former Member
0 Kudos

Hi,

try to use UDF because leading Zeros are trunckated,

check some links for UDF.

http://flickr.com/photos/8764045@N06/

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e...

Example 1

http://www.flickr.com/photo_zoom.gne?id=544183191&size=o

http://www.flickr.com/photo_zoom.gne?id=544183195&size=o

http://www.flickr.com/photo_zoom.gne?id=544183225&size=o

http://www.flickr.com/photo_zoom.gne?id=544183233&size=o

Example 2

http://www.flickr.com/photo_zoom.gne?id=545133789&size=o

http://www.flickr.com/photo_zoom.gne?id=545133791&size=o

http://www.flickr.com/photo_zoom.gne?id=545133801&size=o

http://www.flickr.com/photo_zoom.gne?id=545133807&size=o

http://www.flickr.com/photo_zoom.gne?id=545133811&size=o

http://www.flickr.com/photo_zoom.gne?id=545138911&size=o

http://www.flickr.com/photo_zoom.gne?id=545138913&size=o

http://www.flickr.com/photo_zoom.gne?id=545138915&size=o

http://www.flickr.com/photo_zoom.gne?id=545138917&size=o

http://www.flickr.com/photo_zoom.gne?id=545138947&size=o

http://www.flickr.com/photo_zoom.gne?id=545138951&size=o

http://www.flickr.com/photo_zoom.gne?id=545005958&size=o

Example 3

http://www.flickr.com/photo_zoom.gne?id=549186611&size=o

http://www.flickr.com/photo_zoom.gne?id=549186651&size=o

http://java.sun.com/j2se/1.5.0/docs/api/

/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi

/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d046c490-0201-0010-84b6-9df523cb...

Regards,

phani

Reward points if Helpful

Former Member
0 Kudos

You have to use UDF for this.

Regards,

Sarvesh

prabhu_s2
Active Contributor
0 Kudos

might be the leading 000 are truncated resulting this error. check the same with the input as 10101 and see if the same result is shown