cancel
Showing results for 
Search instead for 
Did you mean: 

IS INITIAL in Java Web Dynpro

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

If IS INITIAL is used to check if the value has been changed, then I believe you can use isChangeByClient().

The syntax is

nodeElement.isChangeByClient();

Former Member
0 Kudos

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