Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

List Tree (cl_gui_list_tree) node add and item change problem

$
0
0

Hallo!

 

I'm developing an application, which is related with List Tree (to be honest, i'm new to Trees). In this application a user can drag and drop a string from the ALV-Grid into the List Tree.If the Tree does not cantain this string jet, then a new node with unique ID will be created and a new item, connected to this node. If the user the second, third... times drag and drops the same table line, then the node is not to be created, but the item text is to be updated (this text contains number of rag and drops, applied to this table-line/node). I have node found any method, which allow the user to check, if the node with the certain ID already exists. So i decided to to id the following way: i use the method item_set_text. If the node exists, then the text is successfully updated. When the node does not exist, then this method should return an Exception. But It does not! The sy-subrc is always 0. But if the node does not exists, then i get DUMP on screnn FLUSH.

 

gr_list_tree->item_set_text(

       EXPORTING

         node_key          = NODE_ID

         item_name         = '2'

         text              = NEW_TEXT

       EXCEPTIONS

         failed            = 1

         node_not_found    = 2

         item_not_found    = 3

         cntl_system_error = 4

         OTHERS            = 5 ).

 

     CASE sy-subrc.

       WHEN 2.

       "create node and add item

       APPEND INITIAL LINE TO lt_nodes ASSIGNING <ls_node>.

       <ls_node>-node_key    = ....

       <ls_node>-relatkey    = ....

 

       APPEND INITIAL LINE TO lt_items ASSIGNING <ls_item>.

       <ls_item>-node_key    = ....

       <ls_item>-item_name   = .....

 

     ....

 

       CALL METHOD gr_list_tree->add_nodes_and_items

         EXPORTING

           node_table                     = lt_nodes

           item_table                     = lt_items

           item_table_structure_name      = space

         EXCEPTIONS

           failed                         = 1

           cntl_system_error              = 2

           error_in_tables                = 3

           dp_error                       = 4

           table_structure_name_not_found = 5

           OTHERS                         = 6.

       IF sy-subrc <> 0.

       MESSAGE 'Error building right tree' TYPE 'E'.

       ENDIF.

     WHEN 1 OR 3 OR 4 OR 5.

       MESSAGE 'Error adding node' TYPE 'E'.

     ENDCASE.


Why does this method so wrong work? May be anyone know, what the reason is...

Or, as alternative to my way, may be onyone knows, how to get, if the node already exists.

I my head, i can only create my own table and store there the added nodes.. But maybe is there another way?

Help me please.


Viewing all articles
Browse latest Browse all 3125

Trending Articles