TREE STRUCTURE PLSSS HELP

Question:
After creating the Tree structure with the function RS_TREE_CREATE
and adding the nodes to it with the function RS_TREE_ADD_NODE
the tree has to be displayed with the function RS_TREE_LIST_DISPLAY
I have succeeded in doing the above things.But now i want to track where the user clicks on the tree structure.
There is a parameter in RS_TREE_LIST_DISPLAY called user command but i am not sure its for the same thing and if it is i dont know how to use it.So if anyone has worked on it Plss help me.
Thanx a lot
Answer:
The tree display uses call back routines. These are routines which you write and provide the function module with the names of. Then at the appropriate point the function modulw will call your routines back.
Below is an example of what I mean. The routines CB_Top_Of_Page and CB_User_Command are the names of the routines that will be executed during those specified events. Note you have to provide the name of the program in which the routines reside. (In this case your own report).
Regards
R
*
*    Construct the tree
*
     Call Function 'RS_TREE_CONSTRUCT'
          Tables
               Nodetab            = T_Nodes
          Exceptions
              Tree_Failure       = 1
              Id_Not_Found       = 2
              Wrong_Relationship = 3
              Others             = 4.
     If sy-subrc = 0.
*
*       Now display the tree
*
        Set pf-status 'LD_TREE' Of Program 'SAPLSEUT'
            Excluding t_excludes.
        Call Function 'RS_TREE_LIST_DISPLAY'
              Exporting
                 Callback_Program      = Sy-Cprog
                 Callback_User_Command = 'CB_USER_COMMAND'
                 Callback_Top_Of_Page  = 'CB_TOP_OF_PAGE'
              Exceptions
                 Others                = 0.
     Else.
        Message E000 with text-032.
     EndIf.
Endform.
*Eject
**********************************************************************
*
*       Procedure:            CB_TOP_OF_PAGE
*
*       Purpose:              Call back routine for RS_TREE_DISPLAY to
*                             handle the top of page for the tree
*                             display
*
*       Entry:                None
*
*       Exit:                 Relevant top of page displayed
*
*       Called By:
*
*       Calls:
*
*       Modification History:
*
Form CB_Top_Of_Page.                                      "#EC CALLED
     Move c_error_report to g_report_type.
     Perform Top_Of_Page.
EndForm.
*Eject
***********************************************************************
*
*       Procedure:     CB_User_Command
*
*       Purpose:       Handles At User Command events
*                      for RS_TREE_DISPLAY
*
*       Entry:         Node Table
*                      User Command
*
*       Exit:          Exit Flag    True - exit,  false continue
*                      List_refresh True - Refresh list,  false not
*
*       Called By:
*
*       Calls:
*
*       Modification History:
*
*   Date    Reason                                         Version  Who
*
Form CB_User_Command Tables NodeTab Structure SnodeText
                      using pu_ucomm        like rsnewleng-fcode
                   changing pc_exit         type c
                            pc_list_refresh type c.       "#EC CALLED
*
     Move True  to pc_exit.
     Move False to pc_list_refresh.
     Case pu_ucomm.
          When 'TRPI'.
*
*              Pick Line. If it's a hotspot then display the order
*              or the delivery otherwise expand/compress the tree
*
               If NodeTab-Hotspot5 = True.
*
*                 Scuttle up the tree until an order or delivery is
*                 found and then open that object for change
*
                  Read Table t_nodes with key id = NodeTab-Parent.
                  While t_nodes-parent <> '000000' and
                        t_nodes-type <> c_pr_order and
                        t_nodes-type <> c_dlvy.
                        Read Table t_nodes with key id = t_nodes-parent.
                  EndWhile.
                  Case t_nodes-type.
                       When c_dlvy.
                            Set Parameter id 'VL' field t_nodes-text4.
                            Call Transaction 'VL02'
                                 And Skip First Screen.
                       When c_pr_order.
                            Set Parameter Id 'ANR' field t_nodes-text4.
                            Call Transaction 'CO02'
                                 And skip first screen.
                       When Others.
                            Message E000 with text-033.
                   EndCase.
               EndIf.
               Move True to pc_list_refresh.
          When 'TREP'.
*
*              Expand Tree
*
               Move True to pc_list_refresh.
          When 'TRCM'.
*
*              Collapse
*
               Move True to pc_list_refresh.
          When 'TRZM'.
*
*              Highlight branch
*
               Move True to pc_list_refresh.
          When Others.
               Break-point.
     EndCase.
     If pc_list_refresh = True.
        pc_exit = false.
     EndIf.
EndForm.
This actually shows a neat technique whereby you can have standard code extended by other programmers whilst not actually altering the base standard.
I use a series of routines for writing BDC's etc. The parameters for a specific BDC are held in a table which is read at the start of the run.
The table contains fields for a program and routine name to be called if the BDC fails and the end users want a mail sent to some one about the failure. The program called is a seperate program written on site for that specific client so I don't want to disturb the standard code. This is how I acheive this:
*
*       Mail a user ?
*
        If not w__ydcset-genmail is initial.
           If not w__ydcset-mailprog is initial.
              Perform (w__ydcset-genmail)
                      in program (w__ydcset-mailprog)
                           tables ZBDC_Table
                            using p_trans p_text sy-uname if found.
           EndIf.
        EndIf.
The perform calls the routine which is changeable for each user and BDC. this is the same type of thing that SAP are doing in the RS_TREE_LIST_DISPLAY function.
(btw - all these routines are available from the repository in Docs.zip)
Regards
R
Answer:
Thanx a lot for ur reply
I have used the fucntion RS_TREE_CREATE to create a tree which does not have any tables parameter.
To add a node i have used RS_TREE_ADD_NODE
and this is within a nested loop.
How do i get where the user has clicked on the TREE .I dont have to handle the exit and cancel buttons.
For example:
If the user clicks on the last level in the tree i have to call a certain transaction
In ur code u read the internal table that has the node id.In my case theres is no such internal table.
Thanx a lot
Answer:
No idea how you do that. I'd have to write a small program myself and at the moment I'm upto my own ears let alone anybody elses.......
Off the top of my head I would have a look at system fields such as SY-LILLI and then read the line from the report using READ LINE to get the contents of the line back. Then you pick the line apart in your code.
R

More Articles:

How to know the last run info for a ABAP Program?
Badi's Help?
VL10 : add some selection criteria?
Link between BSEG and MSEG items?
dynamic report headers(something challenging)?
How can I upload a picture file in SAP?