on 08-29-2008 7:30 PM
hi
i have written the below code , and all the elements
iam getting from the RFC are returning me of type
BigDecimal and i need to calculate the price*numberofnight
he is staying in the hotel , so i have multiplied in the
below way
BigDecimal nightNumber=wdContext.nodeIpsitd().currentIpsitdElement().getMnits();
BigDecimal pitchPrice=wdContext.nodeOpprcid().currentOpprcidElement().getPthpr();
BigDecimal pitchFee=pitchPrice.multiply(nightNumber);
java.lang.NullPointerException
at java.math.BigDecimal.multiply(BigDecimal.java:412)
at uk.co.caravanclub.BookingDetails.onActionGetPrice(BookingDetails.java:303)
at uk.co.caravanclub.wdp.InternalBookingDetails.wdInvokeEventHandler(InternalBookingDetails.java:520)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
iam getting this error ,
can any one help me out?
k
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You get NullPointerException when your object variables are not instantiated, its a good practice that when ever you use such variables first check for the NullPointerException before using them.
Sample Code:
BigDecimal nightNumber = wdContext.nodeIpsitd().currentIpsitdElement().getMnits();
BigDecimal pitchPrice = wdContext.nodeOpprcid().currentOpprcidElement().getPthpr();
BigDecimal pitchFee = new BigDecimal("0"); //Initialization here will avoid NullPointerException
if (nightNumber != null && pitchPrice != null)
pitchFee = pitchPrice.multiply(nightNumber);
Regards,
Jawed Ali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check whether the values coming from backend with null
and proceed to multiply if they are not null
Regards
LN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you debugged to check whether nightNumber is null or not?
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kishore,
Did you try putting the debug messages to verify what values are you getting from the backend?
In webdynpro we can print messages on the screen with Web Dynpro Message Manager API , as below :
BigDecimal nightNumber=wdContext.nodeIpsitd().currentIpsitdElement().getMnits();
weComponentAPI.wdGetMessageManger.reportSuccess("night Number" + nightNumber);
BigDecimal pitchPrice=wdContext.nodeOpprcid().currentOpprcidElement().getPthpr();
weComponentAPI.wdGetMessageManger.reportSuccess("pitchPrice" + pitchPrice);
//BigDecimal pitchFee=pitchPrice.multiply(nightNumber);
Please run this code and verify on the screen what values are displaying from the back end?
Thanks
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.