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 input_node1 TYPE REF TO if_wd_context_node.

 
DATA lv_matnr TYPE wd_this->Element_input_node-matnr.
* navigate from <CONTEXT> to <INPUT_NODE> via lead selection
  input_node1
= wd_context->get_child_node( 'INPUT_NODE' ).

  input_node1
->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
input_node1
= wd_context->get_child_node( 'INPUT_NODE' ).
input_node1
->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
input_node1
= wd_context->get_child_node( 'INPUT_NODE' ).
input_node1
->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:

What’s the error?  Please guide me.

Thanks and Regards

Rashmita Parida

07829797165

Accepted Solutions (0)

Answers (4)

Answers (4)

Lukas_Weigelt
Active Contributor
0 Kudos

Hi Rashmita,

first of all, thanks for being a shiny example how to ask a question properly; I think this is the most detailed one I've seen for quite some time and it really makes me feel refreshed between all these "dear cheers, I have error, please do the needful"-posts...

'aight, let's start: until your onsearch-method, everything looks OK. I got a little confused by the part before and after you call your RFC, I wager you tried to somehow debug what's happening there with writes and check whether the RFC is executed at all by executing its coding beforehand in the WDA, do I see this correctly?

The error is most likely that your outbound plug of the search-view is not bound to the inbound plug of the result view. You should check this first. Example from one of my early WDAs:

If this is not the error cause, you should debug your on-search method and look where it crashes, alternatively take a look at the dump in ST22.

Please rule this one out first of all and get back here.

By the way, saying you are very new to WDA, do you know of these tutorials? http://scn.sap.com/docs/DOC-8863

They helped me a great lot when I was starting with WDA.

EDIT: gosh, people are fast... and they are all right, lead selection should not be initialized with a 0 to n cardinality, this only dumps though, if there is no data selected, so maybe it's not the only error cause.

Cheers, Lukas

farooq_basha
Active Participant
0 Kudos

Hi Rashmita,

In your FIRST Screen Init. Lead Selection  - Yes you have mention. Make it as NO

If data is not available then u can't select lead so it will throw NULL error.

Regards,

Farooq

Former Member
0 Kudos

Hi rashmita , pls post the full code ..i think 2 errors are there ..

1) did u go through navigation for get default code (in ur code instance for node is not there )

2) did u embed the view into window...

nd one ore mainly i thinkk u have missed the init lead selection...

for ex: 

elem_mara = node_mara->get_element(  ).

pls check this parameters it will work..

thanks and regards ..

  lokesh

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Just try to keep Init. lead selection as No for Input node. Then try to run.

Former Member
0 Kudos

Thanks for ur reply. But I am not able to understand what U have suggested to do. Please can you explain it brifely. Because I am a fresher in this field. So I am not able to solve it.

Thanks and Regards

Rashmita parida

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

In Input_node, go to properties and then try setting Initialization Lead No instead of Yes.