Application Development and Automation 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: 
Read only

Problem with Copied Code finding Public Method

Former Member
0 Likes
968

Hi Guys,

I'm an old R/2 programmer trying to get my head around OO coding.

I have copied, in it's entirety, the SAP example program SAPTLIST_TREE_CONTROL_DEMO, as I'm trying to create a Tree based access to reports (don't ask, the user just wants it!).

I've copied and activate all the standard include programs as follows:

&----


*& Modulpool ZMM_COCKPIT_DISPLAY *

*& *

&----


*& *

*& *

&----


INCLUDE ZMMC_COCKPIT_DISPLAY_TOP.

INCLUDE ZMMC_COCKPIT_DISPLAY_CL1.

INCLUDE ZMMC_COCKPIT_DISPLAY_O01.

INCLUDE ZMMC_COCKPIT_DISPLAY_I01.

INCLUDE ZMMC_COCKPIT_DISPLAY_F01.

All the programs syntax check successfully, except ZMMC_COCKPIT_DISPLAY_F01 which displays the error message <i>'Method "HANDLE_NODE_DOUBLE_CLICK" is unknown or PROTECTED or PRIVATE'</i>, yet this does not prevent the include program from activating.

The Section of code that is failing is:

  • assign event handlers in the application class to each desired event

SET HANDLER G_APPLICATION->HANDLE_NODE_DOUBLE_CLICK FOR G_TREE.

SET HANDLER G_APPLICATION->HANDLE_ITEM_DOUBLE_CLICK FOR G_TREE.

SET HANDLER G_APPLICATION->HANDLE_EXPAND_NO_CHILDREN FOR G_TREE.

SET HANDLER G_APPLICATION->HANDLE_LINK_CLICK FOR G_TREE.

SET HANDLER G_APPLICATION->HANDLE_BUTTON_CLICK FOR G_TREE.

SET HANDLER G_APPLICATION->HANDLE_CHECKBOX_CHANGE FOR G_TREE.,

When double clicking on the HANDLE_NODE_DOUBLE_CLICK, the SAP then goes to the following code in the ZMMC_COCKPIT_DISPLAY_CL1 program:

CLASS LCL_APPLICATION DEFINITION.

PUBLIC SECTION.

METHODS:

HANDLE_NODE_DOUBLE_CLICK

FOR EVENT NODE_DOUBLE_CLICK

OF CL_GUI_LIST_TREE

IMPORTING NODE_KEY,

HANDLE_EXPAND_NO_CHILDREN

FOR EVENT EXPAND_NO_CHILDREN

OF CL_GUI_LIST_TREE

IMPORTING NODE_KEY,

HANDLE_ITEM_DOUBLE_CLICK

FOR EVENT ITEM_DOUBLE_CLICK

OF CL_GUI_LIST_TREE

IMPORTING NODE_KEY ITEM_NAME,

HANDLE_BUTTON_CLICK

FOR EVENT BUTTON_CLICK

OF CL_GUI_LIST_TREE

IMPORTING NODE_KEY ITEM_NAME,

HANDLE_LINK_CLICK

FOR EVENT LINK_CLICK

OF CL_GUI_LIST_TREE

IMPORTING NODE_KEY ITEM_NAME,

HANDLE_CHECKBOX_CHANGE

FOR EVENT CHECKBOX_CHANGE

OF CL_GUI_LIST_TREE

IMPORTING NODE_KEY ITEM_NAME CHECKED.

ENDCLASS.

CLASS LCL_APPLICATION IMPLEMENTATION.

METHOD HANDLE_NODE_DOUBLE_CLICK.

" this method handles the node double click event of the tree

" control instance

" show the key of the double clicked node in a dynpro field

G_EVENT = 'NODE_DOUBLE_CLICK'.

G_NODE_KEY = NODE_KEY.

ENDMETHOD.

Lastly, the class definition, implementation and other required objects are defined in the ZMMC_COCKPIT_DISPLAY_TOP program as:

&----


*& Include ZMMC_COCKPIT_DISPLAY_TOP *

*& *

&----


REPORT SAPTLIST_TREE_CONTROL_DEMO MESSAGE-ID TREE_CONTROL_MSG.

                                        • Screen Element Components *********************

CLASS LCL_APPLICATION DEFINITION DEFERRED.

CLASS CL_GUI_CFW DEFINITION LOAD.

  • CAUTION: MTREEITM is the name of the item structure which must

  • be defined by the programmer. DO NOT USE MTREEITM!

TYPES: ITEM_TABLE_TYPE LIKE STANDARD TABLE OF ZMMC_TREEITM

WITH DEFAULT KEY.

DATA: G_APPLICATION TYPE REF TO LCL_APPLICATION,

G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

G_TREE TYPE REF TO CL_GUI_LIST_TREE,

G_OK_CODE TYPE SY-UCOMM.

(NB: ZMMC_TREEITM is a copy of the structure MTREEITM).

All the programs are active, and have no syntax errors.

Any ideas on how to make the error message vanish? I don't know, but it must be resolved because it is causing the program to abend at runtime, claiming that the HANDLE_NODE_DOUBLE_CLICK cannot pass value 'NULL' to G_TREE.

Thanks in advance.

Stephen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
835

Hi,

Please check the order of includes for where the Objects G_APPLICATION and G_TREE are getting created.

This might give an idea of why the program is trying to pass a 'NULL' to the object reference G_TREE.

Thanks,

Rashmi.

5 REPLIES 5
Read only

uwe_schieferstein
Active Contributor
0 Likes
835

Hello Stephen

I copied the sample report probably the same way like you did, I activated it and it runs perfectly. Double-Clicking on a node displays the corresponding event in the dnpro section on the right side. Please note that I am working on SAP R/3 Enterprise (4.70, basis 6.20).

Regards

Uwe

Read only

Former Member
0 Likes
835

Uwe,

Thanks for replying so promptyly. We are running on ECC5 640, but I don't presume that that should have changed the way the program and it's elements are generated.

I too can double click on the node, and have the corresponding event on the method within my module pool be displayed - but I can't get the program to recognise the link at runtime or a syntax check time.

Regards,

Stephen

Read only

0 Likes
835

Hello Stephen

I have made the following changes in the module pool (double-clicking on node executes a report (PFCG_MASS_TRANSPORT):

<b>Include TLIST_TREE_CONTROL_DEMOTOP:</b>

...
* Fields on Dynpro 100
  DATA: G_EVENT(30),
        G_NODE_KEY TYPE TV_NODEKEY,
        G_ITEM_NAME TYPE TV_ITMNAME.


* Collect nodes and items in globally accessible itabs
  DATA:
    gt_nodes    TYPE TREEV_NTAB,       " added
    gt_items    type ITEM_TABLE_TYPE.  " added

*** INCLUDE TLIST_TREE_CONTROL_DEMOTOP

<b>

METHOD handle_expand_no_children.:</b>

...
* Items of node with key 'New3'
      CLEAR item.
      item-node_key = 'New3'.
      item-item_name = '1'.
      item-class = cl_gui_list_tree=>item_class_text.
      item-length = 11.
      item-usebgcolor = 'X'. "
*      ITEM-TEXT = 'SAPTROX1'.            " deleted
      item-text = 'PFCG_MASS_TRANSPORT'.  " added
...
    CALL METHOD g_tree->add_nodes_and_items
      EXPORTING
        node_table                     = node_table
        item_table                     = item_table
        item_table_structure_name      = 'MTREEITM'
      EXCEPTIONS
        failed                         = 1
        cntl_system_error              = 3
        error_in_tables                = 4
        dp_error                       = 5
        table_structure_name_not_found = 6.
    IF sy-subrc <> 0.
      MESSAGE a000.
    ENDIF.

    APPEND LINES OF node_table TO gt_nodes.  " added
    APPEND LINES OF item_table TO gt_items.   " added
  ENDMETHOD.                    "HANDLE_EXPAND_NO_CHILDREN

<b>Form CREATE_AND_INIT_TREE:</b>

...
* add some nodes to the tree control
* NOTE: the tree control does not store data at the backend. If an
* application wants to access tree data later, it must store the
* tree data itself.

  PERFORM build_node_and_item_table USING node_table item_table.

  CALL METHOD g_tree->add_nodes_and_items
    EXPORTING
      node_table                     = node_table
      item_table                     = item_table
      item_table_structure_name      = 'MTREEITM'
    EXCEPTIONS
      failed                         = 1
      cntl_system_error              = 3
      error_in_tables                = 4
      dp_error                       = 5
      table_structure_name_not_found = 6.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.

  APPEND LINES OF node_table TO gt_nodes.  " added
  APPEND LINES OF item_table TO gt_items.   " added

ENDFORM.                               " CREATE_AND_INIT_TREE

<b>METHOD handle_node_double_click.:</b>

  METHOD  handle_node_double_click.
    " this method handles the node double click event of the tree
    " control instance
    BREAK-POINT.

    " show the key of the double clicked node in a dynpro field
    g_event = 'NODE_DOUBLE_CLICK'.
    g_node_key = node_key.


    DATA:
      ls_node    TYPE treev_node,
      ls_item    TYPE mtreeitm.

    READ TABLE gt_items INTO ls_item
         WITH KEY node_key  = node_key
                  item_name = '1'.
    IF ( syst-subrc = 0     AND
         ls_item-text IS NOT INITIAL ).
      SUBMIT (ls_item-text) VIA SELECTION-SCREEN
        AND RETURN.  " report !!!
    ENDIF.

  ENDMETHOD.                    "HANDLE_NODE_DOUBLE_CLICK

I am not sure if I am correct but it appears that class CL_GUI_LIST_TREE does not provide any method to get hold of the node or item details. Thus, I collect them in my global itabs.

Regards

Uwe

Read only

Former Member
0 Likes
837

Hi,

Please check the order of includes for where the Objects G_APPLICATION and G_TREE are getting created.

This might give an idea of why the program is trying to pass a 'NULL' to the object reference G_TREE.

Thanks,

Rashmi.

Read only

Former Member
0 Likes
835

Uwe,

Thanks for your assistance. In the end, it turns out the syntax error occurred in the SAP standard code I copied as well as in my program. Also, problem with my SAP GUI installation were causing issues with the selection screen behinf ,y transaction, and this was affecting the way the program ran.

This issue has now been resolved.

Thanks for all your help.

Stephen