CL_GUI_ALV_TREE

Hi All,
I have written an ALV Tree model program with child nodes etc.,I have noticed that the standard ALV tool bar does not work .I mean it goes to PAI and does not perform its functionality. Will standard ALV toolbar work for Tree model ALV?
Thanks,
Kamala

Hi kamala,
I have a problem with my ALV tree and it is not being displayed...I want to show the tree with only 3 columns with hierarchy:
Project Initial -> Project Name -> Project Status.
So that:
A - A Project 1
    - A Project 2
B - B Project 1
      B Project 2
      B Project 3
I need help because I don't know how to use the CL_GUI_ALV_TREE. Can you give me some samples?
Thanks a lot!

Similar Messages

  • How to sort data in cl_gui_alv_tree class?

    Hi,
    I thought that since this object uses an alv grid that the standard sort functionality would exist.  Now that I've developed most of the code, I realize that there is no native sorting functionality.
    Is there some way I can make use of the Superclass CL_ALV_TREE_BASE?
    It has some methods that are "Private", "Instance"  - I'm still a rookie at OO programming in SAP so I'm not sure how best to approach the situation.
    As I see it, I have a few options:
    1)  Manually manage sorting by providing an ascending and descending button/icon on the toolbar and then delete and rebuild the nodes in the tree.
    2)  Manually track the data along with the nodekeys and then use method MOVE_NODE to reposition the data in the tree
    3)  Clone these objects and somehow find the code that is causing the sort options to be suppressed in the toolbar.
    Has anyone built any applications using CL_ALV_TREE_BASE that permit sorting?
    Please don't waste my time by pasting in the links to all the SAP online help for ALV and expect to get points.  Been there, done that.  If there is a particular section that is of specific value, I'll happily study it and report my findings.  Particularly something that explains how to invoke the methods of a superclass and the difference between protected, public, and private.
    Mostly though, I really need a way to sort data in the CL_GUI_ALV_TREE class.
    Thanks

    Hi Ray,
    As far as I know, this will not work. I've had the same problem. The only solution I have found was to re-build the tree each time. It is easier than moving nodes around.
    You can take a look at the class cl_wa_notifications_wps - in case you have a PM or an A&D system.
    Ferenc

  • Editable field in alv tree output using cl_gui_alv_tree

    Hi,
    i need Editable field with F4 help in alv tree output using cl_gui_alv_tree.
    regards,
    Naresh

    sadly, this is not possible. An ALV Tree cannot by editable.
    Regards

  • Refresh problem in CL_GUI_ALV_TREE

    Hi Experts,
    I am taking an object name as input and based on the input value, fetching data from the table and displaying it in the form of a tree, using the class CL_GUI_ALV_TREE. The outtab is passed empty to the set_table_for_first_display method. Now, when I go back, enter a new object name and click on display, the data that is used to build the tree gets updated properly, all the add_node calls get executed fine, but the tree does not get refreshed. It gets refreshed properly if I restart the transaction and start with the new object. I am calling the method frontend_update to update the screen, still there is no change. I am clearing the tree object and building the tree from scratch with the new data. But it does not change.
    Is there any clearing of cache required? I am missing anything that is not refreshing the tree. Any help on this would be greatly appreciated since I am stuck with this for a long time now. Thank you!
    Regards,
    Nithya
    Edited by: Nithya S on Apr 8, 2008 8:57 AM

    hi nithya..........
    check this code....hope it will be useful
    report  y13816_alv_tree_with_oops.
    §1a. Define reference variables
    data: g_alv_tree type ref to cl_gui_alv_tree,
          g_custom_container type ref to cl_gui_custom_container,
          gt_sflight type sflight occurs 0,
          g_max type i value 255.
    end-of-selection.
    call screen 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
      set pf-status 'MENU_BAR'.
    if g_alv_tree is initial.
      perform init_tree.
      call method cl_gui_cfw=>flush
       exceptions
         cntl_system_error = 1
         cntl_error        = 2.
      if sy-subrc <> 0.
        call function 'POPUP_TO_INFORM'
          exporting
            titel         = 'Automation Queue failure'(801)
            txt1          = 'Internal error:'(802)
            txt2          = 'A method in the automation queue'(803)
            txt3          = 'caused a failure.'(804).
      endif.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Form  init_tree
          text
    -->  p1        text
    <--  p2        text
    form init_tree .
    §1b. Create ALV Tree Control and corresponding Container.
    create container for alv-tree
    data: l_tree_container_name(30).
    l_tree_container_name = 'CONTAINER'.
    create object g_custom_container
      exporting
        container_name = l_tree_container_name
      exceptions
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'(100).
      endif.
    Creating Tree Control
    create object g_alv_tree
      exporting
        parent              = g_custom_container
        node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
        item_selection      = 'X'
        no_html_header      = 'X'
        no_toolbar          = '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.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    §2. Create Hierarchy-header
    The simple ALV Tree uses the text of the fields which were used
    for sorting to define this header. When you use
    the 'normal' ALV Tree the hierarchy is build up freely
    by the programmer this is not possible, so he has to define it
    himself.
    data: l_hierarchy_header type treev_hhdr.
      perform build_hierarchy_header changing l_hierarchy_header.
    §3. Create empty Tree Control
    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 g_alv_tree->set_table_for_first_display
        exporting
          i_structure_name    = 'SFLIGHT'
          is_hierarchy_header = l_hierarchy_header
        changing
          it_outtab           = gt_sflight. "table must be empty !
    §4. Create hierarchy (nodes and leaves)
      perform create_hierarchy.
    §5. Send data to frontend.
      call method g_alv_tree->frontend_update.
    endform.                    " init_tree
    *&      Form  build_hierarchy_header
          text
         <--P_L_HIERARCHY_HEADER  text
    form build_hierarchy_header  changing
                                    p_hierarchy_header type treev_hhdr.
    p_hierarchy_header-heading   = 'Month/Carrier/Date'.
    p_hierarchy_header-tooltip   = 'Flights in a Month'.
    p_hierarchy_header-width     = 30.
    p_hierarchy_header-width_pix = ' '.
    endform.                    " build_hierarchy_header
    *&      Form  create_hierarchy
          text
    -->  p1        text
    <--  p2        text
    form create_hierarchy .
    data: ls_sflight type sflight,
          lt_sflight type sflight occurs 0,
          l_yyyymm(6) type c,
          l_yyyymm_last(6) type c,
          l_carrid like sflight-carrid,
          l_carrid_last like sflight-carrid,
          l_month_key type lvc_nkey,
          l_carrid_key type lvc_nkey,
          l_last_key type lvc_nkey.
    §4a. Select data
    select * from sflight into table lt_sflight up to g_max rows.
    §4b. Sort output table according to your conceived hierarchy
    We sort in this order:
       year and month (top level nodes, yyyymm of DATS)
         carrier id (next level)
            day of month (leaves, dd of DATS)
    sort lt_sflight by fldate0(6) carrid fldate6(2).
    Note: The top level nodes do not correspond to a field of the
    output table. Instead we use data of the table to invent another
    hierarchy level above the levels that can be build by sorting.
    §4c. Add data to tree
    loop at lt_sflight into ls_sflight.
    Prerequesite: The table is sorted.
    You add a node everytime the values of a sorted field changes.
    Finally, the complete line is added as a leaf below the last
    node.
      l_yyyymm = ls_sflight-fldate+0(6).
      l_carrid = ls_sflight-carrid.
    Top level nodes:
      if l_yyyymm <> l_yyyymm_last.
        l_yyyymm_last = l_yyyymm.
    *Providing no key means that the node is added on top level:
        perform add_month using    l_yyyymm
                          changing l_month_key.
    The month changed, thus, there is no predecessor carrier
        clear l_carrid_last.
      endif.
    Carrier nodes:
    (always inserted as child of the last month
    which is identified by 'l_month_key')
      if l_carrid <> l_carrid_last.
        l_carrid_last = l_carrid.
        perform add_carrid_line using    ls_sflight
                                         l_month_key
                                changing l_carrid_key.
      endif.
    Leaf:
    (always inserted as child of the last carrier
    which is identified by 'l_carrid_key')
        perform add_complete_line using    ls_sflight
                                           l_carrid_key
                                  changing l_last_key.
    endloop.
    endform.                    " create_hierarchy
    *&      Form  add_month
          text
    form add_month  using    p_yyyymm type c
                             p_relat_key type lvc_nkey
                    changing p_node_key type lvc_nkey.
    data: l_node_text type lvc_value,
          ls_sflight  type sflight,
          l_month(15) type c.
    get month name for node text
    perform get_month using p_yyyymm
                      changing l_month.
    l_node_text = l_month.
    add node:
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
    the leaf gets a child and thus ALV converts it to a folder
    automatically.
    call method g_alv_tree->add_node
      exporting
        i_relat_node_key = p_relat_key
        i_relationship   = cl_gui_column_tree=>relat_last_child
        i_node_text      = l_node_text
        is_outtab_line   = ls_sflight
      importing
        e_new_node_key   = p_node_key.
    endform.                    " get_month
    *&      Form  get_month
          text
         -->P_P_YYYYMM  text
         <--P_L_MONTH  text
    form get_month  using    p_yyyymm
                    changing p_month.
    Returns the name of month according to the digits in p_yyyymm
    data: l_monthdights(2) type c.
    l_monthdights = p_yyyymm+4(2).
    case l_monthdights.
      when '01'.
       p_month = 'January'.
      when '02'.
       p_month = 'February'.
      when '03'.
       p_month = 'March'.
      when '04'.
       p_month = 'April'.
      when '05'.
       p_month = 'May'.
      when '06'.
       p_month = 'June'.
      when '07'.
       p_month = 'July'.
      when '08'.
       p_month = 'August'.
      when '09'.
       p_month = 'September'.
      when '10'.
       p_month = 'October'.
      when '11'.
       p_month = 'November'.
      when '12'.
       p_month = 'December'.
    endcase.
    concatenate p_yyyymm+0(4) '->' p_month into p_month.
    endform.                    " get_month
    *&      Form  add_carrid_line
          text
         -->P_LS_SFLIGHT  text
         -->P_L_MONTH_KEY  text
         <--P_L_CARRID_KEY  text
    form add_carrid_line  using    ps_sflight  type sflight
                                   p_relat_key type lvc_nkey
                          changing p_node_key  type lvc_nkey.
    data: l_node_text type lvc_value,
          ls_sflight  type sflight.
    add node
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
    the leaf gets a child and thus ALV converts it to a folder
    automatically.
    l_node_text = ps_sflight-carrid.
    call method g_alv_tree->add_node
      exporting
        i_relat_node_key = p_relat_key
        i_relationship   = cl_gui_column_tree=>relat_last_child
        i_node_text      = l_node_text
        is_outtab_line   = ls_sflight
      importing
        e_new_node_key   = p_node_key.
    endform.                    " add_carrid_line
    *&      Form  add_complete_line
          text
    form add_complete_line  using    ps_sflight   type sflight
                                     p_relat_key  type lvc_nkey
                            changing p_node_key   type lvc_nkey.
    data: l_node_text type lvc_value.
    write ps_sflight-fldate to l_node_text mm/dd/yyyy.
    add leaf:
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set.
    Since these nodes will never get children they stay leaves
    (as intended).
    call method g_alv_tree->add_node
    exporting
      i_relat_node_key = p_relat_key
      i_relationship   = cl_gui_column_tree=>relat_last_child
      i_node_text      = l_node_text
      is_outtab_line   = ps_sflight
    importing
      e_new_node_key   = p_node_key.
    endform.                    " add_complete_line
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
      when 'EXIT'.
       leave program.
    endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    reward if useful
    cheers,
    rekha

  • Editable field with F4 help in alv tree output using cl_gui_alv_tree

    HI
    i need Editable field with F4 help in alv tree output using cl_gui_alv_tree
    Regards
    Naresh

    Hi Naresh,
    Pass the field catalog with the additional parameter (ls_fcat-edit = 'X'.).
    for F4 help if the data element have the search help it automatically will come. other wise include the additional parameter in the field catalog (ls_fcat-F4AVAILABL = 'X')
    Reward if found helpful.
    Regards,
    Boobalan Suburaj

  • Delete blank lines when downloading to excel from CL_GUI_ALV_TREE

    Hi Experts
    I have developed a report using the class CL_GUI_ALV_TREE. If the user wants to download it into local machine in the excel format, he is going to the print preview and downloadn through Syste --> LIst --> Save --> Local File.
    But in the excel file there are few blank lines after each node. Now my client wants to excluding of those blank lines while downloading the file into excel. Is there any method to achieve this.
    Please advice me if there is any solution.
    Thanks in advance
    Praveen

    Hi Praveen,
    We cannot do any thing if the user download the file by that selection,
    Disable the download option from the toolbar and you provide a download button on the toolbar. as the user clicks the button the delete the black entries from the table and download it using  CL_GUI_FRONTEND_SERVICES.
    Regards,
    Kumar M.

  • CL_GUI_ALV_TREE  Event CHECKBOX_CHANGE

    Dear Experts,
    i use a tree control using class cl_gui_alv_tree.
    All fields of my fieldcatalog are specified as fieldcat-checkbox = 'X' and fieldcat-edit = 'X'.
    i have a global class zcl...... where i implemeted a method as event_handler for class cl_gui_alv_tree for event checkbox_change.
    i set the event handler before i set_table_for_first_display.
    Set event handler for clicks on hotspots
      SET HANDLER go_qual_block->hndl_checkbox_change FOR p_go_alv_tree.
      ls_header-tooltip   =
      ls_header-heading   = 'Blocking Materials'(008).
      ls_header-width     = 50.
      ls_header-width_pix = abap_false.
      CALL METHOD p_go_alv_tree->set_table_for_first_display
        EXPORTING
         I_STRUCTURE_NAME     =
         IS_VARIANT           =
         I_SAVE               =
          i_default            = abap_false
          is_hierarchy_header  = ls_header
         IS_EXCEPTION_FIELD   =
         IT_SPECIAL_GROUPS    =
         IT_LIST_COMMENTARY   =
         I_LOGO               =
         I_BACKGROUND_ID      =
         IT_TOOLBAR_EXCLUDING =
        CHANGING
          it_outtab            = <go_data_tab>
         IT_FILTER            =
          it_fieldcatalog      = lt_fcat.
    .... add nodes.... frontend_update....
    But when i start the program an click on a checkbox nothing happens. Is the event not triggered?
    I searched for examples which handels the event checkbox_change but i don't find anything.
    Is there a special handling for this event?
    thanks in advance.
    best regards,
    Dennis

    Hello thanks for this answer it was helpful but i have not solved the problem.
    My fault was, that i havn't registered the event before setting the event handler.
    but now i have a new problem to register the event.
      l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
      APPEND l_event TO lt_events.
      CALL METHOD p_go_alv_tree->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.
    Set event handler for clicks on hotspots
      SET HANDLER go_qual_block->hndl_checkbox_change FOR p_go_alv_tree.
    it comes back with sy-subrc = 3.
    triggered because item_selection inside the registration.
    But i don't know where this item_selection has to be set.
    LOOP AT EVENTS INTO SIMPLE_EVENT.
        CASE SIMPLE_EVENT-eventid.
          " base events
          when eventid_node_keypress.
          WHEN EVENTID_EXPAND_NO_CHILDREN.
          WHEN EVENTID_NODE_DOUBLE_CLICK.
            IF NOT SEL_CHANGE_USED IS INITIAL.
              RAISE ILLEGAL_EVENT_COMBINATION.
            ENDIF.
          WHEN EVENTID_SELECTION_CHANGED.
          WHEN EVENTID_NODE_CONTEXT_MENU_REQ
               or EVENTID_DEF_CONTEXT_MENU_REQ.
            " register context menu select event
            REG_CTX_MEN_SELECT = 'X'.
          " header
          when EVENTID_HEADER_CONTEXT_MEN_REQ.
            " register context menu select event
            REG_CTX_MEN_SELECT = 'X'.
          WHEN EVENTID_HEADER_CLICK.
            HEADER_CLICK_USED = 'X'.
          " item events
          WHEN EVENTID_BUTTON_CLICK
            OR EVENTID_LINK_CLICK
            OR EVENTID_CHECKBOX_CHANGE
            OR EVENTID_ITEM_DOUBLE_CLICK
            or eventid_item_keypress.
              IF ITEM_SELECTION IS INITIAL.
                                                                                    RAISE ILLEGAL_EVENT_COMBINATION.
              ENDIF.
          WHEN EVENTID_ITEM_CONTEXT_MENU_REQ.
            IF ITEM_SELECTION IS INITIAL.
              RAISE ILLEGAL_EVENT_COMBINATION.
            ENDIF.
            " register  context menu select event
            REG_CTX_MEN_SELECT = 'X'.
          WHEN OTHERS.
            RAISE ILLEGAL_EVENT_COMBINATION.
        ENDCASE.
    Best regards,
    Dennis

  • Alv using class (CL_GUI_ALV_TREE)

    hi guys,
                i want a small example on the class CL_GUI_ALV_TREE_using alv......... its urgent so plx reply immediately.............
    Thanks with regards,
    Vishnu. R

    hi,
    use the following code, if it useful reward the points.
    REPORT  zdemo_alvgrid                 .
    *Data Declaration
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko     TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          it_ekpo     TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko     TYPE t_ekko,
          wa_ekpo     TYPE t_ekko.
    DATA: ok_code like sy-ucomm,           "OK-Code
          save_ok like sy-ucomm.
    *ALV data declarations
    DATA: fieldcatalog  TYPE lvc_t_fcat WITH HEADER LINE.
    DATA: gd_fieldcat   TYPE lvc_t_fcat,
          gd_tab_group  TYPE slis_t_sp_group_alv,
          gd_layout     TYPE slis_layout_alv.
    *ALVtree data declarations
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    DATA: gd_tree             TYPE REF TO cl_gui_alv_tree,
          gd_hierarchy_header TYPE treev_hhdr,
          gd_report_title     TYPE slis_t_listheader,
          gd_logo             TYPE sdydo_value,
          gd_variant          TYPE disvariant.
    *Create container for alv-tree
    DATA: l_tree_container_name(30) TYPE c,
          l_custom_container        TYPE REF TO cl_gui_custom_container.
    *Includes
    *INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
    *INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
    *INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
    *Start-of-selection.
    START-OF-SELECTION.
    ALVtree setup data
        PERFORM data_retrieval.
        PERFORM build_fieldcatalog.
        PERFORM build_layout.
        PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
        PERFORM build_report_title USING gd_report_title gd_logo.
        PERFORM build_variant.
    Display ALVtree report
      call screen 100.
    *&      Form  DATA_RETRIEVAL
          Retrieve data into Internal tables
    FORM data_retrieval.
      SELECT ebeln
       UP TO 10 ROWS
        FROM ekko
        INTO corresponding fields of TABLE it_ekko.
      loop at it_ekko into wa_ekko.
        SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
          FROM ekpo
          appending TABLE it_ekpo
         where ebeln eq wa_ekko-ebeln.
      endloop.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    Please not there are a number of differences between the structure of
    ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
    For example the field seltext_m is replace by scrtext_m in ALVtree.
      fieldcatalog-fieldname   = 'EBELN'.           "Field name in itab
      fieldcatalog-scrtext_m   = 'Purchase Order'.  "Column text
      fieldcatalog-col_pos     = 0.                 "Column position
      fieldcatalog-outputlen   = 15.                "Column width
      fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
      fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
    fieldcatalog-do_sum      = 'X'.              "Sum Column?
    fieldcatalog-no_zero     = 'X'.              "Don't display if zero
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-scrtext_m   = 'PO Iten'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-scrtext_m   = 'Status'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-scrtext_m   = 'Item change date'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-scrtext_m   = 'Material Number'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-scrtext_m   = 'PO quantity'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-scrtext_m   = 'Order Unit'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-scrtext_m   = 'Net Price'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-scrtext_m   = 'Price Unit'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  build_hierarchy_header
          build hierarchy-header-information
         -->P_L_HIERARCHY_HEADER  structure for hierarchy-header
    FORM build_hierarchy_header CHANGING
                                   p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'(013).
      p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  BUILD_REPORT_TITLE
          Build table for ALVtree header
    <->  p1        Header details
    <->  p2        Logo value
    FORM build_report_title CHANGING
          pt_report_title  TYPE slis_t_listheader
          pa_logo             TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader,
            ld_date(10) TYPE c.
    List Heading Line(TYPE H)
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    ls_line-key     "Not Used For This Type(H)
      ls_line-info = 'PO ALVTree Display'.
      APPEND ls_line TO pt_report_title.
    Status Line(TYPE S)
      ld_date(2) = sy-datum+6(2).
      ld_date+2(1) = '/'.
      ld_date3(2) = sy-datum4(2).
      ld_date+5(1) = '/'.
      ld_date+6(4) = sy-datum(4).
      ls_line-typ  = 'S'.
      ls_line-key  = 'Date'.
      ls_line-info = ld_date.
      APPEND ls_line TO pt_report_title.
    Action Line(TYPE A)
      CLEAR ls_line.
      ls_line-typ  = 'A'.
      CONCATENATE 'Report: ' sy-repid INTO ls_line-info  SEPARATED BY space.
      APPEND ls_line TO pt_report_title.
    ENDFORM.
    *&      Form  BUILD_VARIANT
          Build variant
    form build_variant.
    Set repid for storing variants
      gd_variant-report = sy-repid.
    endform.                    " BUILD_VARIANT

  • Cl_gui_alv_tree no child nodes after registering event

    Hey guys,
    I have an uncommon problem with cl_gui_alv_tree.
    My tree has 2 layers, Root and child. Both of them have layout-class  cl_gui_column_tree=>item_class_checkbox.
    Everithing works fine! (without_events.jpg)
    But if I register event "checkbox_change" with method SET_REGISTERED_EVENTS the childnodes disapear! (with_events.jpg)
    Does anyone know a solution?
    here's some code:
    data; gr_alv_0200 type ref to cl_gui_alv_tree.
    METHOD init_dynpro_0200.
         DATA: ls_hierarchy_header TYPE treev_hhdr.
         IF gr_cont_0200 IS INITIAL.
           CREATE OBJECT gr_cont_0200
             EXPORTING
               container_name              = 'CC200'
             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.
         ENDIF.
         IF gr_alv_0200 IS INITIAL.
           CREATE OBJECT gr_alv_0200
             EXPORTING
    *         lifetime                    =
               parent                      = gr_cont_0200
               node_selection_mode         = cl_gui_column_tree=>node_sel_mode_single
               item_selection              = 'X'
               no_toolbar                  = 'X'
               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.
           CHECK sy-subrc EQ 0.
           ls_hierarchy_header-heading = 'Hierarchy Header'.     "#EC NOTEXT
           ls_hierarchy_header-tooltip =
                                  'This is the Hierarchy Header !'. "#EC NOTEXT
           ls_hierarchy_header-width = 100.
           ls_hierarchy_header-width_pix = ''.
            tree_create_fcat( ).
           CALL METHOD gr_alv_0200->set_table_for_first_display
             EXPORTING
               is_hierarchy_header = ls_hierarchy_header
               i_background_id     = 'ALV_BACKGROUND'
             CHANGING
               it_outtab           = gt_treenodes
               it_fieldcatalog     = gt_fcat_0200.
           DATA: lt_events TYPE cntl_simple_events,
                     ls_event LIKE LINE OF lt_events.
           ls_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
           APPEND ls_event TO lt_events.
           CALL METHOD gr_alv_0200->set_registered_events
             EXPORTING
               events                    = lt_events
             EXCEPTIONS
               cntl_error                = 1
               cntl_system_error         = 2
               illegal_event_combination = 3.
           SET HANDLER me->on_tree_checkbox_change FOR gr_alv_0200.
         ENDIF.
       ENDMETHOD.
    METHOD tree_add_node.
         DATA: ls_node_text TYPE lvc_value.
    * set item-layout
         DATA: lt_item_layout TYPE lvc_t_layi,
               ls_item_layout TYPE lvc_s_layi.
         ls_item_layout-fieldname = gr_alv_0200->c_hierarchy_column_name.
         ls_item_layout-style   = cl_gui_column_tree=>style_intensifd_critical.
         ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
         ls_item_layout-editable = 'X'.
         APPEND ls_item_layout TO lt_item_layout.
    * add node
         ls_node_text =  is_data-name.
         DATA: ls_node TYPE lvc_s_layn.
         ls_node-n_image   = space.
         ls_node-exp_image = space.
         CALL METHOD gr_alv_0200->add_node
           EXPORTING
             i_relat_node_key = iv_parent
             i_relationship   = cl_gui_column_tree=>relat_last_child
             i_node_text      = ls_node_text
             is_outtab_line   = is_data
             is_node_layout   = ls_node
            it_item_layout   = lt_item_layout
           IMPORTING
             e_new_node_key   = ev_node_id.
       ENDMETHOD.
    in my current class I've method on_tree_checkbox_change to handle the event. If the event is registered, the method gets called.

    Solved by my own:
    I had to implement method get_registered_events( ), append the new event to the table and call set_registered_events( ).
    The table from get_registered_events( ) is already filled with events.

  • CL_GUI_ALV_TREE - Possible to edit the table cells in situ?

    Hi
    I am working on my first CL_GUI_ALV_TREE report.  The hierarchy is in place and the fields come through ok on the table side.  However,  I would now like to edit the fields.  I have the checkbox showing in the tree control and the row is set to editable.  Am I able to edit the fields in the table side in situ, as I would do in the CL_GUI_ALV_GRID control i.e. using mc_style_enabled/disabled?  These attributes are not present in the class builder so I presume not.  Is there another way? 
    Cheers
    Ian

    Hi
    module user_command_0100 input.
      DATA return TYPE REF TO cl_gui_event.
      save_ok = ok_code.
      case ok_code.
        when 'EXIT' or 'BACK' or 'CANC'.
        Exit program
          leave to screen 0.
      Process ALVtree user actions     
        when others.
          call method cl_gui_cfw=>get_current_event_object
                  receiving
                     event_object = return.
          call method cl_gui_cfw=>dispatch.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    check this code and call method cl_gui_cfw
    hope this helps u....
    Reward points if useful...
    Regards
    Sreenivas

  • Color subtotal value while using class "cl_gui_alv_tree"

    Dear All,
    Can we color subtotal value?? I am using class "cl_gui_alv_tree" to creare alv tree.  if yes please let me know how.
    Regards.
    Gyanendra

    Hi gop4sap11 ,
    Autometically subtotal is coming  coloured that is fine,but my requirment is like,,,  
    can i manually coloured subtotal value of any particular node of any column based on some condition??
    for ex: node name  : -
    af
    coloumn name : ---abc    bcd
    60       70
    can i colore 60 or 70 in red colore?
    subtotal is calculating using standard method
    call method tree1->update_calculations.  of class "cl_gui_alv_tree"
    after that , i tried to use following method
    LOOP AT lt_node_temp INTO ls_node_temp.
                      CALL METHOD TREE1->GET_OUTTAB_LINE
                           EXPORTING
                             I_NODE_KEY     = ls_node_temp-lv_p_node_key
                           IMPORTING
                             E_OUTTAB_LINE  = lv_E_OUTTAB_LINE
                             E_NODE_TEXT    = LV_E_NODE_TEXT
                             ET_ITEM_LAYOUT = LV_ET_ITEM_LAYOUT
                             ES_NODE_LAYOUT = LV_ES_NODE_LAYOUT
                           EXCEPTIONS
                             NODE_NOT_FOUND = 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.
                         CALL METHOD TREE1->CHANGE_NODE
                           EXPORTING
                             I_NODE_KEY     = ls_node_temp-lv_p_node_key
                             I_OUTTAB_LINE  = lv_E_OUTTAB_LINE
                             IS_NODE_LAYOUT = LV_ES_NODE_TEMP_LAYOUT
                             IT_ITEM_LAYOUT = LV_ET_ITEM_TEMP_LAYOUT
                             I_NODE_TEXT    = LV_E_NODE_TEXT
                            I_U_NODE_TEXT  =
                           EXCEPTIONS
                             NODE_NOT_FOUND = 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.
    ENDLOOP.
    this method must be called to send the data to the frontend
      call method tree1->frontend_update.

  • How to print a footer using CL_GUI_ALV_TREE class

    Dear Abapers.
    I'm using SET_TABLE_FOR_FIRST_DISPLAY method from CL_GUI_ALV_TREE class to display a report in an ALV Tree and I need to display the footer.
    Using the PRINT_END_OF_PAGE event from class CL_GUI_ALV_GRID we can display the header, but I need to use CL_GUI_ALV_TREE and there is no method for END_OF_PAGE.
    Can you please help me?
    Many thanks.
    Estela

    Dear Abapers.
    I'm using SET_TABLE_FOR_FIRST_DISPLAY method from CL_GUI_ALV_TREE class to display a report in an ALV Tree and I need to display the footer.
    Using the PRINT_END_OF_PAGE event from class CL_GUI_ALV_GRID we can display the header, but I need to use CL_GUI_ALV_TREE and there is no method for END_OF_PAGE.
    Can you please help me?
    Many thanks.
    Estela

  • ALV using cl_gui_alv_tree

    Hi All,
    Iam new to the concept of ALV classes. The requriement is to display the BOM details in a multilevel hierarchial tree structure  ( there is no limit for the drill down levels). Is it possible to display using the class CL_GUI_ALV_TREE. Is there any sample standard program available. Please suggest.
    Thanks in Advance.

    hi,
    GOTO SE80--> Write package name "SLIS"
    in this package you find all the program related to ur topic.
    hope its helps
    Regards
    Ritesh J

  • Add/Edit/Delete Tree Nodes using CL_GUI_ALV_TREE

    Hi All,
    I am looking for an example of program with CL_GUI_ALV_TREE that have a functionality of add a tree node, edit a tree node, and delete a tree node.
    I have already looked the BCALV_TREE* demo program but could not able to find a program to add/edit/delete node tree elements.
    Any info on this.
    Thanks
    aRs

    Hello aRs
    Here is a sample report showing how to delete nodes in an ALV tree. The report was copied from BCALV_TREE_01. Search for added code:
    *$ADDED: begin
    *$ADDED: end[/code]
    When you display the tree expand the first folder completely. When entering 'DELETE' into the command field directly the first flight date node will be deleted.
    REPORT ZUS_SDN_BCALV_TREE_01_DELNODE.
    based on: REPORT  bcalv_tree_01.
    Purpose:
    ~~~~~~~~
    This report shows the essential steps to build up a hierarchy
    using an ALV Tree Control (class CL_GUI_ALV_TREE).
    Note that it is not possible to build up this hierarchy
    using a simple ALV Tree Control (class CL_GUI_ALV_TREE_SIMPLE).
    To check program behavior
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Start this report. The hierarchy tree consists of nodes for each
    month on top level (this level can not be build by a simple ALV Tree
    because there is no field for months in our output table SFLIGHT.
    Thus, you can not define this hierarchy by sorting).
    Nor initial calculations neither a special layout has been applied
    (the lines on the right do not show anything).
    Note also that this example does not build up and change the
    fieldcatalog of the output table. For this reason, all fields
    of the output table are shown in the columns although the fields
    CARRID and FLDATE are already placed in the tree on the left.
    (Of course, this is not a good style. See BCALV_TREE_02 on how to
    hide columns).
    Essential steps (Search for '§')
    ~~~~~~~~~~~~~~~
    1.Usual steps when using control technology.
       1a. Define reference variables.
       1b. Create ALV Tree Control and corresponding container.
    2.Create Hierarchy-header
    3.Create empty Tree Control
    4.Create hierarchy (nodes and leaves)
       4a. Select data
       4b. Sort output table according to your conceived hierarchy
       4c. Add data to tree
    5.Send data to frontend.
    6.Call dispatch to process toolbar functions
    *$ADDED: begin
    DATA:
      gd_del_nkey      TYPE lvc_nkey.
    *$ADDED: end
    §1a. Define reference variables
    DATA: g_alv_tree         TYPE REF TO cl_gui_alv_tree,
          g_custom_container TYPE REF TO cl_gui_custom_container.
    DATA: gt_sflight      TYPE sflight OCCURS 0,      "Output-Table
          ok_code LIKE sy-ucomm,
          save_ok LIKE sy-ucomm,           "OK-Code
          g_max TYPE i VALUE 255.
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Module  PBO  OUTPUT
          process before output
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAINTITLE'.
      IF g_alv_tree IS INITIAL.
        PERFORM init_tree.
        CALL METHOD cl_gui_cfw=>flush
          EXCEPTIONS
            cntl_system_error = 1
            cntl_error        = 2.
        IF sy-subrc NE 0.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'Automation Queue failure'(801)
              txt1  = 'Internal error:'(802)
              txt2  = 'A method in the automation queue'(803)
              txt3  = 'caused a failure.'(804).
        ENDIF.
      ENDIF.
    ENDMODULE.                             " PBO  OUTPUT
    *&      Module  PAI  INPUT
          process after input
    MODULE pai INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      CASE save_ok.
        WHEN 'EXIT' OR 'BACK' OR 'CANC'.
          PERFORM exit_program.
    *$ADDED: begin
        WHEN 'DELETE'.
          CALL METHOD g_alv_tree->delete_subtree
            EXPORTING
              i_node_key                = gd_del_nkey
             I_UPDATE_PARENTS_EXPANDER = SPACE
              i_update_parents_folder   = 'X'
            EXCEPTIONS
              node_key_not_in_model     = 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.
          CALL METHOD g_alv_tree->frontend_update.
    *$ADDED: end
        WHEN OTHERS.
    §6. Call dispatch to process toolbar functions
          CALL METHOD cl_gui_cfw=>dispatch.
      ENDCASE.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                             " PAI  INPUT
    *&      Form  init_tree
          text
    -->  p1        text
    <--  p2        text
    FORM init_tree.
    §1b. Create ALV Tree Control and corresponding Container.
    create container for alv-tree
      DATA: l_tree_container_name(30) TYPE c.
      l_tree_container_name = 'CCONTAINER1'.
      CREATE OBJECT g_custom_container
         EXPORTING
               container_name = l_tree_container_name
         EXCEPTIONS
               cntl_error                  = 1
               cntl_system_error           = 2
               create_error                = 3
               lifetime_error              = 4
               lifetime_dynpro_dynpro_link = 5.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'(100).
      ENDIF.
    create tree control
      CREATE OBJECT g_alv_tree
        EXPORTING
            parent              = g_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            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.
    §2. Create Hierarchy-header
    The simple ALV Tree uses the text of the fields which were used
    for sorting to define this header. When you use
    the 'normal' ALV Tree the hierarchy is build up freely
    by the programmer this is not possible, so he has to define it
    himself.
      DATA l_hierarchy_header TYPE treev_hhdr.
      PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
    §3. Create empty Tree Control
    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 g_alv_tree->set_table_for_first_display
        EXPORTING
          i_structure_name    = 'SFLIGHT'
          is_hierarchy_header = l_hierarchy_header
        CHANGING
          it_outtab           = gt_sflight. "table must be empty !
    §4. Create hierarchy (nodes and leaves)
      PERFORM create_hierarchy.
    §5. Send data to frontend.
      CALL METHOD g_alv_tree->frontend_update.
    wait for automatic flush at end of pbo
    ENDFORM.                               " init_tree
    *&      Form  build_hierarchy_header
          build hierarchy-header-information
         -->P_L_HIERARCHY_HEADER  strucxture for hierarchy-header
    FORM build_hierarchy_header CHANGING
                                   p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Month/Carrier/Date'(300).
      p_hierarchy_header-tooltip = 'Flights in a month'(400).
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ' '.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  exit_program
          free object and leave program
    FORM exit_program.
      CALL METHOD g_custom_container->free.
      LEAVE PROGRAM.
    ENDFORM.                               " exit_program
    *&      Form  create_hierarchy
          text
    -->  p1        text
    <--  p2        text
    FORM create_hierarchy.
      DATA: ls_sflight TYPE sflight,
            lt_sflight TYPE sflight OCCURS 0,
            l_yyyymm(6) TYPE c,            "year and month of sflight-fldate
            l_yyyymm_last(6) TYPE c,
            l_carrid LIKE sflight-carrid,
            l_carrid_last LIKE sflight-carrid.
      DATA: l_month_key TYPE lvc_nkey,
            l_carrid_key TYPE lvc_nkey,
            l_last_key TYPE lvc_nkey.
    §4a. Select data
      SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.
    §4b. Sort output table according to your conceived hierarchy
    We sort in this order:
       year and month (top level nodes, yyyymm of DATS)
         carrier id (next level)
            day of month (leaves, dd of DATS)
      SORT lt_sflight BY fldate0(6) carrid fldate6(2).
    Note: The top level nodes do not correspond to a field of the
    output table. Instead we use data of the table to invent another
    hierarchy level above the levels that can be build by sorting.
    §4c. Add data to tree
      LOOP AT lt_sflight INTO ls_sflight.
    Prerequesite: The table is sorted.
    You add a node everytime the values of a sorted field changes.
    Finally, the complete line is added as a leaf below the last
    node.
        l_yyyymm = ls_sflight-fldate+0(6).
        l_carrid = ls_sflight-carrid.
    Top level nodes:
        IF l_yyyymm <> l_yyyymm_last.      "on change of l_yyyymm
          l_yyyymm_last = l_yyyymm.
    *Providing no key means that the node is added on top level:
          PERFORM add_month USING    l_yyyymm
                                 CHANGING l_month_key.
    The month changed, thus, there is no predecessor carrier
          CLEAR l_carrid_last.
        ENDIF.
    Carrier nodes:
    (always inserted as child of the last month
    which is identified by 'l_month_key')
        IF l_carrid <> l_carrid_last.      "on change of l_carrid
          l_carrid_last = l_carrid.
          PERFORM add_carrid_line USING    ls_sflight
                                           l_month_key
                                  CHANGING l_carrid_key.
        ENDIF.
    Leaf:
    (always inserted as child of the last carrier
    which is identified by 'l_carrid_key')
        PERFORM add_complete_line USING  ls_sflight
                                         l_carrid_key
                                CHANGING l_last_key.
      ENDLOOP.
    ENDFORM.                               " create_hierarchy
    *&      Form  add_month
    FORM add_month  USING     p_yyyymm TYPE c
                              p_relat_key TYPE lvc_nkey
                    CHANGING  p_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_sflight TYPE sflight,
            l_month(15) TYPE c.            "output string for month
    get month name for node text
      PERFORM get_month USING p_yyyymm
                        CHANGING l_month.
      l_node_text = l_month.
    add node:
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
    the leaf gets a child and thus ALV converts it to a folder
    automatically.
      CALL METHOD g_alv_tree->add_node
        EXPORTING
          i_relat_node_key = p_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_sflight
        IMPORTING
          e_new_node_key   = p_node_key.
    ENDFORM.                               " add_month
    FORM add_carrid_line USING     ps_sflight TYPE sflight
                                   p_relat_key TYPE lvc_nkey
                         CHANGING  p_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_sflight TYPE sflight.
    add node
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
    the leaf gets a child and thus ALV converts it to a folder
    automatically.
      l_node_text =  ps_sflight-carrid.
      CALL METHOD g_alv_tree->add_node
        EXPORTING
          i_relat_node_key = p_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_sflight
        IMPORTING
          e_new_node_key   = p_node_key.
    ENDFORM.                               " add_carrid_line
    *&      Form  add_complete_line
    FORM add_complete_line USING   ps_sflight TYPE sflight
                                   p_relat_key TYPE lvc_nkey
                         CHANGING  p_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value.
      WRITE ps_sflight-fldate TO l_node_text MM/DD/YYYY.
    add leaf:
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set.
    Since these nodes will never get children they stay leaves
    (as intended).
      CALL METHOD g_alv_tree->add_node
        EXPORTING
          i_relat_node_key = p_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          is_outtab_line   = ps_sflight
          i_node_text      = l_node_text
        IMPORTING
          e_new_node_key   = p_node_key.
    *$ADDED: begin
      IF ( ps_sflight-fldate = '20040522' ).  " first flight date
        IF ( gd_del_nkey IS INITIAL ).  " collect only first date
          gd_del_nkey = p_node_key.
        ENDIF.
      ENDIF.
    *$ADDED: end
    ENDFORM.                               " add_complete_line
    *&      Form  GET_MONTH
          text
         -->P_P_YYYYMM  text
         <--P_L_MONTH  text
    FORM get_month USING    p_yyyymm
                   CHANGING p_month.
    Returns the name of month according to the digits in p_yyyymm
      DATA: l_monthdigits(2) TYPE c.
      l_monthdigits = p_yyyymm+4(2).
      CASE l_monthdigits.
        WHEN '01'.
          p_month = 'January'(701).
        WHEN '02'.
          p_month = 'February'(702).
        WHEN '03'.
          p_month = 'March'(703).
        WHEN '04'.
          p_month = 'April'(704).
        WHEN '05'.
          p_month = 'May'(705).
        WHEN '06'.
          p_month = 'June'(706).
        WHEN '07'.
          p_month = 'July'(707).
        WHEN '08'.
          p_month = 'August'(708).
        WHEN '09'.
          p_month = 'September'(709).
        WHEN '10'.
          p_month = 'October'(710).
        WHEN '11'.
          p_month = 'November'(711).
        WHEN '12'.
          p_month = 'December'(712).
      ENDCASE.
      CONCATENATE p_yyyymm+0(4) '->' p_month INTO p_month.
    ENDFORM.                               " GET_MONTH
    /code
    Regards
      Uwe

  • Edit Toolbar of CL_GUI_ALV_TREE

    Hi everyone,
    I'm wondering how to edit the toolbar of the CL_GUI_ALV_TREE. There is no toolbar event like in CL_GUI_ALV_GRID.
    In case of CL_GUI_ALV_GRID you have the attribute 'mt_toolbar' which is an internal table, containing the toolbar buttons.
    In case of CL_GUI_ALV_TREE there is only the attribute 'mr_toolbar' which is a reference to CL_GUI_TOOLBAR. So I thought about editing the internal table M_TABLE_BUTTON from CL_GUI_TOOLBAR(should be the same as mt_toolbar), but it's read-only
    Any idea how to edit/personalize the toolbar of CL_GUI_ALV_TREE?

    For solution check program BCALV_TREE_DEMO, form: change_toolbar!

Maybe you are looking for