cancel
Showing results for 
Search instead for 
Did you mean: 

Ho to set the format of an InputField of type Float

Former Member
0 Kudos

i have a inputField(name input1),which bind to a javaBean(myBean) attribute(price: Float type).

for example:

myBean.setPrice(11000.42).

but i wanna disply such a format: 11,000,420000 in my inputField of web dynpro view.

how to set it?

you know u cann't set to a simple type in u DD.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You have to change the format of the DD simple type in the dictionary.

1. Open the Simple Type

2.Click Representation Tab.

3.Goto the format field and supply your desired format.

For a list of format visit this link

http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html

Hope this helps

Ananda

Answers (4)

Answers (4)

former_member189631
Active Contributor
0 Kudos

HI WINGOAL,

THR ARE STANDARD FORMATTING FUNCTIONS AVAILABLE IN JAVA.

U CAN USE CURRENCY FORMAT FUNCTION .

[nt : see java API for formatting]

sridhar_k2
Active Contributor
0 Kudos

Hi,

If you want to show in to your Input Field, use type String. Runtime you change it String with your desired format(11,000,420000) like (,) and zero's concatenating.

I don't think, there is any ready made solution for this.

Regards,

Sridhar

Former Member
0 Kudos

Hi

Try this code in wdDoInit() method.


wdContext.node<YourNode>.getNodeInfo().getAttribute("YourAttribute").getModifiableSimpleType().setFormat("0,000.000000");

Regards

KK

Former Member
0 Kudos

Hi,

this value getting from BAPI or any other way.

If getting the value from BAPI U can set in R/3 side.

Other wise we can display in View when we are getting form the BACK END.

Let me know how the value will come.

Thanks

Lohi.

Former Member
0 Kudos

hi,Lohitha.

these value is from Back end.

i import javabean as javabean model.

then i bind javabean model to context .

Former Member
0 Kudos

Hi,

U should have data type is same what u displayed on the view must be match then only it is possible.

If that match the previous post is works fine.

Other wise it shows some exception like

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(ApplicationView.Z_Rfc.Output.O_Table.price): must not modify the datatype of a mapped attribute .

Please find this and solve your problem.

thanks

Lohi.

Former Member
0 Kudos

Hi

This is with reference to Lohitha's preveious post.

My post is applicable only to value nodes and not to model nodes. If you happen to bind UI Elements directly to model nodes you will encounter an exception. This is one reason why it is a bad idea to bind UI Elements directly to model nodes.

If your value node in view is mapped to a value node in a component/custom controller, write the formatting code in the wdDoInit() method of controller ( i.e. at the source). The code works fine.

Regards KK.