cancel
Showing results for 
Search instead for 
Did you mean: 

Null reference error

Former Member
0 Kudos

Hi Experts,

I'm an ABAPER and new to CRM Web UI working on developing a z-bsp-component. I need to trigger a pop-up window to show an alert message to the user who submits a request if some information is not available. I succeeded in achieving this one as a 'INFORMATION' message in the view, but couldn't trigger a new pop-up window as i end up with "access null reference error". This is the code i tried in the view attribute level get-method.

IF VALUE IS NOT INITIAL.

***

    • Data: lr_confirm_popup TYPE REF TO if_bsp_wd_popup,*

    • lr_comp_controller TYPE REF TO CL_BSP_WD_COMPONENT_CONTROLLER,*

    • lr_wd_ctrl TYPE REF TO CL_BSP_WD_CONTROLLER.*

***

    • IF lr_confirm_popup IS NOT BOUND.*

    • CALL METHOD lr_comp_controller->window_manager->create_popup_2_confirm*

    • EXPORTING*

    • iv_title = 'Window Title Here'*

    • iv_text = 'Message Text Here'*

    • iv_btncombination = if_bsp_wd_window_manager=>co_btncomb_ok "OK Button*

    • RECEIVING*

    • rv_result = lr_confirm_popup.*

***

    • lr_confirm_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_surrounded ).*

    • lr_confirm_popup->set_on_close_event( iv_event_name = 'POPUP_CLOSED' iv_view = lr_wd_ctrl ).*

    • ENDIF.*

    • lr_confirm_popup->open( ).*

***

*ENDIF.

The error message is as follows:

Error when processing your request

Note

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

The error occurred on the application server dcr_DCR_02 and in the work process 1 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: GET_AREA of program ZL_ZHMS_CRM_TABVIEW_CN00======CP

Method: IF_BSP_MODEL_BINDING~GET_ATTRIBUTE of program CL_BSP_MODEL==================CP

Method: RESOLVE_MODEL_BINDING of program CL_THTMLB_INPUTFIELD==========CP

Method: IF_BSP_ELEMENT~DO_AT_BEGINNING of program CL_THTMLB_INPUTFIELD==========CP

Please advise me on fixing this error.

Thanks and Regards,

Arun V.

Edited by: Arunmozhi_06 on Mar 6, 2012 9:15 AM

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

check below code:

Instead of -

  • IF lr_confirm_popup IS NOT BOUND.

  • CALL METHOD lr_comp_controller->window_manager->create_popup_2_confirm

put-

  • IF lr_confirm_popup IS NOT BOUND.

CALL METHOD comp_controller->window_manager->create_popup_2_confirm

No need to use lr_comp_controller.

Best Regards

Basav

Former Member
0 Kudos

Hi Basavaraj,

I tried that before but it says syntax error as "comp_controller" is not declared. Following is the error:

"The field "COMP_CONTROLLER" is unknown"

Regards,

Arun V

0 Kudos

Hi Arun,

First of all, let me tell you that comp_controller is an attribute available in the view controller class (____IMPL).

So you cannot just refer to from the context node class.

1. Either you have to access the view controller instance of the context node class and access the attribute comp_controller.

2. Or you should write this logic as an event in the view controller class which is the usually done.

Regards,

Leon

MariusStoica
Active Participant
0 Kudos

Hi Leon,

I'm new to SAP CRM as well and I'm trying to get my head around the new concepts.

I received the same error message, because I used the same "concept" code.

What I'm trying to achieve is a popup screen for "user + password" input. I tried this easy example but it seems it's not so easy.

Now, u're talking about a "view controller" class.

At the moment I'm using the new created class ZCL_IM_ORDER_SAVE to do some things after save, but in the same time I need this popup.

In what view do I need to find this controller ?

Here are the only data that I can think of that can help you share the relevant info

Do I access that view with "BSP_WD_CMPWB"?

Thank you in advance,

Marius

Former Member
0 Kudos

Hi,

Can you check what value you are getting in lr_wd_ctrl while calling SET_ON_CLOSE_EVENT method.

It should be the implementation class of the view where you are trying to give a popup message.

Best Regards

Basav

Former Member
0 Kudos

Hi Basavaraj,

I found it's due to null reference error with "lr_comp_controller" which is still not bound as Leon has specified below.

I have declared "lr_comp_controller" attribute in the implementing class and instantiated in within the set method for the view. But i'm clueless on how it's still unbound and please clarify on how to make it instantiated or bound.

Thanks and Regards,

Arun V.

Former Member
0 Kudos

Hi ,

Change the below code:

  • lr_confirm_popup->set_on_close_event( iv_event_name = 'POPUP_CLOSED' iv_view = lr_wd_ctrl ).

To.:

  • lr_confirm_popup->set_on_close_event( iv_event_name = 'POPUP_CLOSED' iv_view = me ).

Hope it works.

Best Regards

Basav

Former Member
0 Kudos

Hi Basavaraj,

I tried it with ME-> reference. But it throws an error due to formal parameter incompatibility with "iv_view".

ERROR:- "ME" is not type-compatible with formal parameter "IV_VIEW".

Thanks and Regards,

Arun V.

0 Kudos

Hi Arun,

Possibly the component controller that you are referring is not assigned and hence null.

Also declare the popup variable as a class variable(in the attributes tab)

Refer the code:

data: lv_text  type string,
        lv_title type string.


  if not gr_no_tg_popup is bound.

    lv_text = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BT_SERVICE_PSL/NO_TG' ). "#EC NOTEXT
    lv_title = 'Product Service Letter'(003). "#EC NOTEXT
    call method comp_controller->window_manager->create_popup_2_confirm
      exporting
        iv_title          = lv_title
        iv_text           = lv_text
        iv_btncombination = if_bsp_wd_window_manager=>co_btncomb_ok
      receiving
        rv_result         = gr_no_tg_popup.

  endif.

  if gr_no_tg_popup is bound.
    gr_no_tg_popup->open( ).
  endif.

Regards,

Leon

Former Member
0 Kudos

Hi Leon,

I declared the pop-up variable in the implementing class and tried it, but in vain. Please clarify me on how to declare the component controller that we use to call the method " create_popup_2_confirm".

call method comp_controller->window_manager->create_popup_2_confirm

exporting

iv_title = lv_title

iv_text = lv_text

iv_btncombination = if_bsp_wd_window_manager=>co_btncomb_ok

receiving

rv_result = gr_no_tg_popup.

I'm confused on how to declare the instance of the "comp_controller" like whether to declare inside the method or as attribute of implementing class and then calling the method for pop-up that you have specified before. Please clarify me.

Regards,

Arun V.

Edited by: Arunmozhi_06 on Mar 6, 2012 11:05 AM

Edited by: Arunmozhi_06 on Mar 6, 2012 11:15 AM