Building tree using view crateria in view objects

suppose that i have the following tables "class" ,"group" and "item".
items in table "item" belong to groups in table "group" and groups belong to classes in table "class" .
suppose there is another table called "selling_basket" that contains an id for the customer and also a foreign key for rows in item table for the items he sold and a "Customer" table that contains customers id and other informations.
suppose that i want to build an JSF page that contains a table from a view based on the "customer" table and a tree of herarichy - class
|_group1
|_item1
|_item2
-class2
|_group2
|_item3
|_group3
and when i click on a row on table customer the tree only display the herarichy for items that this customer sold just.

i solve the probel the description as follow :
. the problem : the problem is that when we use the tree model component with the scenario of filtration on the child nodes, we do a normal transactions of steps on the knowledge that the tree will use the master detail behavior as in table component and other ADF Master-details behaviors, so we build two view criteria one on employee and the other on department with the scenario of displaying only the department who has employees with salary equal some certain value, and only shows the employees who has salary equal that value, and on our code we apply the two criteria on the two view objects with the same value we entered to search for , the scenario works well for the top level nodes, but for child nodes it seems it doesn’t work, the behavior make us walk around our selves for why this happened. By debugging options and Tracing what SQL statements that it executes we found that the system execute two statements on the employee view object one with the bind value with the same we inserted and the other with null value, and we notice that the name of the second view object executed is not what we apply the view criteria for(departmentEO_employeeEO_emo_dept_FK_employeeView).
.The solution: we notice that the tree component doesn’t use master detail behavior as in tables, and instead of that it uses the View link assessors (the run time generated view object departmentEO_employeeEO_emo_dept_FK_employeeView ), to get the detailed items, so we should override the action of the View link assessor.
To deal with that we generate the view object rowimpl and viewimpl java classes, in the rowimpl class there is a method to call the link assessors with the following code:
public RowIterator getEmployeesView()
this.getAttributeInternal(EMPLOYEESVIEW);
We write our code:
public RowIterator getEmployeesView()
System.out.println("Here");
ViewObject s=((DepartmentsViewImpl)this.getViewObject()).getViewLinks()[0].getDestination();//we get the employee object by using the view link
// between department and employee
// then we apply the view criteria to that view object and return it as view link
System.out.println("row number "+s.getEstimatedRowCount());
ViewCriteria evc=s.getViewCriteriaManager().getViewCriteria("EmployeesViewCriteria");
s.ensureVariableManager().setVariableValue("nSal",((DepartmentsViewImpl)this.getViewObject()).getnSal());
s.applyViewCriteria(evc);
s.executeQuery();
return s;
Notice that we use the employee view object getted by the view link instead of the master details.
Regards
Mohammad.b.yaseen
Sep 26 2011 @ 11:43
J2EE Team
RealSoft
for more info this the application url :
http://www.4shared.com/file/lgeaYWXa/TreeTestApplication1.html
notice that i diidn't attach the database with the project so you can connect to the local db
Edited by: mohammad.j.b.yaseen on Sep 26, 2011 12:13 PM

Similar Messages

  • How to save JPanel in HashMap and then build tree using this HashMap

    Actually I'm not sure I'm on right way... what I need to do is to build a tree of tests.
    I can imagine that this can be done in such way
    1. add all jpanels into hash map HashMap<String, JPanel> or HashMap<Vector, JPanel> ?
    2. build tree from this hash map
    3. each node contains jpanel
    +root
    |
    +suite1
    |
    test1 -------------> jpanel with components
    |
    test2
    |
    +suite2
    |
    test21
    |
    test22
    If somebody has an idea how to cope with this, please help!

    Yes, I've tried, but i didn't find appropriate option. In Easy setup I can only choose presets. I've tried to edit capture presets, but there were no Log and Capture window settings.

  • Problem occured when create a tree table for master-detail view objects using SQL queries?

    I am programming a tree table for master-detail view objects using SQL queries and these 2 view objects are not simple singel tables queries, and 2 complex SQL are prepared for master and view objects. see below:
    1. Master View object (key attribute is SourceBlock and some varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK,                   
            sum(                   
             case when cntr_list.cntr_size_q = '20'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr20 ,                   
            sum(                   
             case when cntr_list.cntr_size_q = '40'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr40 ,                   
             sum(                   
             case when cntr_list.cntr_size_q = '45'                   
                  then cntr_list.cntr_qty                   
                  else 0 end ) as cntr45                    
    FROM (       
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,       
               scn.CNTR_SIZE_Q,        
               count(scn.CNTR_SIZE_Q) AS cntr_qty        
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2       
        WHERE       
        scm.cmr_n = scn.cmr_n             
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                 
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                 
        AND scm.shift_mode_c = :ShiftModeCode                           
        AND scm.end_terminal_c = :TerminalCode      
        AND scm.start_terminal_c = yb1.terminal_c                  
        AND scm.start_block_n = yb1.block_n                  
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                  
        AND scm.end_terminal_c = yb2.terminal_c                  
        AND scm.end_block_n = yb2.block_n                  
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n           
        AND scn.status_c not in (1, 11)             
        AND scn.shift_type_c = 'V'             
        AND scn.source_c = 'S'       
        GROUP BY yb1.BLOCK_M, scn.CNTR_SIZE_Q       
    ) cntr_list       
    GROUP BY cntr_list.SOURCE_BLOCK
    2. Detail View object (key attributes are SourceBlock and EndBlock and same varaible bindings are used for this view object.)
    SELECT  cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK,                
            sum(                     
             case when cntr_list.cntr_size_q = '20'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr20 ,                     
            sum(                     
             case when cntr_list.cntr_size_q = '40'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr40 ,                     
             sum(                     
             case when cntr_list.cntr_size_q = '45'                     
                  then cntr_list.cntr_qty                     
                  else 0 end ) as cntr45                      
    FROM (         
        SELECT yb1.BLOCK_M as SOURCE_BLOCK,     
               yb2.BLOCK_M as END_BLOCK,  
               scn.CNTR_SIZE_Q,          
               count(scn.CNTR_SIZE_Q) AS cntr_qty          
        FROM  SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2         
        WHERE         
        scm.cmr_n = scn.cmr_n               
        AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')                   
        OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))                   
        AND scm.shift_mode_c = :ShiftModeCode                             
        AND scm.end_terminal_c = :TerminalCode        
        AND scm.start_terminal_c = yb1.terminal_c                    
        AND scm.start_block_n = yb1.block_n                    
        AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n                    
        AND scm.end_terminal_c = yb2.terminal_c                    
        AND scm.end_block_n = yb2.block_n                    
        AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n             
        AND scn.status_c not in (1, 11)               
        AND scn.shift_type_c = 'V'               
        AND scn.source_c = 'S'         
        GROUP BY yb1.BLOCK_M, yb2.BLOCK_M, scn.CNTR_SIZE_Q         
    ) cntr_list         
    GROUP BY cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK
    3. I create a view link to create master-detail relationship for these 2 view objects.
    masterview.SourceBlock (1)->detailview.SourceBlock (*).
    4. I create a tree table using these 2 view objects with master-detail relationship.
    When I set default value for variable bindings of these 2 view objects and the matching records exist, tree table can work well. I can expand the master row to display detail row in UI.
    But I need to pass in dymamic parameter value for variable bindings of these 2 view objects, tree table cannnot work again. when I expand the master row and no detail row are displayed in UI.
    I am sure that I pass in correct parameter value for master/detail view objects and matching records exist.
    Managed Bean:
            DCIteratorBinding dc = (DCIteratorBinding)evaluteEL("#{bindings.MasterView1Iterator}");
            ViewObject vo = dc.getViewObject();
            System.out.println("Before MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            System.out.println("Before MasterView1Iterator ShiftModeCode="+ vo.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo.executeQuery();
            System.out.println("MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
            DCIteratorBinding dc1 = (DCIteratorBinding)evaluteEL("#{bindings.DetailView1Iterator}");
            ViewObject vo1 = dc1.getViewObject();
            System.out.println("Before DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
            System.out.println("Before DetailView1Iterator ShiftModeCode="+ vo1.ensureVariableManager().getVariableValue("ShiftModeCode"));
            vo1.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
            vo1.ensureVariableManager().setVariableValue("DateTo", dateTo);
            vo1.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
            vo1.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
            vo1.executeQuery();
            System.out.println("after DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
    5.  What's wrong in my implementation?  I don't have no problem to implement such a tree table if using simple master-detail tables view object, but now I have to use such 2 view objects using complex SQL for my requirement and variable bindings are necessary for detail view object although I also think a bit strange by myself.

    Hi Frank,
    Thank you and it can work.
    public void setLowHighSalaryRangeForDetailEmployeesAccessorViewObject(Number lowSalary,
                                                                              Number highSalary) {
            Row r = getCurrentRow();
            if (r != null) {
                RowSet rs = (RowSet)r.getAttribute("EmpView");
                if (rs != null) {
                    ViewObject accessorVO = rs.getViewObject();
                    accessorVO.setNamedWhereClauseParam("LowSalary", lowSalary);
                    accessorVO.setNamedWhereClauseParam("HighSalary", highSalary);
                executeQuery();
    but I have a quesiton in this way. in code snippet, it is first getting current row of current master VO to determine if update variables value of detail VO. in my case, current row is possibly null after executeQuery() of master VO and  I have to change current row manually like below.
    any idea?
                DCIteratorBinding dc = (DCIteratorBinding)ADFUtil.evaluateEL("#{bindings.SSForecastSourceBlockView1Iterator}");
                ViewObject vo = dc.getViewObject();           
                vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
                vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
                vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
                vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
                vo.executeQuery();
                vo.setCurrentRowAtRangeIndex(0);
                ((SSForecastSourceBlockViewImpl)vo).synchornizeAccessorVOVariableValues();

  • ALV tree using Objects

    Hi,
    I am making an ALV tree using objects and the code is crashing due to an error in the Screen 100 ( which I am using ). I tried to implement the example provided at http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm but that is not working.
    Can anyone please tell me a working example or a brief tutorial so that I can correct the logical errors in my code.
    Thanks,
    Gaurav

    Hi,
    Check whether u have uncommented the PAI and PBO modules.
    Try this one.
    REPORT ZZZTEST_3
           NO STANDARD PAGE HEADING
           MESSAGE-ID zcs_cs_001.
    1/ Report Name: ZZZ_ALV_TREE_DEMO
    The definition and implementation of the event reciever class
    include <icon>.
    Predefine a local class for event handling to allow the
    declaration of a reference variable before the class is defined.
    class lcl_event_receiver definition deferred.
    data :
         Alv Containers
         tree definition
           o_tree type ref to cl_gui_simple_tree,
         Event Handler
           o_eventreceiver     type ref to lcl_event_receiver,
           o_dockingcontainer TYPE REF TO cl_gui_docking_container.
    data :
        node structures for tree building
          i_nodes type table of abdemonode, " node table def create bespoke
          w_nodes like line of i_nodes,     " work area
          i_tree_event type cntl_simple_events, " Itab for Tree Events
          w_tree_event type cntl_simple_event.   " Work area for Tree Events
    data:
           v_ratio1            type i,     "docking container screen area
    container screen area
           v_action(12)        type c.
    Internal Tables Used for Object ALV Display.
    data:
          i_toolbar           type table of stb_button,  "Tool bar for Grid1
          i_exclude1          type ui_functions,
          i_exclude2          type ui_functions,
          i_groups            type lvc_t_sgrp,  " Group Definitions
          i_selected_rows     type lvc_t_row.   " Select row type
    constants: c_x(1)    type c value 'X',             "Checked
               c_a(1)    type c value 'A'.             "All Layouts
          CLASS lcl_event_receiver DEFINITION
    class lcl_event_receiver definition.
      event receiver definitions for ALV actions
      public section.
        class-methods:
    Status bar
           handle_user_command
            for event user_command of cl_gui_alv_grid
                importing e_ucomm,
    Tree Actions
          handle_node_double_click
            for event node_double_click of cl_gui_simple_tree
            importing node_key,
    Row Double click for dirll down.
           handle_double_click
             for event double_click of cl_gui_alv_grid
                importing e_row
                          e_column
                          es_row_no.
    endclass.
    Implementation
    Every event handler that is specified below should also be set after
    the object has been created.  This is done in the PBO processing.
    with the following command
    SET HANDLER oEventreceiver->handle_toolbar FOR o_Alvgrid.
    class lcl_event_receiver implementation.
      method handle_user_command.
    In event handler method for event USER_COMMAND: Query your
      function codes defined in step 2 and react accordingly.
      endmethod.
    *&      Method handle_double_click
    This method is called when the user double clicks on a line to drill
    down.
    The following are exported from the ALV
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
      method handle_double_click.
    The double click drill down processing should be
    coded in the form below.
      endmethod.
    *&      Method handle_node_double_click
    This method handles the node double click event of the tree
    LVC_S_ROW
    LVC_S_COL
    LVC_S_ROID
      method handle_node_double_click.
       perform f9903_handle_node_double_click using node_key.
      endmethod.
    endclass.
    INITIALIZATION
    INITIALIZATION.
    PERFORM f050_initialize_values.
    FORM f050_initialize_values.
      v_ratio1 = 30.  "tree size
    ENDFORM.                    "  f050_initialize_values
    START-OF-SELECTION
    START-OF-SELECTION.
    END-OF-SELECTION
    END-OF-SELECTION.
      CALL SCREEN 9001.
    *Data Selection
    FORM f9000_objects_create USING    value(pobject)
                                 pparent
                                 value(pratio)
                                 value(prows)
                                 value(pcolumns).
      CASE pobject.
        WHEN  'o_dockingcontainer'.
          IF o_dockingcontainer IS INITIAL.
            CREATE OBJECT o_dockingcontainer
              EXPORTING
               side                        = v_dock_side1
                ratio                       = pratio  "amount of screen
              EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5
                others                      = 6.
            PERFORM f9800_error_handle USING text-e06.
          ENDIF.
          WHEN 'o_tree'.
          IF o_tree IS INITIAL.
            CREATE OBJECT o_tree
             EXPORTING
            LIFETIME                    =
               parent                      = pparent
            SHELLSTYLE                  =
               node_selection_mode         = o_tree->node_sel_mode_single
            HIDE_SELECTION              =
              name                        = 'Transactions'
             EXCEPTIONS
               lifetime_error              = 1
               cntl_system_error           = 2
               create_error                = 3
                failed                     = 4
               illegal_node_selection_mode = 5
               others                      = 6.
            PERFORM f9800_error_handle USING text-e06.
          ENDIF.
        WHEN 'o_eventreceiver'.
          IF o_eventreceiver IS INITIAL.
            CREATE OBJECT o_eventreceiver.
            PERFORM f9800_error_handle USING text-e08.
          ENDIF.
        WHEN OTHERS.
       do nothing
      ENDCASE.
    ENDFORM.                    " f9000_objects_create
    *&      Form  f9100_create_tree
          Create the Tree
         -->P_O_TREE  tree data
    FORM f9100_create_tree USING p_o_tree TYPE REF TO cl_gui_simple_tree.
      REFRESH: i_nodes.
      CLEAR: w_nodes.
    Header Tree Folder
      w_nodes-node_key = 'ROOT'.
      w_nodes-isfolder = c_x.
      w_nodes-expander = c_x.
      w_nodes-text = 'Transactions'.
      APPEND w_nodes TO i_nodes.
    Adding Root Nodes for the tree.
    Key:
    NODE_KEY, RELATKEY, RELATSHIP, HIDDEN, DISABLED, ISFOLDER, N_IMAGE,
    EXP_IMAGE, STYLE, LAST_HITEM, NO_BRANCH, EXPANDER, DRAGDROPID, TEXT
      PERFORM f9101_node_list USING: '1' 'ROOT' '' '' '' c_x '' '' '' '' ''
                              c_x '' 'Sales Orders'.
    Adding subitems for the root node.
      PERFORM f9101_node_list USING:
                            Material Details
                              'VA01' '1' '' '' '' '' '@15@' '' '' '' '' ''
                              '' 'Create Sales Orders',
                            Document Details
                              'VA02' '1' '' '' '' '' '@15@' '' '' '' '' ''
                               '' 'Change Sales Orders'.
      PERFORM f9101_node_list USING: '2' 'ROOT' '' '' '' c_x '' '' '' '' ''
                              c_x '' 'Deliveries'.
    Adding subitems for the root node.
      PERFORM f9101_node_list USING:
                            Material Details
                              'VL01' '2' '' '' '' '' '@15@' '' '' '' '' ''
                              '' 'Create Outbound Delivery',
                            Document Details
                              'VL02' '2' '' '' '' '' '@15@' '' '' '' '' ''
                              '' 'Change Outbound Delivery'.
    add the nodes to the tree object,
      PERFORM f9102_add_treenodes TABLES i_nodes
                                 USING 'ABDEMONODE'  "node definition
                                        p_o_tree.       "tree declaration
    enabling event handlers for the tree
      PERFORM f9103_tree_event_handle USING p_o_tree.
    ENDFORM.                    " f9100_create_tree
    *&      Form  f9101_node_list
          Adding Nodes in a TREE
    FORM f9101_node_list USING    value(pnodekey)
                                 value(prelatkey)
                                 value(prelatship)
                                 value(phidden)
                                 value(pdisabled)
                                 value(pisfolder)
                                 value(pimage)
                                 value(pexpimage)
                                 value(pstyle)
                                 value(plastitem)
                                 value(pnobranch)
                                 value(pexpander)
                                 value(pdragdropid)
                                 value(ptext).
      w_nodes-node_key   = pnodekey.
      w_nodes-relatkey   = prelatkey.
      w_nodes-relatship  = prelatship. "Natural number
      w_nodes-hidden     = phidden.
      w_nodes-disabled   = pdisabled.
      w_nodes-isfolder   = pisfolder.
      w_nodes-n_image    =  pimage.  "Icons / embedded bitmap
      w_nodes-exp_image  = pexpimage. "Icons / embedded bitmap
      w_nodes-style      = pstyle.
      w_nodes-last_hitem = plastitem. "Tree Control: Column Name / Item
      "Name
      w_nodes-no_branch  = pnobranch.
      w_nodes-expander   = pexpander.
      w_nodes-dragdropid = pdragdropid.
      w_nodes-text       = ptext.
      APPEND w_nodes TO i_nodes.
    ENDFORM.                    " f9101_node_list
    *&      Form  f9102_add_treenodes
          Adding the Nodes to the Tree
         -->PI_NODES  Table containg the Nodes
         -->PTABLE    Name of the Table structure name
         -->PO_TREE   tree object
    FORM f9102_add_treenodes TABLES pi_nodes TYPE STANDARD TABLE
                            USING  value(ptable)
                                   po_tree TYPE REF TO cl_gui_simple_tree.
      CALL METHOD po_tree->add_nodes
        EXPORTING
          table_structure_name           = ptable    "may need to change
          node_table                     = pi_nodes[]
        EXCEPTIONS
          error_in_node_table            = 1
          failed                         = 2
          dp_error                       = 3
          table_structure_name_not_found = 4
          OTHERS                         = 5
      PERFORM f9800_error_handle USING text-e10.
    ENDFORM.                    " f9102_add_treenodes
    *&      Form  f9103_tree_event_handle
          Event Handling for Tree.
         -->P_P_O_TREE  text
    FORM f9103_tree_event_handle USING
                                p_o_tree TYPE REF TO cl_gui_simple_tree.
      w_tree_event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
      w_tree_event-appl_event = ' '. " process PAI if event occurs
      APPEND w_tree_event TO i_tree_event.
      CALL METHOD p_o_tree->set_registered_events
          EXPORTING
            events = i_tree_event
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
      IF sy-subrc <> 0.
       MESSAGE A000.
      ENDIF.
      IF o_eventreceiver IS INITIAL.
        CREATE OBJECT o_eventreceiver.
      ENDIF.
      SET HANDLER o_eventreceiver->handle_node_double_click FOR p_o_tree.
    ENDFORM.                    " f9103_tree_event_handle
         -->P_IEXCLUDE  text
         -->P_1150   text
    FORM f9200_exclude_functions USING   pexclude LIKE i_exclude1
                                   value(pfunction).
      DATA: l_exclude TYPE ui_func.
      l_exclude = pfunction.
      APPEND l_exclude TO pexclude.
    ENDFORM.                    " f9200_exclude_functions
    *&      Form  f9903_handle_node_double_click
          This form is used to handle the double click event for the tree
         -->P_NODE_KEY  Node clicked.
    FORM f9903_handle_node_double_click USING  p_node_key.
      CASE p_node_key.
        WHEN 'VA01'.
         SUBMIT ZZZ_TEST AND RETURN.
         CALL TRANSACTION 'VA01'. " and skip first screen.
        WHEN 'VA02'.
          CALL TRANSACTION 'VA02'. " and skip first screen.
        WHEN 'VL01'.
          CALL TRANSACTION 'VL01'. " and skip first screen.
        WHEN 'VL02'.
          CALL TRANSACTION 'VL02'. " and skip first screen.
        WHEN OTHERS.
        do nothning.
      ENDCASE.
    ENDFORM.                    " f9903_handle_node_double_click
    *&      Form  f9700_free_objects
    This form handles the freeing of the following objects
    ALV
    Docking Container
         -->P_O_ALVGRID  text
         -->P_0020   text
         -->P_0021   text
    FORM f9700_free_objects USING pobject
                        value(ptype)
                        value(ptext).
    Need to type the field symbol or it does not work
      CASE ptype.
        WHEN 'DOCKING'.
          DATA: l_odock TYPE REF TO cl_gui_docking_container.
          l_odock = pobject.
          IF NOT ( l_odock IS INITIAL ).
            CALL METHOD l_odock->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error = 2
                OTHERS            = 3.
            CLEAR: pobject, l_odock.
            PERFORM f9800_error_handle USING ptext.
          ENDIF.
        WHEN 'TREE'.
          DATA: l_otree TYPE REF TO cl_gui_simple_tree.
          l_otree = pobject.
          IF NOT ( l_otree IS INITIAL ).
            CALL METHOD l_otree->free
              EXCEPTIONS
                cntl_error        = 1
               cntl_system_error  = 2
                OTHERS            = 3.
            CLEAR: pobject, l_otree.
            PERFORM f9800_error_handle USING ptext.
          ENDIF.
        WHEN OTHERS.
       do something.
      ENDCASE.
    ENDFORM.                    " f9700_free_objects
    *&      Form  f9800_error_handle
          Handles Errors
         -->P_PTEXT  text
    FORM f9800_error_handle USING    value(ptext).
      IF sy-subrc NE 0.
    add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
             EXPORTING
                  titel = text-e01
                  txt2  = sy-subrc
                  txt1  = ptext.
      ENDIF.
    ENDFORM.                    " f9800_error_handle
    *PBO & PAI Modules
    *&      Module  STATUS_9001  OUTPUT
          text
    module status_9001 output.
    Set the Status Bar
      set pf-status 'Z_STATUS'.
    Set the Title
      set titlebar 'Z_TITLE'.
      perform f9000_objects_create using:
                create docking container
                  'o_dockingcontainer' '' v_ratio1 '' '',
                create a tree
                  'o_tree' o_dockingcontainer '' '' '',
                Create the event reciever
                  'o_eventreceiver' '' '' '' ''.
    Create the Tree View.
      perform f9100_create_tree using o_tree.
    endmodule.                 " STATUS_9001  OUTPUT
    *&      Module  USER_COMMAND_9001  INPUT
          text
    module user_command_9001 input.
      case sy-ucomm.
        when 'EXIT' or  'CANC'.
          perform f9700_free_objects using:
                        o_tree 'TREE' text-E03,
                        o_dockingcontainer 'DOCKING' text-E05,
                        o_eventreceiver 'EVENT' text-e09.
    leave program.
          leave.    " to SCREEN 0.
        when 'BACK'.
          perform f9700_free_objects using:
                        o_tree 'TREE' text-E03,
                        o_dockingcontainer 'DOCKING' text-e05,
                        o_eventreceiver 'EVENT' text-E09.
          set screen '0'.
          leave screen.
        when others.
      endcase.
    endmodule.                 " USER_COMMAND_9001  INPUT
    Get back to me if u have any queries. Give me ur mail id, i will send one more sample code for ALV tree. This sample program will display only Tree not grid u can add ALV grid too.
    Thanks & Regards,
    Judith.

  • Dynamic tree UI element in the view

    Dear All,
         Can anyone provide me with the code snippet for Dynamic Tree UI element in the view. I need to show the tree which should be generated dynamically.
    Thanks alot in advance!
    Points will be rewarded, Please its urgent!
    Cheers,
    Darshna.

    Hi ,
    sorry for the late reply... here is the code for onActionLoadchildren .. i am sure you wont understand this.. but lets try...
    DATA:
        element_parent  TYPE REF TO if_wd_context_element,
        lv_object_key1   type string,
        lv_object_type  type string.
    DATA:
           node_root_entry                     TYPE REF TO if_wd_context_node,
           elem_root_entry                     TYPE REF TO if_wd_context_element,
           stru_root_entry                     TYPE if_structure_view_new=>element_root_entry ,
           item_valid_from                     LIKE stru_root_entry-valid_from,
           item_plant                          LIKE stru_root_entry-plant,
           item_equi_key                       LIKE stru_root_entry-equi_key,
           item_object_key                     LIKE stru_root_entry-object_key,
           item_object_type                    TYPE string,
           item_path                           TYPE string,
           item_parent_path                    TYPE string,
          context_node                        TYPE REF TO if_wd_context_node,
           root_entry                          TYPE if_structure_view_new=>element_selected_entry.
          l_ref_componentcontroller           TYPE REF TO ig_componentcontroller.
    DATA:
         node_root_info                    TYPE REF TO if_wd_context_node,
         elem_root_info                    TYPE REF TO if_wd_context_element,
          stru_root_info                    TYPE if_structure_view_new=>element_root_info .
    DATA:
          element                            TYPE REF TO if_wd_context_element,
          node_selected_entry                TYPE REF TO if_wd_context_node,
          elem_selected_entry                TYPE REF TO if_wd_context_element.
    DATA:
          ls_hier_return      TYPE rplm_ts_struc_elements,
          lt_hier_return      TYPE TABLE OF rplm_ts_struc_elements,
          ls_hier_return_temp TYPE rplm_ts_struc_elements,
          lt_hier_return_temp TYPE TABLE OF rplm_ts_struc_elements,
          ls_hier_level       TYPE rplm_ts_hier_level,
          lt_hier_level       TYPE TABLE OF rplm_ts_hier_level,
          ls_hier_return_sort TYPE rplm_mt_ts_hier,
          lt_hier_return_sort TYPE TABLE OF rplm_mt_ts_hier.
      DATA:
           temp_hier_level TYPE if_structure_view_new=>element_hier_level,
           lt_hier_temp    TYPE TABLE OF if_structure_view_new=>element_hier_level,
           lt_temp         TYPE TABLE OF if_structure_view_new=>element_hier_level.
      DATA:
           lc_path       TYPE string,
           lv_object_key TYPE string.
      DATA:
           lv_hier_lines TYPE i.
      DATA:
          node_entries                        TYPE REF TO if_wd_context_node,
           node_sub_entries                    TYPE REF TO if_wd_context_node,
          elem_sub_entries                    TYPE REF TO if_wd_context_element,
           stru_sub_entries                    TYPE if_structure_view_new=>element_sub_entries .
      TYPES: BEGIN OF ls_hier_type,             "structure for Hierarchy table
          object(31)      TYPE c,         "Objectkey
          predecessor(31) TYPE c,         "Objectkey Predecessor
          data(2000)      TYPE c,         "Data container
          level           TYPE i,         "level of object in tree
          successors(1)   TYPE c,         "Object has successors: YES/NO/U
          display(1)      TYPE c,         "Object is displayed: YES/NO
          selected(1)     TYPE c,         "Object is selected/marked: YES/NO
          index_predec    LIKE sy-tabix,  "Index predecessor
          strno           TYPE ilom_strno,"External number for func. loc.
                                         "in BOMs used for top object
       END OF ls_hier_type.
      DATA:
           ls_hier     TYPE ls_hier_type,
           lt_hier     TYPE TABLE OF ls_hier_type WITH DEFAULT KEY,
           lt_mat_hier TYPE TABLE OF ls_hier_type WITH DEFAULT KEY.
      " For retrieving Material Data Heirarchy
      DATA:
           lh_stpo_tab     TYPE TABLE OF rihstpx ,
           lwa_stpo_tab    LIKE LINE OF lh_stpo_tab,
           check_menge     TYPE string ,
           check_meins     TYPE string ,
           lwa_mat_hier    LIKE LINE OF  lt_mat_hier ,
           lt_dup_mat_hier LIKE lt_mat_hier,
           lv_len          TYPE i,
           lv_len_temp     TYPE i .
      DATA:
           lv_equnr TYPE equi-equnr,
           lv_tplnr TYPE iflo-tplnr,
           lv_matnr TYPE mast-matnr.
      DATA:
           lv_cnt   TYPE i,
           lv_index TYPE i.
      DATA:
           lv_path        TYPE string,
           lv_parent_path TYPE string,
           pos            TYPE string,
           separator      TYPE c VALUE '.',
           max_level      TYPE i,
           temp_level     TYPE i,
           counter        TYPE i VALUE 1.
      TYPES: BEGIN OF ls_pred_type,             "structure for Hierarchy table
         parent(31)      TYPE c,         "Objectkey Predecessor
         path(2000)      TYPE c,         "Data container
         index_predec    LIKE sy-tabix,  "Index predecessor
      END OF ls_pred_type.
    DATA:
          ls_pred TYPE ls_pred_type,
          lt_pred TYPE TABLE OF ls_pred_type WITH DEFAULT KEY.
    DATA:
          lv_int_obj_key TYPE string,
          obj_len        TYPE i,
          lv_funcloc_ext TYPE ilom_strno,
          lv_funcloc     TYPE itob-tplnr.
    DATA:
          lv_level        TYPE i,
          lv_temp         TYPE i,
          lt_path_entries TYPE string_table.
    DATA:
          node_general                        TYPE REF TO if_wd_context_node,
          elem_general                        TYPE REF TO if_wd_context_element,
          stru_general                        TYPE if_structure_view_new=>element_general ,
          item_collapse_visibility            LIKE stru_general-collapse_visibility.
    DATA:
          elem_context                        TYPE REF TO if_wd_context_element,
          stru_context                        TYPE if_structure_view_new=>element_context ,
          item_expand_all                     LIKE stru_context-expand_all.
    lv_path = path.
    Get Element whose children shall be loaded
      element_parent = wd_context->path_get_element( lv_path ).
    element_parent->get_attribute(
          EXPORTING
            name =  `OBJECT_KEY`
          IMPORTING
            value = LV_object_key ).
    element_parent->get_attribute(
          EXPORTING
            name =  `OBJECT_TYPE`
          IMPORTING
            value = lv_object_type ).
    node_root_entry = wd_context->get_child_node( name = wd_this->wdctx_root_entry ).
    get element via lead selection
      elem_root_entry = node_root_entry->get_element(  ).
    get single attribute
      elem_root_entry->get_attribute(
        EXPORTING
          name =  `VALID_FROM`
        IMPORTING
          value = item_valid_from ).
      elem_root_entry->get_attribute(
          EXPORTING
            name =  `PLANT`
          IMPORTING
            value = item_plant ).
    item_object_type = lv_object_type.
    if lv_object_type eq 'EQUI'.
      item_object_key = ''.
      item_equi_key = lv_object_key.
    elseif lv_object_type eq 'FUNCLOC'.
      item_object_key = lv_object_key.
      item_equi_key = ''.
    ELSE.
      lv_matnr = lv_object_key.
    For BOM, material and Assembly
    endif.
      IF item_object_type EQ 'EQUI'.
        lv_equnr = lv_object_key.
      ELSEif item_object_type eq 'FUNCLOC'.
        lv_tplnr = lv_object_key.
      ELSE.
        LV_MATNR = lv_object_key.
        exit.
      ENDIF.
      CALL FUNCTION 'PM_HIERARCHY_CALL'
        EXPORTING
          datum             = item_valid_from
          equnr             = lv_equnr
          tplnr             = lv_tplnr
          matnr             = lv_matnr
          levdo             = '99'
          levup             = '00'
          sanin             = 'X'
          select_equi       = 'X'
          select_iflo       = 'X'
          select_stpo       = 'X'
          selmod            = 'D'
          stkkz             = ''
          werks             = item_plant
          with_equi         = 'X'
          with_equi_hier    = 'X'
          with_iflo_hier    = 'X'
          with_btyp         = 'X'
          with_mara         = 'X'
          with_ibase_hier   = ''
          capid             = ''
          emeng             = 0
        IMPORTING
          et_hier           = lt_hier
        EXCEPTIONS
          no_hierarchy      = 1
          no_object_defined = 2
          no_selection      = 3
          no_valid_equnr    = 4
          no_valid_matnr    = 5
          no_valid_selmod   = 6
          no_valid_tplnr    = 7
          OTHERS            = 8.
      LOOP AT lt_hier INTO ls_hier.
        ls_hier_return-object_key = ls_hier-object.
        ls_hier_level-object_key = ls_hier-object.
        ls_hier_level-predecessor = ls_hier-predecessor.
        lv_len = strlen( ls_hier-object ).
        IF lv_len GT 1.
          lv_len_temp = lv_len - 1.
        ELSEIF
        lv_len_temp = lv_len.
        ENDIF.
        ls_hier_level-level = ls_hier-level.
        IF ls_hier-object(1) = 'T'.
          ls_hier_return-icon = 'ICON_TECHNICAL_PLACE'.
          ls_hier_return-object_type = 'FUNCLOC'.
          IF ls_hier-successors = 'Y'.
            ls_hier_return-is_leaf = abap_false.
            ls_hier_return-is_expanded = abap_false.
            ls_hier_return-children_loaded = abap_true.
          ELSE.
            ls_hier_return-is_leaf = abap_true.
            ls_hier_return-is_expanded = abap_true.
            ls_hier_return-children_loaded = abap_true.
          ENDIF.
        ELSEIF ls_hier-object(1) = 'E'.
          ls_hier_return-icon = 'ICON_EQUIPMENT'.
          ls_hier_return-object_type = 'EQUI'.
          IF ls_hier-successors = 'Y'.
            ls_hier_return-is_leaf = abap_false.
            ls_hier_return-is_expanded = abap_false.
            ls_hier_return-children_loaded = abap_true.
          ELSE.
            ls_hier_return-is_leaf = abap_true.
            ls_hier_return-is_expanded = abap_true.
            ls_hier_return-children_loaded = abap_true.
          ENDIF.
        ELSEIF ls_hier-object+lv_len_temp(1) = 'M'.
          ls_hier_return-icon = 'ICON_MATERIAL'.
          ls_hier_return-object_type = 'MATERIAL'.
          IF ls_hier-successors = 'Y'.
            ls_hier_return-is_leaf = abap_false.
            ls_hier_return-is_expanded = abap_false.
            ls_hier_return-children_loaded = abap_false.
          ELSE.
            ls_hier_return-is_leaf = abap_true.
            ls_hier_return-is_expanded = abap_true.
            ls_hier_return-children_loaded = abap_true.
          ENDIF.
        ELSEIF ls_hier-object+lv_len_temp(1) = 'X'.
          ls_hier_return-icon = 'ICON_SUPPLY_AREA'.
          ls_hier_return-object_type = 'MATBOM'.
          IF ls_hier-successors = 'Y'.
            ls_hier_return-is_leaf = abap_false.
            ls_hier_return-is_expanded = abap_false.
            ls_hier_return-children_loaded = abap_false.
          ELSE.
            ls_hier_return-is_leaf = abap_true.
            ls_hier_return-is_expanded = abap_true.
            ls_hier_return-children_loaded = abap_true.
          ENDIF.
        ELSEIF ls_hier-object+lv_len_temp(1) = 'A'.
          ls_hier_return-icon = 'ICON_MATERIAL_REVISION'.
          ls_hier_return-object_type = 'MATERIAL'.
          IF ls_hier-successors = 'Y'.
            ls_hier_return-is_leaf = abap_false.
            ls_hier_return-is_expanded = abap_false.
            ls_hier_return-children_loaded = abap_false.
          ELSE.
            ls_hier_return-is_leaf = abap_true.
            ls_hier_return-is_expanded = abap_true.
            ls_hier_return-children_loaded = abap_true.
          ENDIF.
        ENDIF.
    *IF ls_hier-predecessor EQ item_object_key OR ls_hier-object EQ item_object_key.
        APPEND ls_hier_return TO lt_hier_return.
        APPEND ls_hier_level TO lt_hier_level.
    *ENDIF.
        CLEAR lv_len.
        CLEAR lv_len_temp.
      ENDLOOP.
    lt_hier_return_temp = lt_hier_return.
      DESCRIBE TABLE lt_hier LINES lv_hier_lines.
      IF lv_hier_lines EQ 0.
        elem_selected_entry = wd_context->path_get_element( '1.ENTRIES.1' ).
    Get children node
        elem_selected_entry->set_attribute(
        value = abap_true
        name = 'IS_LEAF' ).
      ENDIF.
    *************************************Deleting Now***********
    SORT lt_hier_level BY level DESCENDING.
      LOOP AT lt_hier_level INTO ls_hier_level.
        max_level = ls_hier_level-level.
        EXIT.
      ENDLOOP.
      SORT lt_hier_level BY level ASCENDING.
      LOOP AT lt_hier_level INTO ls_hier_level WHERE level EQ 0.
        ls_hier_level-path = '1.ENTRIES.1'.
        ls_hier_level-parent_path = '1.ENTRIES.1'.
        MODIFY lt_hier_level FROM ls_hier_level.
      ENDLOOP.
    ************************New design to Generate Path and Parent path
    lv_cnt = 0.
    temp_level = 1.
    SORT lt_hier_level BY object_key ASCENDING.
    LOOP AT lt_hier_level INTO ls_hier_level WHERE level EQ 1.
       lv_cnt = lv_cnt + 1.
       lv_parent_path = '1.ENTRIES.1'.
       ls_hier_level-parent_path = lv_parent_path.
       pos = lv_cnt.
       CONCATENATE lv_parent_path separator 'SUB_ENTRIES' separator pos INTO lv_path.
       ls_hier_level-path = lv_path.
       MODIFY lt_hier_level FROM ls_hier_level.
    ENDLOOP.
    temp_level = 1.
    lv_cnt = 0.
    *********************Need to call this for each level ***************************
    WHILE temp_level LT max_level.
       CLEAR lt_pred.
       CLEAR ls_pred.
       LOOP AT lt_hier_level INTO ls_hier_level WHERE level EQ temp_level.
         ls_pred-parent = ls_hier_level-object_key.
         ls_pred-path = ls_hier_level-path.
         APPEND ls_pred TO lt_pred.
       ENDLOOP.
       SORT lt_pred BY parent.
       DELETE ADJACENT DUPLICATES FROM lt_pred.
       LOOP AT lt_pred INTO ls_pred.
         lv_cnt = 0.
         LOOP AT lt_hier_level INTO ls_hier_level WHERE predecessor EQ ls_pred-parent.
           lv_cnt = lv_cnt + 1.
           lv_parent_path = ls_pred-path.
           ls_hier_level-parent_path = lv_parent_path.
           lv_path = ''.
           pos = lv_cnt.
           CONCATENATE lv_parent_path separator 'SUB_ENTRIES' separator pos INTO lv_path.
           ls_hier_level-path = lv_path.
           MODIFY lt_hier_level FROM ls_hier_level.
         ENDLOOP.
       ENDLOOP.
       temp_level = temp_level + 1.
    ENDWHILE.
    LOOP AT lt_hier_level INTO ls_hier_level.
       LOOP AT lt_hier_return INTO ls_hier_return.
         IF ls_hier_level-object_key = ls_hier_return-object_key.
           MOVE-CORRESPONDING ls_hier_level TO ls_hier_return.
           MODIFY lt_hier_return FROM ls_hier_return.
         ENDIF.
       ENDLOOP.
    ENDLOOP.
    SORT lt_hier_return BY path ASCENDING.
    **************************Delete the extra first character returned by PM_HIERARCHY_CALL******
      LOOP AT lt_hier_return INTO ls_hier_return.
        IF ls_hier_return-object_key(1) = 'T'.
          SHIFT ls_hier_return-object_key BY 1 PLACES.
          lv_object_key = ls_hier_return-object_key.
          lv_funcloc_ext = lv_object_key.
          CALL FUNCTION 'CONVERSION_EXIT_TPLNR_OUTPUT'
            EXPORTING
              input  = lv_funcloc_ext
            IMPORTING
              output = lv_funcloc.
          lv_int_obj_key = lv_funcloc.
          ls_hier_return-object_key = lv_int_obj_key.
        ELSEIF ls_hier_return-object_key(1) = 'E'.
          SHIFT ls_hier_return-object_key BY 1 PLACES.
          lv_object_key = ls_hier_return-object_key.
          obj_len = strlen( lv_object_key ).
          IF obj_len GE 18.
            lv_object_key = lv_object_key+0(18).
          ENDIF.
          wd_comp_controller->conv_ext_2_int(
           EXPORTING
             iv_object_key_ext =  lv_object_key            " String
             iv_object_type =   'EQUI'               " String
           IMPORTING
             ev_object_key =   lv_int_obj_key                " String
          SHIFT lv_int_obj_key LEFT DELETING LEADING '0'.
          ls_hier_return-object_key = lv_int_obj_key.
        ELSE.
          SHIFT ls_hier_return-object_key BY 1 PLACES.
          lv_object_key = ls_hier_return-object_key.
          obj_len = strlen( lv_object_key ).
          IF obj_len GE 18.
            lv_object_key = lv_object_key+0(18).
          ENDIF.
          SHIFT lv_object_key LEFT DELETING LEADING '0'.
          ls_hier_return-object_key = lv_object_key.
        ENDIF.
        MODIFY lt_hier_return FROM ls_hier_return TRANSPORTING object_key object_key.
      ENDLOOP.
    LOOP AT lt_hier_level INTO ls_hier_level.
       IF ls_hier_level-object_key(1) = 'T'.
         SHIFT ls_hier_level-object_key BY 1 PLACES.
         lv_object_key = ls_hier_level-object_key.
         lv_funcloc_ext = lv_object_key.
         CALL FUNCTION 'CONVERSION_EXIT_TPLNR_OUTPUT'
           EXPORTING
             input  = lv_funcloc_ext
           IMPORTING
             output = lv_funcloc.
         lv_int_obj_key = lv_funcloc.
         ls_hier_level-object_key = lv_int_obj_key.
       ELSEIF ls_hier_level-object_key(1) = 'E'.
         SHIFT ls_hier_level-object_key BY 1 PLACES.
         lv_int_obj_key = ls_hier_level-object_key.
         obj_len = strlen( lv_int_obj_key ).
         IF obj_len GE 18.
           lv_int_obj_key = lv_int_obj_key+0(18).
         ENDIF.
         wd_comp_controller->conv_ext_2_int(
          EXPORTING
            iv_object_key_ext =  lv_int_obj_key            " String
            iv_object_type =   'EQUI'               " String
          IMPORTING
            ev_object_key =   lv_int_obj_key                " String
         SHIFT lv_int_obj_key LEFT DELETING LEADING '0'.
         ls_hier_level-object_key = lv_int_obj_key.
       ELSE.
         SHIFT ls_hier_level-object_key BY 1 PLACES.
         lv_int_obj_key = ls_hier_level-object_key.
         obj_len = strlen( lv_int_obj_key ).
         IF obj_len GE 18.
           lv_int_obj_key = lv_int_obj_key+0(18).
         ENDIF.
         SHIFT lv_int_obj_key LEFT DELETING LEADING '0'.
         ls_hier_level-object_key = lv_int_obj_key.
       ENDIF.
       MODIFY lt_hier_level FROM ls_hier_level TRANSPORTING object_key object_key.
    ENDLOOP.
    *********************Getinfo if root node else call Get_Children_Info to generate the structure as well*******
      IF lv_path EQ '1.ENTRIES.1'.
        element = wd_context->path_get_element( lv_path ).
      navigate from <ENTRIES> to <SUB_ENTRIES> via lead selection
        node_sub_entries = element->get_child_node( name = 'SUB_ENTRIES' ).
        element->get_attribute( EXPORTING name = 'OBJECT_KEY'
                                 IMPORTING value = item_object_key ).
        element->get_attribute( EXPORTING name =  `OBJECT_TYPE`
                                IMPORTING value = item_object_type ).
    ****************Get Info of Technical Objects*************
        wd_comp_controller->get_children_info(
          EXPORTING
            iv_lt_list =     lt_hier_return           " Rplm_Tt_Mt_Struc
            iv_path = ''
            iv_hier_level  = lt_hier_level
          IMPORTING
            ev_lt_full =      lt_hier_return                   " Rplm_Tt_Mt_Struc
    Create the strcuture by binding the entries to Node which is bound to the table
    element = wd_context->path_get_element( lc_path ).
    Get children node
            node_sub_entries = element->get_child_node( 'SUB_ENTRIES' ).
            CALL METHOD node_sub_entries->bind_table
              EXPORTING
                new_items            = lt_hier_return
                set_initial_elements = abap_true.
      @TODO handle not set lead selection
       IF ( node_entries IS INITIAL ).
       ENDIF.
       lv_temp = 1.
    ***************Sort the LT_HIER_TABLE appropriately ******
       LOOP AT lt_hier_return INTO ls_hier_return .
         MOVE-CORRESPONDING ls_hier_return TO ls_hier_return_sort.
         ls_hier_return_sort-path_length = strlen( ls_hier_return_sort-path ).
         APPEND ls_hier_return_sort TO lt_hier_return_sort.
       ENDLOOP.
       SORT lt_hier_return_sort BY path_length ASCENDING path ASCENDING.
       CLEAR lt_hier_return.
       LOOP AT lt_hier_return_sort INTO ls_hier_return_sort.
         MOVE-CORRESPONDING ls_hier_return_sort TO ls_hier_return.
         APPEND ls_hier_return TO lt_hier_return.
       ENDLOOP.
    *wd_comp_controller->gv_master_data = lt_hier_return.
       LOOP AT lt_hier_return INTO ls_hier_return.
         lv_path = ls_hier_return-path.
         lc_path = ls_hier_return-parent_path.
         IF lv_path NE '1.ENTRIES.1'.
           element = wd_context->path_get_element( lc_path ).
    Get children node
           node_sub_entries = element->get_child_node( 'SUB_ENTRIES' ).
    Now, create the children elements
           element->get_attribute( EXPORTING name = 'OBJECT_KEY'
                                   IMPORTING value = ls_hier_level-predecessor ).
    Create the strcuture by binding the entries to Node which is bound to the table
           CALL METHOD node_sub_entries->bind_structure
             EXPORTING
               new_item             = ls_hier_return
               set_initial_elements = abap_false.
         ENDIF.
       ENDLOOP.
    Only when a new level is reached we create one more child node
    else we attach our elements to same child node
        element = wd_context->path_get_element( item_path ).
    Get children node
        element->set_attribute(
        value = abap_false
        name = 'IS_EXPANDED' ).
      ENDIF.
      navigate from <CONTEXT> to <GENERAL> via lead selection
      node_general = wd_context->get_child_node( name = wd_this->wdctx_general ).
      get element via lead selection
      elem_general = node_general->get_element(  ).
      get single attribute
      elem_general->set_attribute(
        name =  `COLLAPSE_VISIBILITY`
        value = abap_false ).
      node_selected_entry = wd_context->get_child_node( name = if_structure_view_new=>wdctx_selected_entry ).
      get element via lead selection
      elem_selected_entry = node_selected_entry->get_element(  ).
      get single attribute
      elem_selected_entry->set_attribute(
          name =  `OBJECT_KEY`
          value = '' ).
      elem_selected_entry->set_attribute(
            name =  `OBJECT_TYPE`
            value = '' ).
    get element via lead selection
      elem_context = wd_context->get_element(  ).
    get single attribute
      elem_context->set_attribute(
        name =  `EXPAND_ALL`
        value = abap_false ).
      wd_this->enable_buttons(
    endmethod.

  • TREE -  Built Only on Tables/Views Found in Application Schemas

    Problem
    When creating a "TREE" region using the wizard it prompts for a "schema name". The problem is that the table/view I would like to build a "TREE" on does not exist in the schemas listed by the wizard. Only the schemas that are associated with applications in the workspace are listed. It is not possible to base a "TREE" on a table/view that exists outside those schemas listed. This is a point of frustration because the parsing schema/user for my app has privileges to select from the table/view in the non-listed schema.
    Example
    Here is an example I tried. I want to create a tree of all breadcrumb entries (breadcrumb map) in a selected app. I used the data-dictionary view apex_application_bc_entries that is owned by FLOWS_020200. The view apex_application_bc_entries has a public synonym. My parsing schema user can select from that view.
    I selected create a TREE "Based on a SQL Query"
    SELECT aabe.breadcrumb_entry_id id
    ,aabe.parent_breadcrumb_id pid
    ,aabe.entry_label name
    ,aabe.url link
    ,null a1
    ,null a2
    FROM apex_application_bc_entries aabe
    WHERE application_id = :P20_APPLICATION_ID
    I'm using apex version build 2.2.0.00.32.
    Comment
    I understand a possible workaround would be to build a view of apex_application_bc_entries. That would be a "view of a view" and I prefer not to do that.
    Thoughts?
    Todd

    Have you duplicated the entire development environment on your laptop that exists on the other system, including data sources, databases or XML files, wherever the application is pulling the data from.
    Lawrence   *Adobe Community Expert*
       www.Cartweaver.com
       Complete Shopping Cart Application for
       Dreamweaver, available in ASP, PHP and CF

  • Problems in creation of workbook using Change query local view.

    Hi Experts,
    I have created a Multiprovider by using union of two infocubes and created a Query based on Multiprovider.  I want to restrict one infocube in Change Query local view for creating new workbooks.  In Query global view we drag and drop the Infocube under Filters, but in the Query local view Filter panel is in disable mode. (My requirement is to create the workbooks using change query local view only)
    How can I restrict the one Infocube values in the workbooks by using Change query local view? 
    Thanks in advance.
    Venkat.

    Hi Venkat Prasad
    As you told that the query is on multi provider and the view is not allowing to declare/define filter value
    Just drag the infoprovider info object avilable under packet dimension to rows and right click on it restrict by selecting the name of the info provider when u right click it will show you the option of restrict once u click on it,it will takes to u a pop up where you can able to see the name of info providers and you specify according to it and finally in the display of results if you dont want to to display the info provider name then just right click on the 0infoprovider object under rows go to properties then choose hide option under display.
    Hope its clear a little..!
    Thanks
    K M R
    **Assigning points is the only way of saying thanks in SDN***
    >
    venkata prasad wrote:
    > Hi K M R,
    >
    > Thanks for ur quick response.  Most of the Infoobjects are common for both infocubes. I didn't understand this sentense "retrict the value with the infoprovider which values you are trying to view".
    > Please explian elaborately how to restrict the values speicfic to infoprovider under rows.

  • ALV Tree using ABAP Objects

    Can anyone tell me how to Copy a node on an ALV Tree using context menu ?

    Hello Vidya
    The sample report ZUS_SDN_ALVTREE_CTXMENU demonstrates how to copy nodes on an ALV tree.
    Before showing the entire coding I would like to point out a few crucial parts of the coding:
    (1) Defintion of OUTTAB list
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE  TYPE vbak.
    TYPES: nkey     TYPE lvc_nkey.
    TYPES: ntype    TYPE lvc_value.  " 'VKORG' / 'VTWEG' / 'SPART' / leaf
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    The OUTTAB list contains two additional fields holding the tree key (LVC_NKEY) and the node type.
    (2) The main logic of the report is implemented in event handler method handle_node_ctxmenu_sel.
          WHEN 'COPY_SUBTREE'.
            CALL METHOD go_alvtree->get_subtree
              EXPORTING
                i_node_key       = node_key
              IMPORTING
                et_subtree_nodes = lt_subtree.
            CALL METHOD go_alvtree->get_parent
              EXPORTING
                i_node_key        = node_key
              IMPORTING
                e_parent_node_key = ld_parent_key.
            LOOP AT lt_subtree INTO ld_node_key.
              READ TABLE gt_outtab INTO ls_outtab
                   WITH KEY nkey = ld_node_key.
              APPEND ls_outtab TO lt_outtab.
            ENDLOOP.
            READ TABLE lt_outtab INTO ls_outtab INDEX 1.
            ld_ntype = ls_outtab-ntype.
            DELETE lt_outtab WHERE ( vbeln IS INITIAL ).  " hierarchy nodes
            CASE ld_ntype.
              WHEN 'VKORG'.
                ld_top_key = ld_parent_key.
              WHEN 'VTWEG'.
                ld_vkorg_key = ld_parent_key.
              WHEN 'SPART'.
                ld_vtweg_key = ld_parent_key.
              WHEN 'LEAF'.
                ld_spart_key = ld_parent_key.
            ENDCASE.
    "       Note: similar logic like in routine CREATE_HIERARCHY
            SORT lt_outtab BY vkorg vtweg spart kunnr audat.
            LOOP AT lt_outtab INTO ls_outtab.
    *& Report  ZUS_SDN_ALVTREE_CTXMENU
    *& Based on: BCALV_TREE_03
    REPORT  zus_sdn_alvtree_ctxmenu.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE  TYPE vbak.
    TYPES: nkey     TYPE lvc_nkey.
    TYPES: ntype    TYPE lvc_value.  " 'VKORG' / 'VTWEG' / 'SPART' / leaf
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA:
      gd_repid      TYPE syst-repid,
      gd_okcode     TYPE ui_func,
      go_docking    TYPE REF TO cl_gui_docking_container,
      go_alvtree    TYPE REF TO cl_gui_alv_tree.
    DATA:
      gt_outtab     TYPE ty_t_outtab,  " Sales Document
      gt_fcat       TYPE lvc_t_fcat.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
    * §2. Define an event handler method to build up a context menu
    *     (postfix of event name: _CONTEXT_MENU_REQUEST).
    * This event is fired each time the user klick with the right
    * mouse button on a node.
        CLASS-METHODS:
          handle_node_ctxmenu_req
          FOR EVENT node_context_menu_request OF cl_gui_alv_tree
            IMPORTING
              node_key
              menu,
    * §3. Define an event handler method to respond to a function code
    *     triggered by your menu (postfix: _CONTEXT_MENU_SELECTED).
    * This event is fired when the user selects an entry of the
    * build up context menu.
          handle_node_ctxmenu_sel
          FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
            IMPORTING
              node_key
              fcode
              sender.
    * 'sender' is an implicit event parameter that is provided by
    * ABAP Objects runtime system. It contains a reference to the
    * object that fired the event. You may directly use it to
    * call methods of this instance.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
    * §4. Implement your event handler methods.
      METHOD handle_node_ctxmenu_req.
    * Event parameter 'menu' holds a reference to the standard context
    * menu of ALV Tree (functions 'Expand'/'Collapse' on nodes).
    * You may either append your own functions (separated by a line)
    * or clear the menu if you do not want to allow standard functions.
    * In this case the standard menu is cleared.
        CALL METHOD menu->clear.
    * The next line defines one line of the context menu.
        CALL METHOD menu->add_function
          EXPORTING
            fcode = 'DEL_SUBTREE'
            text  = 'Delete Subtree'(901).        "Delete Subtree
        CALL METHOD menu->add_function
          EXPORTING
            fcode = 'COPY_SUBTREE'
            text  = 'Copy Subtree'(902).        "Copy Subtree
      ENDMETHOD.                    "handle_node_ctxmenu_req
      METHOD handle_node_ctxmenu_sel.
    * At this point of execution, the user selected a menu entry of the
    * menu build up in event handler method handle_node_cm_req.
    * Query your own function codes and react accordingly.
        DATA:
          l_rc TYPE c,
          ld_ntype      TYPE lvc_value,
          ld_parent_key TYPE lvc_nkey,
          ld_node_key   TYPE lvc_nkey,
          lt_subtree    TYPE lvc_t_nkey,
          ls_outtab     TYPE ty_s_outtab,
          ls_last       TYPE ty_s_outtab,
          lt_outtab     TYPE ty_t_outtab.
        DATA:
          ld_vkorg_key   TYPE lvc_nkey,
          ld_vtweg_key   TYPE lvc_nkey,
          ld_spart_key   TYPE lvc_nkey,
          ld_last_key    TYPE lvc_nkey,
          ld_top_key     TYPE lvc_nkey.
        CASE fcode.
          WHEN 'DEL_SUBTREE'.
            CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
                 EXPORTING
                      textline1      = 'Do you really want to delete'(902)
                    textline2      = 'this node and all its subnodes?'(903)
                      titel          = 'Confirmation'(904)
                      cancel_display = ' '
                 IMPORTING
                      answer         = l_rc.
            IF l_rc EQ 'J'.
              CALL METHOD sender->delete_subtree
                EXPORTING
                  i_node_key = node_key.
    * Do not forget to refresh the display when you change the contents
    * of your list.
              CALL METHOD sender->frontend_update.
            ENDIF.
          WHEN 'COPY_SUBTREE'.
            CALL METHOD go_alvtree->get_subtree
              EXPORTING
                i_node_key       = node_key
              IMPORTING
                et_subtree_nodes = lt_subtree.
            CALL METHOD go_alvtree->get_parent
              EXPORTING
                i_node_key        = node_key
              IMPORTING
                e_parent_node_key = ld_parent_key.
            LOOP AT lt_subtree INTO ld_node_key.
              READ TABLE gt_outtab INTO ls_outtab
                   WITH KEY nkey = ld_node_key.
              APPEND ls_outtab TO lt_outtab.
            ENDLOOP.
            READ TABLE lt_outtab INTO ls_outtab INDEX 1.
            ld_ntype = ls_outtab-ntype.
            DELETE lt_outtab WHERE ( vbeln IS INITIAL ).  " hierarchy nodes
            CASE ld_ntype.
              WHEN 'VKORG'.
                ld_top_key = ld_parent_key.
              WHEN 'VTWEG'.
                ld_vkorg_key = ld_parent_key.
              WHEN 'SPART'.
                ld_vtweg_key = ld_parent_key.
              WHEN 'LEAF'.
                ld_spart_key = ld_parent_key.
            ENDCASE.
            SORT lt_outtab BY vkorg vtweg spart kunnr audat.
            LOOP AT lt_outtab INTO ls_outtab.
              IF ( ld_ntype = 'VKORG' ).
                "   new sales organisation
                IF ( ls_outtab-vkorg = ls_last-vkorg ).
                ELSE.
                  PERFORM add_sales_org
                                    USING
                                       ls_outtab
                                       ld_top_key
                                 CHANGING
                                       ld_vkorg_key.
                  ls_outtab-nkey   = ld_vkorg_key.
                  ls_outtab-ntype = 'VKORG'.
                  DESCRIBE TABLE gt_outtab.  " fill sy-tfill
                  MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                    TRANSPORTING nkey ntype.
                ENDIF.
              ENDIF.
              IF ( ld_ntype = 'VKORG'  OR
                   ld_ntype = 'VTWEG' ).
                "   new distribution channel
                IF ( ls_outtab-vkorg = ls_last-vkorg  AND
                     ls_outtab-vtweg = ls_last-vtweg ).
                ELSE.
                  PERFORM add_distrib_chan
                                    USING
                                       ls_outtab
                                       ld_vkorg_key
                                 CHANGING
                                       ld_vtweg_key.
                  ls_outtab-nkey = ld_vtweg_key.
                  ls_outtab-ntype = 'VTWEG'.
                  DESCRIBE TABLE gt_outtab.  " fill sy-tfill
                  MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                    TRANSPORTING nkey ntype.
                ENDIF.
              ENDIF.
              IF ( ld_ntype = 'VKORG'  OR
                   ld_ntype = 'VTWEG'  OR
                   ld_ntype = 'SPART' ).
                "   new channel
                IF ( ls_outtab-vkorg = ls_last-vkorg  AND
                     ls_outtab-vtweg = ls_last-vtweg  AND
                     ls_outtab-spart = ls_last-spart ).
                ELSE.
                  PERFORM add_division
                                    USING
                                       ls_outtab
                                       ld_vtweg_key
                                 CHANGING
                                       ld_spart_key.
                  ls_outtab-nkey = ld_spart_key.
                  ls_outtab-ntype = 'SPART'.
                  DESCRIBE TABLE gt_outtab.  " fill sy-tfill
                  MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                    TRANSPORTING nkey ntype.
                ENDIF.
              ENDIF.
    * Leaf:
              PERFORM add_complete_line
                                USING
                                   ls_outtab
                                   ld_spart_key
                             CHANGING
                                   ld_last_key.
              ls_outtab-nkey = ld_last_key.
              ls_outtab-ntype = 'LEAF'.
              DESCRIBE TABLE gt_outtab.  " fill sy-tfill
              MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                  TRANSPORTING nkey ntype.
              ls_last = ls_outtab.
            ENDLOOP.
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'REFRESH_TREE'
    *          IMPORTING
    *            RC       =
        ENDCASE.
      ENDMETHOD.                    "handle_node_ctxmenu_sel
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      PERFORM init_controls.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL SCREEN '0100'.
    * NOTE: no screen elements, ok_code -> gd_okcode
    **    PROCESS BEFORE OUTPUT.
    **      MODULE STATUS_0100.
    **    PROCESS AFTER INPUT.
    **      MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      TRANSLATE gd_okcode TO UPPER CASE.  " facilitate manual entries
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
      when 'REFRESH_TREE'.
        CALL METHOD go_alvtree->update_calculations
    *      EXPORTING
    *        NO_FRONTEND_UPDATE =
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
      DATA:
        ls_hierarchy_header TYPE treev_hhdr.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999 " full-size screen
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * create tree control
      CREATE OBJECT go_alvtree
        EXPORTING
            parent              = go_docking
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = ' '
            no_html_header      = 'X'
            no_toolbar          = ''
        EXCEPTIONS
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
      PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
    * Hide columns and sum up values initially using the fieldcatalog
      PERFORM build_fieldcatalog.
    * IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
    * (even after this method call). You can change data of your table
    * by calling methods of CL_GUI_ALV_TREE.
    * Furthermore, the output table 'gt_outtab' must be global and can
    * only be used for one ALV Tree Control.
      CALL METHOD go_alvtree->set_table_for_first_display
        EXPORTING
          is_hierarchy_header = ls_hierarchy_header
        CHANGING
          it_fieldcatalog     = gt_fcat
          it_outtab           = gt_outtab. "table must be empty !
      PERFORM init_tree.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  INIT_TREE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_tree .
      PERFORM create_hierarchy.
      PERFORM register_events.
    * Update calculations which were initially defined by field DO_SUM
    * of the fieldcatalog. (see build_fieldcatalog).
      CALL METHOD go_alvtree->update_calculations.
    * Send data to frontend.
      CALL METHOD go_alvtree->frontend_update.
    ENDFORM.                    " INIT_TREE
    *&      Form  build_hierarchy_header
    *       text
    *      <--P_LS_HIERARCHY_HEADER  text
    FORM build_hierarchy_header
         CHANGING
               cs_hierarchy_header TYPE treev_hhdr.
      cs_hierarchy_header-heading =
            'SalesOrg/DistChannel/Division'(300).
      cs_hierarchy_header-tooltip = 'Customer: Master Sales Data'(400).
      cs_hierarchy_header-width = 45.
      cs_hierarchy_header-width_pix = ''.
    ENDFORM.                    " build_hierarchy_header
    *&      Form  build_fieldcatalog
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
    * define local data
      DATA:
        ls_fcat    TYPE lvc_s_fcat.
      REFRESH: gt_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
         i_structure_name             = 'VBAK'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT gt_fcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'VBELN'  OR
               'AUDAT'  OR
               'AUART'  OR
               'WAERK'  OR
               'VKORG'  OR
               'VTWEG'  OR
               'SPART'  OR
               'BSTNK'  OR
               'KUNNR'.
          WHEN 'NETWR'.
            ls_fcat-do_sum = 'X'.
            ls_fcat-h_ftype = 'SUM'.  " or: 'MAX' / 'AVG'
          WHEN OTHERS.
            ls_fcat-tech = 'X'.
        ENDCASE.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDLOOP.
    ENDFORM.                    " build_fieldcatalog
    *&      Form  create_hierarchy
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_hierarchy .
    * define local data
      DATA:
        ls_outtab    TYPE ty_s_outtab,
        ls_last      TYPE ty_s_outtab,
        lt_outtab    TYPE ty_t_outtab.
      DATA:
        ld_vkorg_key   TYPE lvc_nkey,
        ld_vtweg_key   TYPE lvc_nkey,
        ld_spart_key   TYPE lvc_nkey,
        ld_last_key    TYPE lvc_nkey,
        ld_top_key     TYPE lvc_nkey.
      " Select data
      SELECT * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE lt_outtab
        UP TO 1550 ROWS.
      " sort table according to conceived hierarchy
      SORT lt_outtab BY vkorg vtweg spart kunnr audat.
    * Define one top node. In this way it is possible to calculate
    * values for the whole hierarchy.
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ''
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = 'Sales Documents'
        IMPORTING
          e_new_node_key   = ld_top_key.
      CLEAR: ls_outtab.
      ls_outtab-nkey  = ld_top_key.
      ls_outtab-ntype = 'ROOT'.
      MODIFY gt_outtab FROM ls_outtab INDEX 1
            TRANSPORTING nkey ntype.
      LOOP AT lt_outtab INTO ls_outtab.
        "   new sales organisation
        IF ( ls_outtab-vkorg = ls_last-vkorg ).
        ELSE.
          PERFORM add_sales_org
                            USING
                               ls_outtab
                               ld_top_key
                         CHANGING
                               ld_vkorg_key.
          ls_outtab-nkey   = ld_vkorg_key.
          ls_outtab-ntype = 'VKORG'.
          DESCRIBE TABLE gt_outtab.  " fill sy-tfill
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ENDIF.
        "   new distribution channel
        IF ( ls_outtab-vkorg = ls_last-vkorg  AND
             ls_outtab-vtweg = ls_last-vtweg ).
        ELSE.
          PERFORM add_distrib_chan
                            USING
                               ls_outtab
                               ld_vkorg_key
                         CHANGING
                               ld_vtweg_key.
          ls_outtab-nkey = ld_vtweg_key.
          ls_outtab-ntype = 'VTWEG'.
          DESCRIBE TABLE gt_outtab.  " fill sy-tfill
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ENDIF.
        "   new channel
        IF ( ls_outtab-vkorg = ls_last-vkorg  AND
             ls_outtab-vtweg = ls_last-vtweg  AND
             ls_outtab-spart = ls_last-spart ).
        ELSE.
          PERFORM add_division
                            USING
                               ls_outtab
                               ld_vtweg_key
                         CHANGING
                               ld_spart_key.
          ls_outtab-nkey = ld_spart_key.
          ls_outtab-ntype = 'SPART'.
          DESCRIBE TABLE gt_outtab.  " fill sy-tfill
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ENDIF.
    * Leaf:
        PERFORM add_complete_line
                          USING
                             ls_outtab
                             ld_spart_key
                       CHANGING
                             ld_last_key.
        ls_outtab-nkey = ld_last_key.
        ls_outtab-ntype = 'LEAF'.
        DESCRIBE TABLE gt_outtab.  " fill sy-tfill
        MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ls_last = ls_outtab.
      ENDLOOP.
    ENDFORM.                    " create_hierarchy
    *&      Form  ADD_SALES_ORG
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_TOP_KEY  text
    *      <--P_LD_VKORG_KEY  text
    FORM add_sales_org
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      ld_nodetext = us_outtab-vkorg.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = ls_outtab
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " ADD_SALES_ORG
    *&      Form  add_DISTRIB_CHAN
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_VKORG_KEY  text
    *      <--P_LD_VTWEG_KEY  text
    FORM add_distrib_chan
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      ld_nodetext = us_outtab-vtweg.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = ls_outtab
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " add_DISTRIB_CHAN
    *&      Form  add_division
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_VTWEG_KEY  text
    *      <--P_LD_SPART_KEY  text
    FORM add_division
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      ld_nodetext = us_outtab-spart.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = ls_outtab
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " add_division
    *&      Form  add_complete_line
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_SPART_KEY  text
    *      <--P_LD_LAST_KEY  text
    FORM add_complete_line
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      WRITE us_outtab-kunnr TO ld_nodetext+0  NO-ZERO.
      WRITE us_outtab-audat TO ld_nodetext+20 DD/MM/YYYY.
      CONDENSE ld_nodetext.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = us_outtab    " !!!
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " add_complete_line
    *&      Form  register_events
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM register_events .
      DATA:
        lt_events TYPE cntl_simple_events,
        ls_event TYPE cntl_simple_event.
    * The following four tree events registers ALV Tree in the constructor
    * method itself.
    *    - cl_gui_column_tree=>eventid_expand_no_children
    * (needed to load data to frontend when a user expands a node)
    *    - cl_gui_column_tree=>eventid_header_context_men_req
    * (needed for header context menu)
    *    - cl_gui_column_tree=>eventid_header_click
    * (allows selection of columns (only when item selection activated))
    *   - cl_gui_column_tree=>eventid_item_keypress
    * (needed for F1-Help (only when item selection activated))
    * Nevertheless you have to provide their IDs again if you register
    * additional events with SET_REGISTERED_EVENTS (see below).
    * To do so, call first method  GET_REGISTERED_EVENTS (this way,
    * all already registered events remain registered, even your own):
      CALL METHOD go_alvtree->get_registered_events
        IMPORTING
          events = lt_events.
    * (If you do not these events will be deregistered!!!).
    * You do not have to register events of the toolbar again.
    * Register additional events for your own purposes:
    * §5. Register first context menu event on frontend (with postfix
    *     (_REQUEST). The second is registered automatically.
      ls_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      APPEND ls_event TO lt_events.
    * register events on frontend
      CALL METHOD go_alvtree->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
    * §6. Register both context menu events on backend (ABAP Objects
    *    event handling).
      SET HANDLER:
        lcl_eventhandler=>handle_node_ctxmenu_req  FOR go_alvtree,
        lcl_eventhandler=>handle_node_ctxmenu_sel  FOR go_alvtree.
    ENDFORM.                    " register_events
    Regards,
      Uwe

  • Set a timeout for crystal sessions while using the Windows.Forms.Viewer?

    Hi,
    I am looking for a way to set the timeout for the crystal report sessions when using the Windows.Forms.Viewer in a .NET application. I guess that the default value is 20 minutes (like in the entperprise installations) but we cannot afford to keep many sessions open for that long. Is there a registry entry which can be set? Or even a way to do this programmatically?
    Thank you in advance,
    Stratos

    Hi David,
    we are talking here about a standalone .NET application where the reports are installed locally (like the application itself). We are not retrieving the reports from a server. The whole thing was developed using the crystal report viewer model probably because it was easier to do so. Is there a method in this model to tell the crystal runtime to do the clean-up work either for a report (like the ReportDocument.Close() ) or for the entire runtime instance. Dispose() does not seem to help us. If you say that there is no other way than redesign then we have to consider this option also.
    Cheers
    Stratos
    PS: What I was thinking of (as Plan B instead of using the ReportDocument object model) is to instantiate the crystal report viewer object in a separate process (.exe). Please note that we open a new crystal report viewer windows for each report, which is displayed. Closing the viewer window (ie. terminate the process) will at least then clean up and release the crystal DLLs and hopefully close the database connections. Or am I missing something here?
    Edited by: Efstratios Karaivazoglou on Jul 29, 2008 10:05 PM

  • Hiding a column used in the custom view!

    Hello! I would like to find out if there is any way to do the following: I have a view based on a table (Configuration Manager - Views).  I specified to display 4 columns to show up in the View, so that we can modify the columns without going into the Database.  In the "Default Display Expression" entry on the Info tab of the view, I've specified how these columns should be displayed on the UI. My problem:  I don't want to display the fourth column on the UI at all, but I want this column to still be accessible by administrators via the view!  Is it possible to specify somehow NOT to display this column, but still use it in the view? Thanks for the suggestions! Anya

    Hello! I've actually created a separate view just to hide this fourth column, and we will be using this for the administration (relates to your point b).  However, someone had asked not to use so many views!  Do you know of any problems if several views are being used for the same table? In our case some tables have up to 3 views already. We use this view for the Metadata field, but the Metadata field is an option list (or controlled vocabulary in our terms).  To enable more user-friendly selection, we are using DHTMLX Grid (dhtmlx.com) to display values in the View.  The grid is displaying all columns from the view, by default!  (Perhaps I need to check if I can somehow customize the Grid - however, I was hoping to do this from the View itself) Thanks!

  • How to add a new table or view in the view object

    hello,every one.
    I wanna add a new table or view in the view object's query statement.
    when the table or view not in the where clause,the query statement is working fine.
    If they in the where clause,I got the "java.lang.NullPointerException".
    who can help me
    thank you very much

    thank you for your reply
    I wanna extend the VO
    oracle.apps.pay.selfservice.payslip.US.server.PayPayslipGetPersonDetail
    the original sql is:
    SELECT ppf.person_id,
    FROM per_people_f ppf,
    per_assignments_f paf,
    pay_assignment_actions paa
    where paa.assignment_action_id = :1 AND paf.assignment_id = paa.assignment_id AND SYSDATE BETWEEN paf.effective_start_date AND paf.effective_end_date AND paf.person_id = ppf.person_id
    I wanna extend:
    SELECT ppf.person_id, pay_v.element_name,pay_v.assignment_action_id
    FROM per_people_f ppf,
    per_assignments_f paf,
    pay_assignment_actions paa,
    pay_run_results_v pay_v
    where paa.assignment_action_id = :1 AND paf.assignment_id = paa.assignment_id AND SYSDATE BETWEEN paf.effective_start_date AND paf.effective_end_date AND paf.person_id = ppf.person_id
    pay_v.assignment_action_id =paa.assignment_action_id
    if the pay.v in the where clause. I will got the exception. whereas,it's works fine.

  • How do I use Active Sync to view SharePoint Lists (Contacts and Calendars) on a Mobile Phone?

    We are attempting to use SharePoint 2010 in combination with Exchange 2010 to implement shared calendars and contact lists throughout our organization.  We are able to connect the lists to Outlook 2010, but have been unsuccessful in viewing
    the calendars and contact lists from our mobile phones.  How do we use Active Sync to view SharePoint Lists (Contacts and Calendars) on a Mobile Phone?
    In trying to answer this question, we have come across a few different possibilities, all of them falling just short of a long term solution for us.  After doing research, we found that Active Sync will only show the default folders of the account.  To
    solve this, we downloaded an Add-In for Outlook (CodeTwo FolderSync) to synchronize folders and synchronized our SharePoint list with a new Contact list in the default folder.  The issue we came across with this method is that the Add-In we are using
    is not capable of automatic synchronization.  There is a button and it must be clicked after every update is made, which is not ideal for our solution.  We then went to the company (CodeTwo) and found server side software (Exchange Sync) that they
    offer which will automatically synchronize the folders.  After installing that on the Exchange Server, we now are running into the issue of not being able to locate the SharePoint lists on the Exchange Server.
    Does anyone happen to know how we can get to the SharePoint lists from the Exchange Server?  Has anyone else been able to use shared contacts lists and calendars from SharePoint on their mobile phones using Active Sync?  If so, are we in the right
    direction with what we have found so far?
    Thanks,
    Brad

    You cannot use ActiveSync for that, but there are SharePoint clients for the iPhone. Windows Mobile 7 natively supports SharePoint with SharePoint Workspace Mobile, part of Microsoft Office Mobile. Android and BlackBerry might also have some apps.
    Use Microsoft SharePoint Workspace Mobile
    http://www.microsoft.com/windowsphone/en-us/howto/wp7/office/use-office-sharepoint-workspace-mobile.aspx
    iPhone SharePoint Apps Shootout
    http://www.codeproject.com/KB/iPhone/iPhoneSharePointApps.aspx 
    Comparing SharePoint iPhone Apps
    http://blog.praecipio.com/2010/11/02/comparing-sharepoint-iphone-apps/
    MCTS: Messaging | MCSE: S+M

  • How do I use the option "table view" in NetWeaver 2004s Query Designer?

    Dear,
    We have used NetWeaver 2004s Query Designer, We found a strange problem. The option to select table view is not available. It is greyed out. How can you select table view (tabular) in 2004s Query Designer?
    I have read the help doc about tabular view of NetWeaver 2004s Query Designer, I check my query, it has only one structure . but the option is still greyed out. I rebuild the query with 3.x Query Designer in tabular view, and reopen it with 2004s Query Designer, So there is a tab named "tabular view" display, but the option to select table view is still not available, and when users view the query result in web , it is still not in tabular view display. So I am confused, is there a bug with NetWeaver 2004s Query Designer?
    Please help me. Thanks!

    Note 1002271. Seach this note to use key word "table view"

  • Using Google Maps Street View on My MacBook Pro

    Recently, I have been getting "Plug-In Missing" in the place of a video in a blog post. Also, when I try to use Street View in Google Maps I get a box that tells me I need to install Adobe Flash Player 10 or later to be able to use Street View. Should I try to download and install Adobe Flash Player? What could I use to be able to use Google Maps Street View and/or to play videos?

    I found my reply elsewhere - you have to uncheck "contacts" and then recheck it. Kinda idiotic, but there you have it!

  • Using Metadata to generate view as conventional folder structure

    Can Metadata be used to generate a view as the conventional folder drill-down?
    I have a list with metadata for different projects, releases, content type etc and I would like to view them in folder structure with different hierarchies, i.e. using projects--> releases--> content-type as well as release --> projects --> content-type.
    I have asked the same question at : http://stackoverflow.com/questions/22693036/using-metadata-to-view-as-conventional-folder-structure

    Hi,
    If your metadata is based on a hierarchical term set you could use ‘Metadata Navigation’.
    You may have to change your information architecture a bit to accommodate this approach. More info on ‘Metadata Navigation’ here:
    http://office.microsoft.com/en-gb/sharepoint-server-help/configure-metadata-navigation-for-a-list-or-library-HA101820113.aspx
    Hope this helps
    Cheers
    Matt

Maybe you are looking for

  • WebDynpro : 500 Internal Server Error

    Hi All,         We are devloping WebDynpro Project with RFC Model, in that project we created two application's we are deploying that applicaton's into devlopment server, it was excuted successfully, now that same webdynpro project we are deploying t

  • Problem starting ES Builder in PI 7.10

    Just installed PI 7.1 in a sandbox environment with Windows Server 2003 SP2 and MAXDB.  I have also followed the post-installation steps in the installation guide.  So far everything works except the Enterprise Service Builder.  When I clicked on the

  • Converting double to strings

    I'm having a problem in getting my double to convert to a string, here's my code so far.      public void calculatePayments()           double paymentAmount;           double monthlyInterestRate = (Double.parseDouble(interestBox.getText())/12)/100;  

  • Converting to CMYK destroys colors

    I usually do web graphics in RGB. I was asked to do a bottle label for print. I built it in my usual RGB color space, then tried converting it to CMYK at the end. This ruins the colors. Obviously I don't know enough about working for print. Should I

  • I only get the Artists tab in music app everything else is missing.

    I only get the Artists tab in music app everything else is missing.