SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Using Tree Control



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 22, 2007 7:33 pm    Post subject: Using Tree Control Reply with quote

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).

Code:
*
*    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:

Code:
*
*       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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.