on 02-20-2006 6:53 AM
In ABAP, <b>IS INITIAL</b> checks whether a variable has been initialized or not.
When there is a context attribute which binds to a type that come from Adaptive RFC model import, such as <b>NUMC(10)</b>, how to check if it is initialized in Java Web Dynpro?
I, obviously, can do so with <b>"0000000000".equals(foo)</b> but I don't want to hardcode such a string, which is error-prone and makes my program not adaptable when model defination is changed.
Any suggestion?
Thanks!
Tony Kwan
Hi Tony Kwan,
In ABAP is initial is used to check whether the
variable has changed or not.
For WebDynPro or for any java application you can use
String class length() method to find whether it has
changed or not.
I consider "foo" is a string variable.
if foo.length() == 0
//foo is initial
else
//foo is not initial.
Hope it helps.
Regards,
Maheswaran.B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Bala,
Your provided code only works if <b>foo</b> comes from a value attribute. However, if it comes from model attribute, which source is an Adaptive RFC BAPI call, the value will be <b>0000000000</b> rather than <b>null</b>.
Will there be any better & more generic way to check whether an attribute is initial or not?
Thanks your help!
Tony
Hello Kwan,
You can always check if an attribute has some value or not by using the following piece of code:
wdContext.node<nodeName>().get<attributeName>() != null
The aforementioned code will return <i>true</i> if the attribute has some value else it will return <i>false</i>.
Bala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
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.