Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SET_HANDLER_HOBJ_NULL

Former Member
0 Kudos
632

Hi,

unfortunately I am all at sea. I always get this dump. I know that I have forget something but I don't know.

Here my coding.


CLASS lcl_event_tree DEFINITION.

  PUBLIC SECTION.
    METHODS:
      handle_expand_no_children
                          FOR EVENT expand_no_children
                          OF cl_gui_simple_tree
                          IMPORTING node_key.

ENDCLASS.                    "lcl_event_tree DEFINITION


CLASS lcl_event_tree IMPLEMENTATION.

  METHOD handle_expand_no_children.

    DATA: node_table TYPE node_table_type,
          node TYPE ztreenode.

    G_EVENT = 'EXPAND_NO_CHILDREN'.

    IF node_key = 'Child1'.
* add two nodes to the tree control (the children of 'Child1')

* Node with key 'New1'
      CLEAR node.
      node-node_key = c_nodekey-new1.
      node-relatkey = c_nodekey-child1.
      node-relatship = cl_gui_simple_tree=>relat_last_child.
      node-isfolder = ' '.
      node-text = 'New1'(ne1).
      APPEND node TO node_table.

* Node with key 'New2'
      CLEAR node.
      node-node_key = c_nodekey-new2.
      node-relatkey = c_nodekey-child1.
      node-relatship = cl_gui_simple_tree=>relat_last_child.
      node-n_image = '@10@'.
      node-expander = ' '.
      node-text = 'New2'(ne2).
      APPEND node TO node_table.

      CALL METHOD g_tree->add_nodes
        EXPORTING
          table_structure_name           = 'ZTREENODE'
          node_table                     = node_table
        EXCEPTIONS
          failed                         = 1
          error_in_node_table            = 2
          dp_error                       = 3
          table_structure_name_not_found = 4
          OTHERS                         = 5.
      IF sy-subrc <> 0.

      ENDIF.
    ENDIF.
  ENDMETHOD.                    "handle_expand_no_children
ENDCLASS.                    "lcl_event_tree IMPLEMENTATION


* create a container for the tree control
  CREATE OBJECT g_custom_container
    EXPORTING      " the container is linked to the custom control with the
          " name 'TREE_CONTAINER' on the dynpro
      container_name              = 'CONTAINER'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5.
  IF sy-subrc <> 0.

  ENDIF.

* create a tree control
  CREATE OBJECT g_tree
    EXPORTING
      parent                      = container_1_2
      node_selection_mode         = cl_gui_simple_tree=>node_sel_mode_single
    EXCEPTIONS
      lifetime_error              = 1
      cntl_system_error           = 2
      create_error                = 3
      failed                      = 4
      illegal_node_selection_mode = 5.
  IF sy-subrc <> 0.

  ENDIF.

  SET HANDLER gr_event_tree->handle_expand_no_children FOR g_tree.

  PERFORM build_node_table USING node_table.

  CALL METHOD g_tree->add_nodes
    EXPORTING
      table_structure_name           = 'ZTREENODE'
      node_table                     = node_table
    EXCEPTIONS
      failed                         = 1
      error_in_node_table            = 2
      dp_error                       = 3
      table_structure_name_not_found = 4
      OTHERS                         = 5.
  IF sy-subrc <> 0.

  ENDIF.

4 REPLIES 4

uwe_schieferstein
Active Contributor
0 Kudos
198

Hello

There are two ways to get rid of the ABAPdump.

(1) Create the instance of your event handler class

(2) Define your event handler method as static method


...
" Event handler method is an instance method so we should create the instance before we call the method
CREATE OBJECT gr_event_tree.
SET HANDLER gr_event_tree->handle_expand_no_children FOR g_tree.

...


CLASS lcl_event_tree DEFINITION.
 
  PUBLIC SECTION.
    "METHODS:
    CLASS-METHODS:
      handle_expand_no_children
                          FOR EVENT expand_no_children
                          OF cl_gui_simple_tree
                          IMPORTING node_key.  " static method
 
ENDCLASS.                    "lcl_event_tree DEFINITION


...
SET HANDLER gr_event_tree=>handle_expand_no_children FOR g_tree.
...

Regards

Uwe

0 Kudos
198

If you define the Static method, use the classname and method, not the object reference and method:


SET HANDLER lcl_event_tree=>handle_expand_no_children FOR g_tree.

I guess, Uwe made typo on this statement.

Regards,

Naimesh Patel

0 Kudos
198

Hello Naimesh

Thank you for this correction. You are right.

Regards

Uwe

Former Member
0 Kudos
198

Thanks