on 11-16-2009 2:34 PM
Hi All,
I am facing peculiar erro in code.I need to check the null entries in SAP server then it should be replaced by space and if not null then should be replaced by the value in backend.But it is throwing null pointer exception
I am using equalsignore case(null) and trim for space.
I am not getting why its is throwing null pointer exception.Kindly advise
Regards,
Anupama
Hi
Please understand there is difference between null and having one space
1. null is the reserved constant used in Java to represent a void reference i.e a pointer to nothing. Internally it is just a binary 0, but in the high level Java language, it is a magic constant, quite distinct from zero, that internally could have any representation.
2.The String trim() method returns a copy of the string, with leading and trailing whitespace omitted.
3. Check for space i.e (if (abc ! == " ")) . (I need to check the null entries in SAP server then it should be replaced by space and if not null then should be replaced by the value in backend.But it is throwing null pointer exception)
if it true then populate the actual values
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Use
String f = null ;
if(f!==null)
Wdcomponent.getMessageManager.ReportException ("this will cause null pointer exception "+ f.length());
Better to give it any Constant like
priveate static final String NULL_CHECK = "DEL_VAL12";
rather than space ,at the time of chceking see if it has DEL_VAL12 if true then put the actual data else let it be there.
Best Regards
Satish Kumar
Hi All,
Thanks for replies.I got the solution as I have done this by checking the node size greater than zero,its now showing in a correct way what it was supposed to display.Instead of taking field of RFC i took whole node as if size of node is zero then it will defintely wont be having any fields and no feld is having value as zero so the way of valdiation itself was going wrong.
If you have to check the backend valeu is null then take the node's size as validation parameter.
Regards,
Anupama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anupama,
Obviously, when we are picking some value from RFC Model then, the very first thing that we need to do is to check if the Node Itself is not null. Then check if the size of the node is not null......then element of the node at a given index is not null....then the attribute value is not null and then finally attribute values when trimmed to get rid of leading and trailing spaces is not equal to empty string. This way, would wont get any exception at all. Hope it helps you when you encounter similar exceptions in the future.
Regards,
Tushar Sinha
Hi,
If you use equalsIgnoreCase to compare null value you will get null pointer exception; because this method compares with another string.
Try to use (== null) and check.
Regards,
Manjunath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.