Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

closing pop-up box error

Hello,

Im getting a frustrating problem' Access via 'NULL' object reference not possible ' when I try to close the popup box , I am assuming its something to do with either setting up my nodes or attributes, unfortunately i tried everything I could but nothing worked.

this is the part of the code action to generate a popup box, subscribe and assign the OK button an action

method ONACTIONADD_NAME .

Data: context_node type ref to if_wd_context_node.

data lv_action_view TYPE REF TO if_wd_view_controller.

DATA lv_title TYPE string.

DATA lo_nd_add_name TYPE REF TO if_wd_context_node.

DATA lo_el_add_name TYPE REF TO if_wd_context_element.

DATA ls_add_name TYPE wd_this->element_add_name.

data lo_window_manager type ref to if_wd_window_manager.

data lo_api_component type ref to if_wd_component.

data lo_window type ref to if_wd_window.

  • generate a popup box

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_window_manager = lo_api_component->get_window_manager( ).

lo_window = lo_window_manager->create_window(

window_name = 'W_ADD_NAME'

title = 'Add a Tester'

close_in_any_case = abap_false

message_display_mode = if_wd_window=>co_msg_display_mode_selected

close_button = abap_true

button_kind = if_wd_window=>co_buttons_okcancel

message_type = if_wd_window=>co_msg_type_none

default_button = if_wd_window=>co_button_ok

).

  • Subscribe the action handler methods to the popup ok and cancel buttons

lv_action_view = wd_this->wd_get_api( ).

lo_window->subscribe_to_button_event(

button = if_wd_window=>co_button_ok

action_name = 'ON_OK_ADD_NAME'

action_view = lv_action_view

).

lo_window->open( ).

endmethod.

and this is the action where I have the issue of closing the popup box

DATA lo_nd_ui_manipulation TYPE REF TO if_wd_context_node.

DATA lo_nd_add_name TYPE REF TO if_wd_context_node.

DATA lo_el_add_name TYPE REF TO if_wd_context_element.

DATA lo_nd_sname TYPE REF TO if_wd_context_node.

DATA ls_add_name TYPE wd_this->element_add_name.

DATA lo_nd_sname_copy TYPE REF TO if_wd_context_node.

DATA lt_sname_copy TYPE wd_this->elements_sname_copy.

DATA lv_msg_text TYPE string.

DATA lv_param1 TYPE symsgv.

DATA lv_param2 TYPE symsgv.

DATA lv_param3 TYPE symsgv.

DATA lv_elements_count TYPE i.

data lo_window type ref to if_wd_window.

  • get message manager

data lo_api_controller type ref to if_wd_controller.

data lo_message_manager type ref to if_wd_message_manager.

  • Read the values user entered in add name popup

lo_nd_add_name = wd_context->get_child_node( name = wd_this->wdctx_add_name ).

lo_el_add_name = lo_nd_add_name->get_element( ).

lo_el_add_name->get_static_attributes(

IMPORTING

static_attributes = ls_add_name ).

IF ls_add_name IS INITIAL OR ls_add_name-first_name IS INITIAL.

  • display messages fill in the required field in the pop-up windows

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

RECEIVING

MESSAGE_MANAGER = lo_message_manager.

CALL METHOD lo_message_manager->REPORT_T100_MESSAGE

EXPORTING

MSGID = '00'

MSGNO = 055

MSGTY = 'E' .

ELSE.

  • Check if the name is already present

lo_nd_sname_copy = wd_context->get_child_node( name = wd_this->wdctx_sname_copy ).

CHECK NOT lo_nd_sname_copy IS INITIAL.

CALL METHOD lo_nd_sname_copy->get_static_attributes_table

IMPORTING

table = lt_sname_copy.

READ TABLE lt_sname_copy WITH KEY first_name = ls_add_name-first_name TRANSPORTING NO FIELDS.

IF sy-subrc EQ 0.

  • If a same name exist, raise error message

lv_msg_text = 'name exist, please enter a different name'.

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

RECEIVING

MESSAGE_MANAGER = lo_message_manager.

CALL METHOD lo_message_manager->REPORT_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = lv_msg_text.

ELSE.

  • if the name doesnt exist

lo_nd_sname_copy = wd_context->get_child_node( name = wd_this->wdctx_sname_copy ).

CHECK NOT lo_nd_sname_copy IS INITIAL.

CALL METHOD lo_nd_sname_copy->get_static_attributes_table

IMPORTING

table = lt_sname_copy.

READ TABLE lt_sname_copy WITH KEY first_name = ls_add_name-first_name TRANSPORTING NO FIELDS.

  • IF the name doesnt exist , add name

lo_nd_sname = wd_context->get_child_node( name = wd_this->wdctx_sname ).

CHECK NOT lo_nd_sname IS INITIAL.

lo_nd_sname->bind_structure( new_item = ls_add_name set_initial_elements = abap_false ).

CLEAR lt_sname_copy.

CALL METHOD lo_nd_sname->get_static_attributes_table

IMPORTING

table = lt_sname_copy.

  • add the name to the local context

lo_nd_sname_copy->bind_table( lt_sname_copy ).

  • add the name to the shared data name context

lo_nd_sname->bind_table( lt_sname_copy ).

  • set the table's visible row property in order to show the added record

lv_elements_count = lo_nd_sname_copy->get_element_count( ).

lo_nd_ui_manipulation = wd_context->get_child_node( name = wd_this->wdctx_ui_manipulation ).

lo_nd_ui_manipulation->set_attribute( name = `VISIBLEROW` value = lv_elements_count ).

lv_param1 = ls_add_name-first_name.

lv_param2 = ls_add_name-last_name.

lv_param3 = ls_add_name-c_num.

  • display a successfull message

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

RECEIVING

MESSAGE_MANAGER = lo_message_manager

.

  • report message

CALL METHOD lo_message_manager->REPORT_SUCCESS

EXPORTING

MESSAGE_TEXT = 'succesfully added'.

  • Enable/disable delete button based on lead selection

CALL METHOD wd_comp_controller->manage_delete_button .

  • Save the last action in the context, this data will be shown in the idr

CLEAR lv_msg_text.

lv_msg_text = wd_assist->if_wd_component_assistance~get_text( key = '014' ).

CONCATENATE lv_msg_text ls_add_name-first_name INTO lv_msg_text SEPARATED BY space.

lo_nd_ui_manipulation = wd_context->get_child_node( name = wd_this->wdctx_ui_manipulation ).

lo_nd_ui_manipulation->set_attribute( name = `IDR_LAST_ACTION` value = lv_msg_text ).

lo_window->close( ).

every time I add the lo_window->close( ). I get the Null error.

Thanks in advance

Former Member
replied

Hi Abdul,

I guess that you want the user to be able to modify the data in the table & then have the changes made saved to database. Right? SAP recommends using a BAPI for doing the same. (Using a [Service Call|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9cb5d345-0801-0010-6a8e-fc57c23fd600] you can call a BAPI from within your component & get the desired functionality.) If you however intend to just try out a sample example in your IDES then you can directly try using the normal ABAP MODIFY statement on the database table. Try check the sample code snippet below.

Regards,

Uday

data:
      node_sflight           type ref to if_wd_context_node,
      elem_sflight           type ref to if_wd_context_element,
      lt_elements            type WDR_CONTEXT_ELEMENT_SET,
      stru_sflight           type if_main=>element_sflight_node,
      it_flights             type if_main=>elements_sflight_node.
 
"   navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
    node_sflight_node = wd_context->get_child_node( name = if_main=>wdctx_sflight_node ).
 
"   get element via lead selection
"    elem_sflight_node = node_sflight_node->get_element(  ).
     lt_elements = node_sflight->get_elements( ). 
     
"   get all declared attributes
    loop at lt_elements into elem_sflight.
    elem_sflight->get_static_attributes(
      importing
        static_attributes = stru_sflight ).
        
    append stru_sflight to it_flights.
    endloop.
    
    modify ZSFLIGHT99 from table it_flights.
    if sy-subrc eq 0.
    
    endif.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question