Hierarchy using loop

Hi,
Can someone explain me how to find the level using loop/cursor not using connect by clause.
It is just for playing.
Thank you

Hi,
If you needed to write your own function, here's one way you could do it:
CREATE OR REPLACE FUNCTION     emp_level
(       in_empno       IN      scott.emp.empno%TYPE
RETURN     PLS_INTEGER
IS
--          emp_level returns the hierarchy level of the employee with in_emp_id
--          If that employee has no mgr, then it returns 1.
--          If that employee has a manager, then it finds the given employee's mgr,
--              that employee's mgr, and so on until it reaches the top of the tree,
--              and returns the total number of meployees in the chain.
     return_level     PLS_INTEGER           := 0;     -- To be returned
     this_empno     scott.emp.empno%TYPE  := in_empno;
BEGIN
     WHILE  this_empno  IS NOT NULL
     LOOP
--          dbms_output.put_line (this_empno || ' = this_empno');     -- For debugging only
          SELECT  mgr
          INTO     this_empno
          FROM     scott.emp
          WHERE     empno     = this_empno;
          return_level := return_level + 1;
     END LOOP;
     RETURN     return_level;
EXCEPTION
     WHEN NO_DATA_FOUND
     THEN
          RETURN  NULL;     -- Bogus in_empno or corrupt table
END  emp_level;
/You could also use a recursive function.
Notice the commented-out call to dbms_output.put line inside the loop. Whenever you write a loop, you might want to include a call to print like this. If you get into an infinite loop, it will soon cause a buffer overflow, and you won't have to kill the session. Remember to delete the line, or comment it out, when you're sure the loop works correctly.
In pure SQL, this would be hard to do, because there is no real recursion in SQL parat from CONNECT BY (or, starting in Oracle 11, a recursive WITH clause, as Pollywog mentioned above).
MODEL can do iteration, but it can be tricky getting it to do the right number of levels. You might have to guess high, for example, assume that there will never be more than 100 levels. You might be able to do something with the number of rows actulayy in the table. For example, the scott.emp table has 14 rows, so you know you will never have a chain of command the goes more than 14 levels. (The actual maximum depth happens to be 4.)
using dynamic SQL, you could do a self-join, with a different copy of the table for each possible level. This is not very efficient, and hard to code.
I assume your table uses the Adjacency Model , like scott.emp, where every node has pointer to its parent.
There are other methods of storing trees in a relational database; some of them have fairly straghtfoward ways of finding the level of any given node. It alwyas helps to post a little sample data (CREATE TABLE and INSERT statements).
T.PD wrote:
There is no level pseudo column without connect by .Actually, in Oracle 11, you can use LEVEL in any query. However, if there's no CONNECT BY clause, LEVEL will always be 0.

Similar Messages

  • Building Tree hierarchy Using nested loops and class cl_gui_column_tree

    Hello gurus,
    I want to create a tree report using custom container and class cl_gui_column_tree. I have read and understood the standard demo report which SAP has provided i.e. SAPCOLUMN_TREE_CONTROL_DEMO. But in this report all the levels nodes are created as constants and hardcoded. I want to create hierarchy using nested loops. For this i took one example of a hierarchy of VBAK-VBELN->VBAP-POSNR Like One sales order has many line items and each line item can have number of line items in billing plan.
    I have done some coding for it.
    FORM build_tree USING node_table TYPE treev_ntab
                                           item_table TYPE zitem_table.              " i created the zitem_table table type of mtreeitm in SE11.
      DATA: node TYPE treev_node,
                 item TYPE mtreeitm.
      node-node_key = root.
      CLEAR node-relatkey.
      CLEAR node-relatship.
      node-hidden = ' '.
      node-disabled = ' '.
      CLEAR node-n_image.
      CLEAR node-exp_image.
      node-isfolder = 'X'.
      node-expander = 'X'.
      APPEND node TO node_table.
      item-node_key = root.
      item-item_name = colm1.
      item-class = cl_gui_column_tree=>item_class_text.
      item-text = 'Root'.
      APPEND item TO item_table.
      item-node_key = root.
      item-item_name = colm2.
      item-class = cl_gui_column_tree=>item_class_text.
      item-text = 'Amount'.
      APPEND item TO item_table.
      LOOP AT it_vbeln INTO wa_vbeln.
        node-node_key = wa_vbeln-vbeln.
        node-relatkey = root.
        node-relatship = cl_gui_column_tree=>relat_last_child.
        node-hidden = ' '.
        node-disabled = ' '.
        CLEAR node-n_image.
        CLEAR node-exp_image.
        node-isfolder = 'X'.
        node-expander = 'X'.
        APPEND node TO node_table.
        item-node_key = wa_vbeln-vbeln.
        item-item_name = colm1.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_vbeln-vbeln.
        APPEND item TO item_table.
        item-node_key = wa_vbeln-vbeln.
        item-item_name = colm2.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_vbeln-netwr.
        APPEND item TO item_table.
        LOOP AT it_posnr INTO wa_posnr.
        node-node_key = wa_posnr-posnr.
        node-relatkey = wa_vbeln-vbeln.
        node-relatship = cl_gui_column_tree=>relat_last_child.
        node-hidden = ' '.
        node-disabled = ' '.
        CLEAR node-n_image.
        CLEAR node-exp_image.
        node-isfolder = ' '.
        node-expander = ' '.
        APPEND node TO node_table.
        item-node_key = wa_posnr-posnr.
        item-item_name = colm1.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_posnr-posnr.
        APPEND item TO item_table.
        item-node_key = wa_posnr-posnr.
        item-item_name = colm2.
        item-class = cl_gui_column_tree=>item_class_text.
        item-text = wa_posnr-netpr.
        APPEND item TO item_table.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.
    Now this program compiles fine and runs till there is only one level. That is root->vbeln. But when i add one more loop of it_posnr it gives me runtime error of message type 'X'. The problem i found was uniqueness of item-item_name as all the sales order have posnr = 0010. What could be done? I tried giving item_name unique hierarchy level using counters just like stufe field in prps eg. 10.10.10, 10.10.20,10.20.10,10.20.20,20.10.10 etc.. etc.. but still i am getting runtime error when i add one more hierarchy using nested loop. Plz guide.
    Edited by: Yayati6260 on Jul 14, 2011 7:25 AM

    Hello all,
    Thanks the issue is solved. The node key was not getting a unique identification as nodekey. I resolved the issue by generating unique identification for each level. Thanks all,
    Regards
    Yayati Ekbote

  • ALV Tree Hierarchy using OOPS

    Hi all,
    I have developed a program for ALV Tree Hierarchy using OOPs.I followed the SAP demo program.I am not able to get the values in the output.Please can anyone guide me where to correct my program. I am placing the entire code so that you all can also debug and see what is wrong.
    *& Report  ZZHIERARCHY_TEST1
    REPORT  zzhierarchy_test1.
    DATA : alv_container TYPE REF TO cl_gui_custom_container,
           alv_tree      TYPE REF TO cl_gui_alv_tree,
           gt_fcat          TYPE lvc_t_fcat,
           gt_vbrk TYPE vbrk OCCURS 0.                             "Output Table
    DATA : gs_hirarchy_header TYPE treev_hhdr.
    START-OF-SELECTION.
    END-OF-SELECTION.
      CALL SCREEN 9100.
    *&      Module  STATUS_9100  OUTPUT
    MODULE status_9100 OUTPUT.
      SET PF-STATUS 'ALV_TREE'.
      IF alv_container IS INITIAL.
        PERFORM tree_dev.
      ENDIF.
    ENDMODULE.                 " STATUS_9100  OUTPUT
    *&      Form  tree_dev
          text
    FORM tree_dev .
      DATA lv_container_name(20) TYPE c.
      lv_container_name = 'ALV_TREE'.
      CREATE OBJECT alv_container
        EXPORTING
          container_name              = lv_container_name
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          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.
      CREATE OBJECT alv_tree
        EXPORTING
          parent                      = alv_container
          node_selection_mode         = cl_gui_column_tree=>node_sel_mode_single
          item_selection              = 'X'
          no_toolbar                  = ''
          no_html_header              = 'X'
        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
          OTHERS                      = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      PERFORM build_hirarchy_header CHANGING gs_hirarchy_header.
      PERFORM buid_fieldcatalog.
      CALL METHOD alv_tree->set_table_for_first_display
        EXPORTING
          is_hierarchy_header = gs_hirarchy_header
        CHANGING
          it_outtab           = gt_vbrk               "Table Must be Empty
          it_fieldcatalog     = gt_fcat.
      PERFORM create_hierarchy.
      CALL METHOD alv_tree->frontend_update.
    ENDFORM.                    " tree_dev
    *&      Form  build_hirarchy_header
         <--P_GS_HIRARCHY_HEADER  text
    FORM build_hirarchy_header  CHANGING p_gs_hirarchy_header TYPE treev_hhdr.
      p_gs_hirarchy_header-heading   =  'Company Code'(001).
      p_gs_hirarchy_header-tooltip   =  'Comapny Code'(002).
      p_gs_hirarchy_header-width     =   35.
      p_gs_hirarchy_header-width_pix =   ''.
    ENDFORM.                    " build_hirarchy_header
    *&      Form  buid_fieldcatalog
    FORM buid_fieldcatalog .
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
         i_structure_name             = 'VBRK'
        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 'NETWR'.
            ls_fcat-do_sum = 'X'.
            ls_fcat-h_ftype = 'MAX'.
        ENDCASE.
        MODIFY gt_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                    " buid_fieldcatalog
    *&      Form  create_hierarchy
    FORM create_hierarchy .
      DATA : lt_vbrk TYPE TABLE OF vbrk,
             ls_vbrk TYPE vbrk.
      DATA : top_key     TYPE lvc_nkey,
             company_key TYPE lvc_nkey,
             bzirk_key   TYPE lvc_nkey.
      DATA : lv_bukrs     TYPE bukrs,
             lv_bukrs_prv TYPE bukrs,
             lv_bzirk     TYPE bzirk,
             lv_bzirk_prv TYPE bzirk.
      SELECT * FROM vbrk INTO TABLE lt_vbrk UP TO 500 ROWS.
      SORT lt_vbrk BY bukrs .
      CALL METHOD alv_tree->add_node
        EXPORTING
          i_relat_node_key     = ''
          i_relationship       = cl_gui_column_tree=>relat_last_child
          i_node_text          = 'Company Code'
        IMPORTING
          e_new_node_key       = top_key
        EXCEPTIONS
          relat_node_not_found = 1
          node_not_found       = 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 lt_vbrk INTO ls_vbrk.
        lv_bukrs = ls_vbrk-bukrs .
        lv_bzirk = ls_vbrk-bzirk .
        IF lv_bukrs <> lv_bukrs_prv.
          lv_bukrs_prv =  lv_bukrs.
          PERFORM add_node USING lv_bukrs
                                 top_key
                        CHANGING company_key.
        ENDIF.
        IF lv_bzirk <> lv_bzirk_prv.
          lv_bzirk_prv = lv_bzirk.
          PERFORM add_posnr USING lv_bzirk
                                  company_key
                         CHANGING bzirk_key.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " create_hierarchy
    *&      Form  add_node
         -->P_LV_BUKRS  text
         -->P_TOP_KEY  text
         <--P_COMPANY_KEY  text
    FORM add_node  USING    p_lv_bukrs    TYPE bukrs
                            p_top_key     TYPE lvc_nkey
                   CHANGING p_company_key TYPE lvc_nkey .
      DATA: l_node_text TYPE lvc_value,
            ls_vbrk TYPE vbrk.
      l_node_text = 'Company' .
      CALL METHOD alv_tree->add_node
        EXPORTING
          i_relat_node_key     = p_top_key
          i_relationship       = cl_gui_column_tree=>relat_last_child
          is_outtab_line       = ls_vbrk
          i_node_text          = l_node_text
        IMPORTING
          e_new_node_key       = p_company_key
        EXCEPTIONS
          relat_node_not_found = 1
          node_not_found       = 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.
    ENDFORM.                    " add_node
    *&      Form  add_posnr
          text
         -->P_LV_POSNR  text
         -->P_COMPANY_KEY  text
         <--P_POSNR_KEY  text
    FORM add_posnr  USING    p_lv_bzirk    TYPE bzirk
                             p_company_key TYPE lvc_nkey
                    CHANGING p_bzirk_key   TYPE lvc_nkey.
      DATA ls_vbrk TYPE vbrk.
      CALL METHOD alv_tree->add_node
        EXPORTING
          i_relat_node_key     = p_company_key
          i_relationship       = cl_gui_column_tree=>relat_last_child
          is_outtab_line       = ls_vbrk
          i_node_text          = 'Sales District'
        IMPORTING
          e_new_node_key       = p_bzirk_key
        EXCEPTIONS
          relat_node_not_found = 1
          node_not_found       = 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.
    ENDFORM.                    " add_posnr
    *&      Module  USER_COMMAND_9100  INPUT
    MODULE user_command_9100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
      CALL METHOD alv_container->free.
      LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9100  INPUT

    Check this forum there are many threads on this.

  • Downloaded my hierarchy using the program z_sap_hierarchy_download

    hi
    I want download downloaded my hierarchy using the program z_sap_hierarchy_download but I have any problem when I using idoc method, I have this message:
    Node [00001350, 00001580]: Leaf 'E010000000' already exists as child of node 00001501
    Best regard
    Francoise

    hi
    The problem is that 2 id differents has the same description.
    my program is:
    begin
    SAP Consulting BW Tools:
    Download hierarchy into a flat file. The file has the correct format
    Text elements:
    P_DATES Include from/to dates
    P_DATETO Valid-to date
    P_FNAME File name
    P_HIENM Hierarchy name
    P_INTER Include from/to leaves
    P_IOBJNM InfoObject
    P_LANGU Language
    P_VERS Hierarchy version
    REPORT z_sap_hierarchy_download.
    TYPE-POOLS: rs, rsdm, rrh1.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS:
    p_iobjnm TYPE rsdiobjnm MEMORY ID rsc.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
    PARAMETERS:
    p_hienm TYPE rshiedir-hienm,
    p_vers TYPE rshiedir-version,
    p_dateto TYPE rshiedir-dateto,
    p_langu TYPE rshiedirt-langu.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME.
    PARAMETERS:
    p_fname LIKE rlgrap-filename,
    p_dates AS CHECKBOX DEFAULT 'X',
    p_inter AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b3.
    File structure
    TYPES:
    No dates/intervals
    BEGIN OF y_s_hierfile_1,
    nodeid TYPE rshienodid,
    iobjnm TYPE rsiobjnm,
    nodename TYPE rsnodename,
    tlevel TYPE rstlevel,
    link TYPE rslink,
    parentid TYPE rsparent,
    childid TYPE rschild,
    nextid TYPE rsnext,
    langu TYPE langu,
    txtsh TYPE rstxtsh,
    txtmd TYPE rstxtmd,
    txtlg TYPE rstxtlg,
    END OF y_s_hierfile_1,
    y_t_hierfile_1 TYPE STANDARD TABLE OF y_s_hierfile_1,
    With dates
    BEGIN OF y_s_hierfile_2,
    nodeid TYPE rshienodid,
    iobjnm TYPE rsiobjnm,
    nodename TYPE rsnodename,
    tlevel TYPE rstlevel,
    link TYPE rslink,
    parentid TYPE rsparent,
    childid TYPE rschild,
    nextid TYPE rsnext,
    dateto TYPE rsdateto,
    datefrom TYPE rsdatefrom,
    langu TYPE langu,
    txtsh TYPE rstxtsh,
    txtmd TYPE rstxtmd,
    txtlg TYPE rstxtlg,
    END OF y_s_hierfile_2,
    y_t_hierfile_2 TYPE STANDARD TABLE OF y_s_hierfile_2,
    With intervals
    BEGIN OF y_s_hierfile_3,
    nodeid TYPE rshienodid,
    iobjnm TYPE rsiobjnm,
    nodename TYPE rsnodename,
    tlevel TYPE rstlevel,
    link TYPE rslink,
    parentid TYPE rsparent,
    childid TYPE rschild,
    nextid TYPE rsnext,
    leafto TYPE rsleafto,
    leaffrom TYPE rsleaffrom,
    langu TYPE langu,
    txtsh TYPE rstxtsh,
    txtmd TYPE rstxtmd,
    txtlg TYPE rstxtlg,
    END OF y_s_hierfile_3,
    y_t_hierfile_3 TYPE STANDARD TABLE OF y_s_hierfile_3,
    With dates/intervals
    BEGIN OF y_s_hierfile_4,
    nodeid TYPE rshienodid,
    iobjnm TYPE rsiobjnm,
    nodename TYPE rsnodename,
    tlevel TYPE rstlevel,
    link TYPE rslink,
    parentid TYPE rsparent,
    childid TYPE rschild,
    nextid TYPE rsnext,
    dateto TYPE rsdateto,
    datefrom TYPE rsdatefrom,
    leafto TYPE rsleafto,
    leaffrom TYPE rsleaffrom,
    langu TYPE langu,
    txtsh TYPE rstxtsh,
    txtmd TYPE rstxtmd,
    txtlg TYPE rstxtlg,END OF y_s_hierfile_4,
    y_t_hierfile_4 TYPE STANDARD TABLE OF y_s_hierfile_4.
    Hierarchy definition
    DATA:
    g_s_hiesel TYPE rsndi_s_hiesel,
    g_s_hiedir TYPE rsndi_s_hiedir,
    g_subrc TYPE sy-subrc,
    g_t_hiedirt TYPE TABLE OF rshiedirt,
    g_s_hierstruc TYPE rssh_s_htab,
    g_t_hierstruc TYPE TABLE OF rssh_s_htab,
    g_s_thiernode TYPE rsthiernode,
    g_t_thiernode TYPE TABLE OF rsthiernode WITH KEY langu hieid objvers
    nodename,
    g_s_hierintvl TYPE rssh_s_jtab,
    g_t_hierintvl TYPE TABLE OF rssh_s_jtab WITH KEY hieid objvers nodeid,
    g_s_message TYPE rsndi_s_message,
    g_t_message TYPE TABLE OF rsndi_s_message,
    g_s_chavlinfo TYPE rsdm_s_chavlinfo,
    g_t_chavlinfo TYPE rsdm_t_chavlinfo.
    File
    DATA:
    g_fname TYPE string,
    g_struct_s TYPE string,
    g_struct_t TYPE string,
    gr_s_file TYPE REF TO data,
    gr_t_file TYPE REF TO data.
    FIELD-SYMBOLS:
    <g_langu> TYPE ANY,
    <g_s_file> TYPE ANY,
    <g_t_file> TYPE STANDARD TABLE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_iobjnm.
      CALL FUNCTION 'RSD_IOBJ_F4'
        EXPORTING
          i_show_cha    = rs_c_true
          i_objvers     = rs_c_objvers-active
          i_hietabfl    = rs_c_true
        CHANGING
          c_iobjnm      = p_iobjnm
        EXCEPTIONS
          illegal_input = 1.
      CHECK sy-subrc = 0.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_hienm.
      DATA:
      l_s_hiertxt TYPE rrh1_s_hiertxt,
      l_t_hiertxt TYPE rrh1_t_hiertxt.
      CALL FUNCTION 'RRH1_HIERARCHY_HELP_VALUES_GET'
        EXPORTING
          i_iobjnm          = p_iobjnm
          i_dateto          = p_dateto
          i_hienm           = p_hienm
          i_version         = p_vers
        IMPORTING
          e_t_hiertxt       = l_t_hiertxt
        EXCEPTIONS
          no_f4_available   = 1
          dialogue_canceled = 2
          OTHERS            = 3.
      CHECK sy-subrc = 0.
      READ TABLE l_t_hiertxt INTO l_s_hiertxt INDEX 1.
      CHECK NOT l_s_hiertxt IS INITIAL.
      p_hienm = l_s_hiertxt-hienm.
      DATA:
      l_s_dynpfields TYPE dynpread,
      l_t_dynpfields TYPE STANDARD TABLE OF dynpread.
      CLEAR: l_t_dynpfields, l_s_dynpfields.
      l_s_dynpfields-fieldname = 'P_VERS'.
      WRITE l_s_hiertxt-version TO l_s_dynpfields-fieldvalue.
      APPEND l_s_dynpfields TO l_t_dynpfields.
      l_s_dynpfields-fieldname = 'P_DATETO'.
      WRITE l_s_hiertxt-dateto TO l_s_dynpfields-fieldvalue.
      APPEND l_s_dynpfields TO l_t_dynpfields.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
        EXPORTING
          dyname     = sy-repid
          dynumb     = sy-dynnr
        TABLES
          dynpfields = l_t_dynpfields.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
      DATA:
      l_filename1 TYPE string,
      l_filename2 TYPE string,
      l_path TYPE string,
      l_fullpath TYPE string,
      l_action TYPE i.
      l_filename1 = p_fname.
      CALL METHOD cl_gui_frontend_services=>file_save_dialog
      EXPORTING
      window_title = 'Select Download File'
      default_extension = 'txt'
      default_file_name = l_filename1
      file_filter = 'All Files (.)|.|Text files (.txt)|.txt'
      CHANGING
      filename = l_filename2
      path = l_path
      fullpath = l_fullpath
      user_action = l_action
      EXCEPTIONS
      cntl_error = 1
      OTHERS = 2.                                               "#EC NOTEXT
      CHECK sy-subrc = 0.
      CALL METHOD cl_gui_cfw=>flush.
      IF l_action = 0.
        p_fname = l_fullpath.
      ENDIF.
    INITIALIZATION.
      GET PARAMETER ID 'RSC' FIELD p_iobjnm.
    START-OF-SELECTION.
    Check input
      CHECK NOT p_fname IS INITIAL.
      IF p_langu IS INITIAL.
        p_langu = sy-langu.
      ENDIF.
      IF p_dateto IS INITIAL.
        p_dateto = '99991231'.
      ENDIF.
    Read hierarchy
      CLEAR g_s_hiesel.
      g_s_hiesel-objvers = rs_c_objvers-active.
      g_s_hiesel-hienm = p_hienm.
      g_s_hiesel-version = p_vers.
      g_s_hiesel-iobjnm = p_iobjnm.
      g_s_hiesel-dateto = p_dateto.
      CALL FUNCTION 'RSNDI_SHIE_STRUCTURE_GET'
        EXPORTING
          i_s_hiesel        = g_s_hiesel
          i_no_nodenm_table = rs_c_true
        IMPORTING
          e_s_hiedir        = g_s_hiedir
          e_subrc           = g_subrc
        TABLES
          e_t_hiedirt       = g_t_hiedirt
          e_t_hierstruc     = g_t_hierstruc
          e_t_thiernode     = g_t_thiernode
          e_t_hierintvl     = g_t_hierintvl
          e_t_message       = g_t_message.
      IF g_subrc <> 0.
        READ TABLE g_t_message INTO g_s_message INDEX 1.
        IF sy-subrc = 0.
          MESSAGE ID g_s_message-msgid TYPE 'I' NUMBER g_s_message-msgno
          WITH g_s_message-msgv1 g_s_message-msgv2
          g_s_message-msgv3 g_s_message-msgv4.
        ELSE.
          MESSAGE ID 'RSBO' TYPE 'I' NUMBER 899
          WITH 'Hierarchy read error'.
        ENDIF.
        EXIT.
      ENDIF.
    Defined output structures
      IF p_dates IS INITIAL AND p_inter IS INITIAL.
        g_struct_s = 'Y_S_HIERFILE_1'.
        g_struct_t = 'Y_T_HIERFILE_1'.
      ELSEIF p_dates = 'X' AND p_inter IS INITIAL.
        g_struct_s = 'Y_S_HIERFILE_2'.
        g_struct_t = 'Y_T_HIERFILE_2'.
      ELSEIF p_dates IS INITIAL AND p_inter = 'X'.
        g_struct_s = 'Y_S_HIERFILE_3'.
        g_struct_t = 'Y_T_HIERFILE_3'.
      ELSE.
        g_struct_s = 'Y_S_HIERFILE_4'.
        g_struct_t = 'Y_T_HIERFILE_4'.
      ENDIF.
      CREATE DATA gr_s_file TYPE (g_struct_s).
      ASSIGN gr_s_file->* TO <g_s_file>.
      CREATE DATA gr_t_file TYPE (g_struct_t).
      ASSIGN gr_t_file->* TO <g_t_file>.
    Nodes
      REFRESH <g_t_file>.
      LOOP AT g_t_hierstruc INTO g_s_hierstruc.
        CLEAR <g_s_file>.
        MOVE-CORRESPONDING g_s_hierstruc TO <g_s_file>.
    Texts for nodes
        READ TABLE g_t_thiernode INTO g_s_thiernode WITH TABLE KEY
        langu = p_langu
        hieid = g_s_hierstruc-hieid
        objvers = rs_c_objvers-active
        nodename = g_s_hierstruc-nodename.
        IF sy-subrc = 0.
          MOVE-CORRESPONDING g_s_thiernode TO <g_s_file>.
        ELSE.
    Texts for characteristic values
          REFRESH g_t_chavlinfo.
          CLEAR g_s_chavlinfo.
          g_s_chavlinfo-c_chavl = g_s_hierstruc-nodename.
          APPEND g_s_chavlinfo TO g_t_chavlinfo.
          CALL FUNCTION 'RSD_CHAVL_READ_ALL'
            EXPORTING
              i_iobjnm                  = g_s_hierstruc-iobjnm
              i_langu                   = p_langu
              i_dateto                  = p_dateto
              i_check_value             = space
              i_sid_in                  = space
              i_hieid                   = g_s_hiedir-hieid
              i_objvers                 = g_s_hiedir-objvers
            CHANGING
              c_t_chavlinfo             = g_t_chavlinfo
            EXCEPTIONS
              info_object_not_found     = 1
              routines_generation_error = 2
              check_table_not_existing  = 3
              text_table_not_existing   = 4
              OTHERS                    = 5.
          IF sy-subrc = 0.
            READ TABLE g_t_chavlinfo INTO g_s_chavlinfo INDEX 1.
            IF sy-subrc = 0.
              MOVE-CORRESPONDING g_s_chavlinfo-e_chatexts TO <g_s_file>.
              ASSIGN COMPONENT 'LANGU' OF STRUCTURE <g_s_file> TO <g_langu>.
              IF sy-subrc = 0.
                <g_langu> = p_langu.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
    Intervals
        IF g_s_hierstruc-intervl = 'X' AND p_inter = 'X'.
          READ TABLE g_t_hierintvl INTO g_s_hierintvl WITH TABLE KEY
          hieid = g_s_hierstruc-hieid
          objvers = rs_c_objvers-active
          nodeid = g_s_hierstruc-nodeid.
          IF sy-subrc = 0.
            MOVE-CORRESPONDING g_s_hierintvl TO <g_s_file>.
          ENDIF.
        ENDIF.
        APPEND <g_s_file> TO <g_t_file>.
      ENDLOOP.
    Download output table
      g_fname = p_fname.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = g_fname
          write_field_separator   = space
        TABLES
          data_tab                = <g_t_file>
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc = 0.
        MESSAGE ID 'RSBO' TYPE 'I' NUMBER 899
        WITH 'Hierarchy download successful!'.
      ELSE.
        MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    end

  • How to Use Loop in BPM?

    Hi,
    I would like to use LOOP functionality in BPM until all the records are processed.
    Any Help would be appreciated.
    Regards,
    Ganesh Karicharla

    hi,
    what does it mean all records
    by payload loop, time loop?
    this page presents all sorts of loops jut check it:
    http://help.sap.com/saphelp_nw04/helpdata/en/08/16163ff8519a06e10000000a114084/content.htm
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • How to cast vector to vector with out using loop. and how to override "operator =" of vector for this kind of condition.

    Hi All How to TypeCast in vector<>...  typedef  struct ...  to class... 
    //how to cast the vector to vector cast with out using loop
    // is there any way?
    //================ This is Type Definition for the class of ClsMytype=====================
    typedef struct tagClsMytype
    CString m_Name;
    int m_Index;
    double m_Value;
    } xClsMytype;
    //================ End of Type Definition for the class of ClsMytype=====================
    class ClsMytype : public CObject
    public:
    ClsMytype(); // Constructor
    virtual ~ClsMytype(); // Distructor
    ClsMytype(const ClsMytype &e);//Copy Constructor
    // =========================================
    DECLARE_SERIAL(ClsMytype)
    virtual void Serialize(CArchive& ar); /// Serialize
    ClsMytype& operator=( const ClsMytype &e); //= operator for class
    xClsMytype GetType(); // return the typedef struct of an object
    ClsMytype& operator=( const xClsMytype &e);// = operator to use typedef struct
    ClsMytype* operator->() { return this;};
    operator ClsMytype*() { return this; };
    //public veriable decleare
    public:
    CString m_Name;
    int m_Index;
    double m_Value;
    typedef struct tagClsMyTypeCollection
    vector <xClsMytype> m_t_Col;
    } xClsMyTypeCollection;
    class ClsMyTypeCollection : public CObject
    public:
    ClsMyTypeCollection(); // Constructor
    virtual ~ClsMyTypeCollection(); // Distructor
    ClsMyTypeCollection(const ClsMyTypeCollection &e);//Copy Constructor
    DECLARE_SERIAL(ClsMyTypeCollection)
    virtual void Serialize(CArchive& ar);
    xClsMyTypeCollection GetType();
    ClsMyTypeCollection& operator=( const xClsMyTypeCollection &e);
    ClsMyTypeCollection& operator=( const ClsMyTypeCollection &e); //= operator for class
    void Init(); // init all object
    CString ToString(); // to convert value to string for the display or message proposed
    ClsMyTypeCollection* operator->() { return this;}; // operator pointer to ->
    operator ClsMyTypeCollection*() {return this;};
    public:
    vector <ClsMytype> m_t_Col;
    //private veriable decleare
    private:
    //===================================================
    ClsMytype& ClsMytype::operator=( const xClsMytype &e )
    this->m_Name= e.m_Name;
    this->m_Index= e.m_Index;
    this->m_Value= e.m_Value;
    return (*this);
    //==========================Problem for the vector to vector cast
    ClsMyTypeCollection& ClsMyTypeCollection::operator=( const xClsMyTypeCollection &e )
    this->m_t_Col= (vector<ClsMytype>)e.m_t_Col; // how to cast
    return (*this);
    Thanks in Advance

    Hi Smirt
    You could do:
    ClsMyTypeCollection* operator->() {
    returnthis;};
    // operator pointer to ->
    operatorClsMyTypeCollection*()
    {returnthis;};
    public:
    vector<ClsMytype>
    m_t_Col;//??
    The last line with "vector<xClsMytype>
    m_t_Col;". It compiles but I doubt that is what you want.
    Regards
    Chong

  • Not able to view Characteristic Hierarchy using Tcode KES3

    Hi everyone,
    I need to view the Characteristic Hierarchy using T-code KES3 in CO-PA. Ideally, once we are into KES3 screen, we need to select the characteristic and variant to display the hierarchy. But, when I select the characteristic and variant, it says that "Hierarchy doesn't exist".
    However, when I create a report for that particular characteristic using T-code KE31, I am able to view the hierarchy for that characteristic there.
    Can anyone please help me in this regard that why the characteristic hierarchy is not available in KES3, while it's picking up the hierarchy at the time of report creation.
    Thanks.
    Regards,
    Gaurav Tibrewal

    Hi Nikolas,
    I want to see the hierarchy of "Business Unit" characteristic. This characteristic is being maintained under "Referenced Characteristic" in T-code KE31. This characteristics is being maintained in Profitability Analysis (T-code KEA5).
    Also, I am not able to derive the source where the hierarchy is being maintained for that characteristic. Because, if hierarchy is coming while creating CO-PA reports. they must be maintained somewhere.
    Please let me know if you need any further input.
    Regards,
    Gaurav

  • It is possible to print any name 200 times without using loops?

    How to print any name 200 times without using loops and recurssive function and that to in java?

    String name = "incognito10";
    System.out.println(name.replaceAll("\\w+",
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n"+
        "$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0\n$0"
    );

  • Using loop in dbms_advisor Package

    Dears,,
    I used dbms_advisor package as following below
    dbms_advisor.create_object
    task_name => name,
    object_type => 'TABLE',
    attr1 => 'HR',
    attr2 => 'Employees',
    attr3 => NULL,
    attr4 => NULL,
    attr5 => NULL,
    object_id => obj_id
    what i need is to use loop to retrieve all tables at once then use them one by one in the script above without inserting table name myself.
    In another meaning (See the following):
    * loop to retrieve all tables
    * dbms_advisor.create_object
    task_name => name,
    object_type => 'TABLE',
    attr1 => 'HR',
    attr2 => 'TAB', Which TAB retrieved from loop one by one by itself
    attr3 => NULL,
    attr4 => NULL,
    attr5 => NULL,
    object_id => obj_id
    * end loop;
    How can i make this please?
    Thanks & Regards,,
    Edited by: . . Oracle DBA . . on Apr 10, 2011 5:56 AM

    . . Oracle DBA . . wrote:
    How can i make this please?
    begin
        for v_rec in (select owner,table_name from dba_tables) loop
          dbms_advisor.create_object(
                                     task_name => v_rec.owner || '_' || v_rec.table_name,
                                     object_type => 'TABLE',
                                     attr1 => v_rec.owner,
                                     attr2 => v_rec.table_name,
                                     attr3 => NULL,
                                     attr4 => NULL,
                                     attr5 => NULL,
                                     object_id => obj_id
        end loop;
    end;
    /SY.

  • How to use loop in VBAK table using BDC RFC connection through excel vba ?

    Hello,
    I am trying to extract data from VBAK table using rfc connection with Excel VBA. where i can able to pull data first time, when i tried to use the same set of code using loops, it throws an error like BAD INDEX.
    Any help appreciated.

    Hello,
    I am trying to extract data from VBAK table using rfc connection with Excel VBA. where i can able to pull data first time, when i tried to use the same set of code using loops, it throws an error like BAD INDEX.
    Any help appreciated.

  • How to use LOOP(Until) step in a Workflow

    Hi,
    How to use LOOP(Until) step in a Workflow?
    What are the steps involved in using the step LOOP(Until).

    Hmmm... using it is just like using a LOOP UNTIL statement in any programming language. You get at least one loop iteration, as opposed to a WHILE loop which may give you zero iterations.
    You simply insert a node of this type in the workflow, and magically there will be a loop inside which you can insert the steps you want to execute in the loop, and by double-clicking at the end node of the loop you can enter the condition for exiting.
    What exactly is it you are having trouble understanding about the use of it?

  • How to use loop in BPEL Process

    Hi friends
    I have done a bpel process which picks up XMl file using File Adapter and imports the data from the XMl file to oracle db table using DB adapter....
    But here the XMl file which have only one row ..if i want insert the XML file which have two or more rows i want to use loop in my BPEL process how to use the loop in my bpel process ?
    In my BPEL process i have used receive ,transform , and invoke activity where can i use loop in my BPEL process
    Advance Thanks
    AT

    Hi Friend thanks
    Hi Oracler how to make use of transform activity and use a for each in it.?
    iam not getting i try can u please explain some more in brief
    Thanks
    AT

  • How to use loop in smartforms???

    hi experts,
                  I have an internal table with three values .i am passing it into new itab inside smartforms .while displaying it is displaying only the third data .i think i must use loop condition .but i dont know where to use it .pls help me.if i select only one data it is coming .if i select multiple data using select statement .only the final thing is coming .

    On your smartform, you should have a table set up.  Go to transaction SMARTFORMS, enter your form name, and display it.  Now navigate to the table on your form and double-click it.  Go to the Data tab.  Under "LOOP", make sure that you have checked "Internal table".  Next to that should be the name of your internal table, then "Into", then a work area.  The work area needs to be defined under "Global Definitions" (under Global Settings, check the tree for your form).  Your work area should be defined as TYPE, with the associated type being your internal table.  Your internal table should actually be defined as a structure where each component is one item that you want to include in your row.  I hope this helps.
    - April King

  • How to use loop in premiere elements 8?

    Hi,
    Using pre elements 8 and I don`t know how to set or use loop option in premiere elements 8
    Please help
    Vinay

    For an authored DVD, there is no capability to Loop that DVD, created in PrE. There are other authoring programs, like Sony's DVD Architect, and Adobe Encore (available only with PrPro), that allow this to be done easily.
    The way to do similar in PrE is to do an AutoPlay DVD and then this use the Repeat button on the DVD player.
    Good luck,
    Hunt

  • How to use loop

    Hi
    I have one control block in form of Grid and now I want clear my grid when button pressed for new selection.
    So any one let me know how can I use loop for these field
         :ADVANCES_SCHEME.TXT_MONTH := '';
              :ADVANCES_SCHEME.MONTH_VERIFIED := '';
              :ADVANCES_SCHEME.CK_VERIFIED := 'N';
    Thanks in advance...
    Regards

    Thanks every one. I have solve my problem, just put this statement in begin clause
         Clear_Block(No_Validate);
    this statement clear my grid.
    Regards

Maybe you are looking for

  • My ipod lost all of my songs

    my ipod lost all of the information for all the songs i had on my ipod... the songs are there because it is an 8g 4th generation ipod, but says it only has 4g of memory left... i had plugged it into my computer, but it wasn't registering, so i pulled

  • Unable to print to Epson SP870

    I upgraded yesterday from iPhoto 4.0.3 to iPhoto 6.0.6 on my Powerbook running OS X 10.3.9. Nothing else changed on my computer except, of course, the simultaneous installation of the other iLife 06 applications (which I don't use; in fact I immediat

  • Using another computer as a harddrive

    I am currently running Leopard on a Mac Pro. I have an old G5 that I'd like to run as an external drive that I can leave on always to store photos, music, etc to free up space on the Mac Pro. How would I go about doing this? What hardware would I nee

  • CRM: Link Business Partner to Case

    Anyone know of a BAPI or class that will allow me to do this.  I have created a Case (so have its GUID) and have the GUID of the Citizen (Business Partner) - just need to link them together - any ideas?

  • Bridge CS5 frozen

    Since using the beta version of CS6 Bridge CS5 is frozen or very very slow, is there anyway to reinstall it without installing the whole PS5 suite? Or is there another solution to getting Bridge back on its feet? MBP 2.2  OSX10.7.3 Thanks in advance.