cancel
Showing results for 
Search instead for 
Did you mean: 

Access via 'NULL' object reference is not possible

Former Member
0 Kudos

Dear Exports

Can anyone help me to solve the error. I mam totally fresher in webdynpro platform. And I am not able to check the error. I have a RFC enabled function module. And in my web dynpro component I have called this function module. When I have runed the application an error raised that access via 'NULL' reference is not possible. I have attached the entire screenshots also. Please if anyone can know what's the error and how to solve it please guide me.

1.    1.   This is my 1st node of component controller context.

Dictionary structure is mchb because the import parameters are

2.       2.This is my 2nd node of component controller context.

Here the dictionary structure is zstock_struct because in my RFC enabled function module the export parameter is an internal table of this structure type.

And I have created this structure of type MCHB table. And the structure is of this type:

The source code of this RFC is

3.       I have created 2 views one for input and 2nd one for result. My aim is: when I will give the material no, plant, and storage location it will display the Quantity of that material, batch no of that material with same material no. This is my first view context

4.       This is my second  view context:

5.       This is the layout of my first view:

Where the UI elements are:

6.       This is the layout of my second view:

Where the UI elements are

7.       Then I click on the on action event of the search button of first view

method ONACTIONSEARCHDATA

   DATA lo_nd_input_node TYPE REF TO if_wd_context_node.

    DATA lo_el_input_node TYPE REF TO if_wd_context_element.
    DATA ls_input_node TYPE wd_this->Element_input_node.
    DATA lv_matnr TYPE wd_this->Element_input_node-matnr.

*   navigate from <CONTEXT> to <INPUT_NODE> via lead selection
    lo_nd_input_node = wd_context->get_child_node( name = wd_this->wdctx_input_node ).

*   get element via lead selection
    lo_el_input_node = lo_nd_input_node->get_element( ).

*   get single attribute
    lo_el_input_node->get_attribute(
      EXPORTING
        name `MATNR`
      IMPORTING
        value = lv_matnr ).

  DATA lv_werks TYPE wd_this->Element_input_node-werks.

* navigate from <CONTEXT> to <INPUT_NODE> via lead selection
  lo_nd_input_node = wd_context->get_child_node( name = wd_this->wdctx_input_node ).

* get element via lead selection
  lo_el_input_node = lo_nd_input_node->get_element( ).

* get single attribute
  lo_el_input_node->get_attribute(
    EXPORTING
      name `WERKS`
    IMPORTING
      value = lv_werks ).



  DATA lv_lgort TYPE wd_this->Element_input_node-lgort.

* navigate from <CONTEXT> to <INPUT_NODE> via lead selection
  lo_nd_input_node = wd_context->get_child_node( name = wd_this->wdctx_input_node ).

* get element via lead selection
  lo_el_input_node = lo_nd_input_node->get_element( ).

* get single attribute
  lo_el_input_node->get_attribute(
    EXPORTING
      name `LGORT`
    IMPORTING
      value = lv_lgort ).

DATA: wa_MCHB TYPE MCHB.

wa_MCHB
-MATNR = lv_matnr .
wa_MCHB
-WERKS = lv_werks.
wa_MCHB
-LGORT = lv_lgort.


DATA: wa_struct TYPE ZSTOCK_STRUCT,
      it_struct
TYPE TABLE OF ZSTOCK_STRUCT.


SELECT MATNR CHARG CLABS FROM MCHBINTO CORRESPONDING FIELDS OF TABLE it_structWHERE MATNR = wa_MCHB-MATNR.

CALL FUNCTION 'ZBAPI_STOCK_AVL_CHECK'
 
EXPORTING
    MATERIAL_NO           
= wa_MCHB-MATNR
    PLANT                 
= wa_MCHB-WERKS
    STORAGE_LOCATION      
= wa_MCHB-LGORT
 
TABLES
    T_ITAB                
= it_struct
          .
LOOP at it_struct INTO wa_struct.
 
WRITE: wa_struct-MATNR,
         wa_struct
-CHARG,
         wa_struct
-CLABS.
 
ENDLOOP.

  wd_this
->fire_out1_plg(
 
).*............................................
endmethod.

When I will run the application the following error is raised:

Yesterday I have put this query and I got suggestions to check the navigation link between the two views and change the property of the initial lead selection value to No. I will do it and activate the component and test the application and an error raised. What’s the error I am not able to getting it. Please anyone can help me to solve the error. I am totally fresher and I have no much knowledge on this platform also.

Accepted Solutions (0)

Answers (2)

Answers (2)

chengalarayulu
Active Contributor
0 Kudos

Hi Rashmita,

Its very clear to understand...

and just change the Input_Node cardinality to 1...1, then remove WRITE statement.

instead just make binding with OUTPUT node with IT_STRUCT.

then after fire the outbound plug.

now test.

former_member184578
Active Contributor
0 Kudos

Hi,

The second error screen shot is due to the wrong cardinality. For INPUT_NODE, you selected cardinality as 0..n change it to 1..1 as you are binding it to only one input field.

In onAction of search button, You are writing select query and then calling FM, which will serve same..!!

After that., what is the necessary for loop..? write statement..!!

In WDA write statement will not work.

To display the result in second view, you have to use bind_table( ) method.

Hope this helps u.,

Thanks & Regards,

Kiran