cancel
Showing results for 
Search instead for 
Did you mean: 

BigDecimal adding

Former Member
0 Kudos

Hi Gurus,

One Quick question here. I have 3 fields of type BigDecimal. How can i programatically add all these 3 fields together and later display this value in a new field? Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

if you node structure is:

biddecimal

1.anum

2.bnum

3.cnum

and result is "result"


public void onActionadd(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionadd(ServerEvent)
    
   BigDecimal val1 = new BigDecimal(wdContext.currentBigdecimalElement().getAnum());
   BigDecimal val2 = new BigDecimal(wdContext.currentBigdecimalElement().getBnum());
   BigDecimal val3 = new BigDecimal(wdContext.currentBigdecimalElement().getCnum());
   
// by using th emthod add, we can add decimal numbers
   *result1 = val1.add(val2);*
   result2 = result1.add(val3);
   
   wdContext.currentBigdecimalElement().setResult(result2.toString());
    //@@end
  } 

regards,

pinki

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

If ur problem has solved ,make the question has solved.

Regards

Hazrath

Former Member
0 Kudos

Hi

1)u can convert the BigDemial value into int or float or double by using the

intValue() or floatValue() or doubleValue()

2)then u can add the 3 values

Regards

Hazrath