cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to access child node attributes

Former Member
0 Kudos

Hi

I am using webdynpro for java.

I have imported a model.

The context structure is as follows:

Contex

!

ZessModelName

!

OutputNode

!

1stTablefromRFC

!

2ndTablefromRfc

!

empname

!

Pernr

I want to access the pernr attribute returned in the node OutputNode.

I used this code

wdContext.currentOutputElement().getPernr() ;

But it gives null point exception.

If I map the pernr attribute directly to a textview it shows value of the pernr means pernr is returned from backend.

Please tell me the right way to access the pernr attribute in such a scenario as I want to set another attribute to this pernr for firing an insert query..

Accepted Solutions (0)

Answers (3)

Answers (3)

srinivas_sistu
Active Contributor
0 Kudos

Hi Anzar,

I have tried your scenario. You are getting null pointer exception because of cardinality of your node, change the cardinality from 0.n to 1.1 or 1.n.... it will work.

More over to get the value you can do

1. wdContext.nodeYourNode().currentYouNodeElement().getAttribute();

or

simply

2. wdContext.currentYouNodeElement().getAttribute();

I just wanted to correct the prevoius reply by some one stating

*You are writing wdContext.currentOutputElement().getPernr() ;

that is wrong because you are directly accessing currentOutputElement

you must write the name of node of which you want to access current Element*

that 2nd approach is wrong.

Both will give you current value associated with the context attribute.

Regards,

Srinivas.

Edited by: srinivas sistu on Jun 17, 2008 3:05 PM

piyush_kumar6
Active Contributor
0 Kudos

Hi anzar ,

you try to use following code

wdContext.nodeOutput().currentOutputElement().getPernr() ;

Former Member
0 Kudos

Hi,

Generally null pointer exception will come when u try to accces a variable with is not defined.

Actually it has to show the value for

wdContext.currentOutputElement().getPernr() ;

So check whether you are clearing the nodes anywhere in ur code.

and also after executing the function module immediately check the value

Regards

Padma N