on 07-21-2008 1:56 PM
Hi,
I have a input field Amount of type Bigdecimal.
i have to sum the column data Amount; after that the total is passed to Amount(Bigdecimal) input field.
The code for calculation is as follows:
public void onActionTotalOfAmount(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionTotalOfAmount(ServerEvent)
int NodeSize = wdContext.nodeCtx_Claim_Create().size();
float Amount = 0;
for(int i=0;i<NodeSize;i++)
{
Amount = Amount + wdContext.nodeCtx_Claim_Create().getCtx_Claim_CreateElementAt(i).getCtx_Amount();
wdContext.currentContextElement().setCtx_Total(Amount);
}
But when i am passing the Amount to input field(Bigdecimal) the error is type missmatch.
Please tell me that how to convert the Amount(float) to Amount (big decimal).
Regards
Hi,
use -
Amount = Amount.add(wdContext.nodeCtx_Claim_Create().getCtx_Claim_CreateElementAt(i).getCtx_Amount());
instead of
Amount = Amount + wdContext.nodeCtx_Claim_Create().getCtx_Claim_CreateElementAt(i).getCtx_Amount();
Aviad
Edit:
Do not use float for amount. use -
BigDecimal Amount = new BigDecimal(0);
Edited by: Aviad Levy on Jul 21, 2008 3:24 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
in general to convert float to big decimal
* To convert Float to BigDecimal.
* @param f the Float to be converted
* @return converted BigDecimal
*/
public BigDecimal toBigDecimal(Float f) {
return (f == null) ? null : new BigDecimal(f.toString());
}
that is.....
BigDecimal big = new BigDecimal(floatX.toString());
apply it as you want.
PradeeP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.