cancel
Showing results for 
Search instead for 
Did you mean: 

decimal maximum of 17 digits

Former Member
0 Kudos

hi all,

it is possible that a user of our WDJ application must enter a number which consists of more than 17 digits, lets say "1234567890123456789"

it is also nessecary that we have a custom scale of the value, a simple Java type like double, float is not accurate enough.

So we decided to use simple type "decimal" which is ought to be a java.math.BigDecimal, with custom scale. But we faced a problem at runtime. When we set the type of a contaxt attribute to "decimal" and bind it ona input field, WDJ cuts every digit behind the 17th digit.

1234567890123456789 --> calling some action

1234567890123456700

or

123456789,0123456789 --->

123456789,01234568

I tried double and its behaving absolutely identical (could that be some workaround by SAP engineers?)

it is not possible to bind a input field to a context attribute of type java.math.BigDecimal

any suggestions?

Stefan

using WDJ 2004 SP19

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Stefan,

Create a SimpleType of type decimal. Specify total digits(20) and fraction digits(2) in the definition part, and in the Representation tab, specify External length (say 26). Apply this type to the context attribute and bind it to the input field. You should have an input field which takes more than 17 digits.

If this is successful, you can copy data from Model node to a value node, manipulate BigDecimal etc.

But just bear in mind the limit of a decimal value

Lemme know if that helps.

Regards,

Rajit

Former Member
0 Kudos

Hi,

I think the problem is that web dynpro uses numberformat to format the string.

Numberformat can only handle values as double and double is restricted in length.

The hole "simple type length values" thing doesn't solve the problem.

Try the following:

Simple Type

Type decimal

Maximum digits: 30

Fraction digits: 2

Enter:

12345678901234567890.123456789

As long as the string exceeds the 17/18 digits from double the rest is cut of and the fraction digits maximum does not work.

If you leave the mask you wouldn't even see the changes in your input!!!

The only solution I can think about (and it is not a sweet one) is:

1. create two string context attributes

2. set one calculated and bind it to the input field

3. create a decimal context attribute (this is the goal and the only one which should be necessary)

4. implement the calculated getter and setter

the setter should validate the input, update the second string value to the input, if valid input - should parse and update the big decimal

if validation fails a message must be reported

5. create the getter which should return the formatted big decimal or (if invalid data was entered) return the second string attribute which holds the user input

as you can see one decimal and two string attributes (one as calculated attribute and one to hold the invalid inputs) are necessary for every number!!! the effort is incredible.

by the way: I think reporting messages in calculated setter isn't even possible. Maybe you have to implement some sort of message list for reporting all errors and report all messages in every action handler you have

Did anybody solve this issue in a better way?

Former Member
0 Kudos

Hi Stefan,

I am not sure, but can you please try to create Decimal type of length say 40 in Local Dcitionary. Change Context attribute type to newly created type.

Regards,

Ganga.

Former Member
0 Kudos

that's what I did in first place

Former Member
0 Kudos

Hi Stefan,

If you can associate R/3 field to input field, all properties will be inherited to Web Dynpro field as well. In this way I think we can definately incorporate more than 17 digits. Please check if this is possible.

Other option which you will know already is input field type changing to String and using format method.

Regards,

Ganga.

Former Member
0 Kudos

we are using java beans model encapsulating R/3 logic, in java beans model it is BigDecimal.

(The corresponding RFC structure generated by enterprise connector also offers BigDecimal, so I think it's worthless)

yes the by-hand transformation StringBigDecimalString is possible, but not very elegant, the model class is used pretty often

Stefan

Former Member
0 Kudos

Hi,

<i><<it is not possible to bind a input field to a context attribute of type java.math.BigDecimal>></i>

You can create such a context attribute.

1. Create a value attribute.

2. From the properties view click the "..." button for the type of this attribute.

3. From the dialog box select Java native type.

4. Select "Browse" and type BigDecimal.

If you cannot do this, then I guess it's because of the NW version you are using (I'm using 7.0 and I can do this).

Regards,

Satyajit.

Former Member
0 Kudos

it is not possible to bind a input field to a context attribute of type java.math.BigDecimal

binding is not possible, you can create context attributes of any type, but it is not possible to bind a List/Exception/BigDecimal Object to a input field UI Element (it demands java.lang.String if you try) aight?

cheers

Stefan

former_member182294
Active Contributor
0 Kudos

The best way could be assign the input field to String and set the Caliculated property of the attribute to true. And create another value attribute of type BigDecimal ( or you can reuse the model attribute). Using Setter and Getter methods of caliculated attributes you can copy values, you can validate.

You can refer the following

Regards

Abhilash