cancel
Showing results for 
Search instead for 
Did you mean: 

Access via 'NULL' object reference not possible.

Former Member
0 Kudos

Hi

I am very new in Web-dynpro. I have developed my 1st web-dynpro application through some web tutorials. But when I am click on the Test button, browser is open and give me the below Error.Can anyone help me to solve the issue. This is my first development so I could not able to understand what needs to be done to correct the Error.

The following error text was processed in the system RD1 : Access via 'NULL' object reference not possible.

The error occurred on the application server bebmssd6_RD1_00 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: GET_ATTRIBUTE_EXTERNAL of program CL_WDR_VIEW_ELEMENT_ADAPTER===CP

Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L0STANDARD==============CP

Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP

Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP

Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L7STANDARD==============CP

Method: CONV_VIEW_INTO_VE_ADAPTER_TREE of program CL_WDR_INTERNAL_WINDOW_ADAPTERCP

Method: SET_CONTENT_BY_WINDOW of program CL_WDR_INTERNAL_WINDOW_ADAPTERCP

Method: RENDER_WINDOWS of program CL_WDR_CLIENT_SSR=============CP

Method: IF_WDR_RESPONSE_RENDERER~RENDER_VIEWS of program CL_WDR_CLIENT_SSR=============CP

Method: IF_WDR_RESPONSE_RENDERER~RENDER_USER_INTERFACE_UPDATES of program CL_WDR_CLIENT_SSR=============CP

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Please check my last post which I got the solution

Former Member
0 Kudos

Thanks Arpan and Kumar,

I got the loop whole. As a new bee I made some small mistake and it will create a problem. I assigne the Input field bind property to the table field itself rather than the attribute which I created.

Thanks a lot for your valuable time and helping me for solvin my life's first WD application.

furhter more I will add some small things in application like popup box etc..to more learning.

Regards,

Deepak

Former Member
0 Kudos

Deepak,

I do not find you give the node names.Where have you referenced the node?

Regards,

Arpan

Former Member
0 Kudos

sorry to bother you,

can you please describe more on your reply, as I do not get anything.

Have you taliking about the Code part ?

Former Member
0 Kudos

Deepak,

Yes I was talking about the code.

Check Kiran's code.

Folloe this process

1. Get the node

eg.

lo_nd_variable_edit = wd_context->get_child_node( name = wd_this->wdctx_variable_edit ).

In the bold portion give your node name

2. Get the required record from your node

lo_el_variable_edit = lo_nd_variable_edit->get_element( )...Gets the lead selection

OR

lo_el_variable_edit = lo_nd_variable_edit->get_element( INDEX = n ). Gets the row n

3. Get all declared attributes

lo_el_variable_edit->get_static_attributes(

IMPORTING

static_attributes = ls_variable_edit ).

OR

Get one attribute

lo_el_variable_edit->get_attribute(

EXPORTING

name = 'fieldname'

IMPORTING

value = ls_var1 ).

And PLEASE check the cardinality of the context of the input fields .

Former Member
0 Kudos

Hi Deepak,

I hope you have maintained the cardinality of the input fields for selection node as 1..1.

If it is so then it might be problem in the node.Maybe we need to look at the code.

Regards,

Arpan

Former Member
0 Kudos

Hi Arpan,

Where can I set the cardiality of input field. I can only see the cardiality option in Table Node only.

Can you please suggest.

Former Member
0 Kudos

Deepak,

Your input fields have to be bound to the nodes for which you get the data and query from the

backend table.

Click on the input field in the layout and see in the Property part in the row value it should be bound

to some node in the context.If it is not click on the button in the Binding column, and it will open the context.

Click on the right node and attribute and select.

Go to the context tab and check whether the selected node has cardinality 1..1.

Regards,

Arpan

Former Member
0 Kudos

Hi Deepak,

Have you used a table in your application?

If yes then look at the context node you have bound the table to.

The cardinality of the node can be 0..n

Or if you have cardinality 1..n then check the check box Initialization Lead Selection

in the Property of the node.

Kind regards,

Arpan

Former Member
0 Kudos

Yes I have used the table in my application,

basically My application as below,

There is one table called Movie, which has fields called Code, type, name, actor and actress.

in the Browser I have given the two field for selection to user , and one button called search. when user click on search button based on data inputed in code and type field , data will filter and show into the table below.

field for selection is Code and Type

My Parameter for the Node as Below

cardinality 0..n

Selection 0..1

Initialization Lead Selection - Yes

Singleton - YesBut still the same Error.

former_member283828
Participant
0 Kudos

The error is because of calling method from the reference which is not initialised.

I think the method name where you are getting is 'SET_CONTENT_BY_WINDOW' check properly whether the all the references are initialized.

paste the code so that we can help you.

Former Member
0 Kudos

below are the methods which is declared under the views

ONACTIONONCLICK

WDDOAFTERACTION

WDDOBEFOREACTION

WDDOEXIT

WDDOINIT

WDDOMODIFYVIEW

only ONACTIONONCLICK method i have created , rest all the method is by default and not changed anything in that.

Code for the ONACTIONONCLICK method is as below

method ONACTIONONCLICK .

types: begin of movie_data,

code type ZWDMOVIE-code,

TYPE type ZWDMOVIE-TYPE,

name type ZWDMOVIE-name,

actor type ZWDMOVIE-actor,

actress type ZWDMOVIE-actress,

end of movie_data.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_category_att LIKE ls_context-category_att.

DATA TABLE_NODE type ref to IF_WD_CONTEXT_NODE.

data: itab_movie type table of movie_data.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `CATEGORY_ATT`

IMPORTING

value = lv_category_att ).

  • DATA lo_el_context TYPE REF TO if_wd_context_element.

  • DATA ls_context TYPE wd_this->element_context.

DATA lv_code_att LIKE ls_context-code_att.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `CODE_ATT`

IMPORTING

value = lv_code_att ).

select * from ZWDMOVIE into corresponding fields of table itab_movie

where CODE = lv_code_att

and TYPE = lv_category_att.

TABLE_NODE = WD_CONTEXT->GET_CHILD_NODE( 'MOVIE' ).

TABLE_NODE->BIND_ELEMENTS( itab_movie ).

endmethod.

former_member283828
Participant
0 Kudos

Hi,

use code wizard to generate code.

I have put the chaged code in BOLD.

first you have to get the node by specifying node name then you have to get the element.

your code:

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_category_att LIKE ls_context-category_att.

DATA TABLE_NODE type ref to IF_WD_CONTEXT_NODE.

data: itab_movie type table of movie_data.

changed code.

TABLE_NODE = wd_context->get_child_node( 'GIVE THE NODE NAME' ).

    • get element via lead selection*

lo_el_context = TABLE_NODE->get_element( ).

below is the procedure to read the where 'DATA' is the node name

DATA lo_nd_data TYPE REF TO if_wd_context_node.

DATA lo_el_data TYPE REF TO if_wd_context_element.

DATA ls_data TYPE wd_this->element_data.

  • navigate from <CONTEXT> to <DATA> via lead selection

lo_nd_data = wd_context->get_child_node( 'DATA' ).

  • get element via lead selection

lo_el_data = lo_nd_data->get_element( ).

  • get all declared attributes

lo_el_data->get_static_attributes(

IMPORTING

static_attributes = ls_data ).

Former Member
0 Kudos

Below is the code as per ypu ask to changed, but still Error is the same . Below is my modified code.Please kindly suggest.

method ONACTIONONCLICK .

types: begin of movie_data,

code type ZWDMOVIE-code,

TYPE type ZWDMOVIE-TYPE,

name type ZWDMOVIE-name,

actor type ZWDMOVIE-actor,

actress type ZWDMOVIE-actress,

end of movie_data.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_category_att LIKE ls_context-category_att.

DATA TABLE_NODE type ref to IF_WD_CONTEXT_NODE.

data: itab_movie type table of movie_data.

TABLE_NODE = WD_CONTEXT->GET_CHILD_NODE('MOVIE').

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `CATEGORY_ATT`

IMPORTING

value = lv_category_att ).

  • DATA lo_el_context TYPE REF TO if_wd_context_element.

  • DATA ls_context TYPE wd_this->element_context.

DATA lv_code_att LIKE ls_context-code_att.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `CODE_ATT`

IMPORTING

value = lv_code_att ).

select * from ZWDMOVIE into corresponding fields of table itab_movie

where CODE = lv_code_att

and TYPE = lv_category_att.

TABLE_NODE->BIND_ELEMENTS( itab_movie ).

endmethod.

Former Member
0 Kudos

Hi Deepak,

This MOVIE has cardinality 1:N or 0:N

TABLE_NODE = WD_CONTEXT->GET_CHILD_NODE('MOVIE').
* get element via lead selection
lo_el_context = wd_context->get_element( ).

Then when you are getting the element then you need to specify the index to get the element otherwise NULL reference will come.

In the ONCLICK event you can get the index right using the WDEVENT parameters

lo_el_context = wd_context->get_element( index = index ).

Regards,

Lekha.

Former Member
0 Kudos

Lekha,

Could you explain why is it needed to get the index of the context for input field ?

And even if it is context for table why will selecting the lead selection bring a NULL reference ?

Regards,

Arpan

former_member15918
Participant
0 Kudos

This error has occured bcaz somewhere object is not initialized.

Please check ST22 where dump details are stored which might point to exact line where initialization is necessary

cfortiniviana
Explorer
0 Kudos

Look at ST22, ,you will se this message type E.

21.05.2022 17:20:45 lnl-s4h_S4H_00 DEVFIORI295 200 C DATREF_NOT_ASSIGNED ZCL_ZPRIMEIRO_SRV_295_DPC_EXT=CP 17 093199F198E700F0E006229978BD2894

In your Browser :

Error: Access using a 'NULL' data reference is not possible.","persistent":false,"targets":["/dadosSet"],"type":"Error"},

Att,

Cleber