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

Similar Messages

  • 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

  • ALV Tree Output

    Hi,
    In my present project we have requirement for developing ALV tree output using ALV configuration model in WD4A. Please provide sample code or tutorial related to ALV Tree development in WebDynpro ABAP.
    Best regards,
    Alleiah

    Hi Alleiah Marabathini ,
    The following r excellent websites containing ONLY PDF docs on ALV Tree in WebDynpro ABAP:
    Simple Example for Using ALV in Web Dynpro for ABAP
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3439404a-0801-0010-dda5-8c14514d690d
    Programming the ALV Configuration Model in Web Dynpro for ABAP
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1190424a-0801-0010-84b5-ef03fd2d33d9
    Editing ALV in Web Dynpro for ABAP
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1
    Using Events with ALV Tables in Web Dynpro for ABAP
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bd28494a-0801-0010-45a3-fc359d82d3e8
    Using ALV with a Dynamic Context Node in Web Dynpro for ABAP
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783
    cheers!
    gyanaraj

  • Alv field with f4 help without using class

    Hi,
    Can any one give me a program of "Alv field with f4 help without using class".
    Thanking you in advance.

    hi
    <b>Linking F4 Help to Fields</b>
    For the last section, we will deal with linking F4 help to fields. It is easy. As usual, define, implement and register the event “onf4” at proper places in your code. For F4 help, you must register the fields whose F4 request will trigger the “onf4” event. For this you must prepare a table of type “LVC_T_F4” and register this table using the method “register_f4_for_fields”. While preparing table you must include a line for each field which will trigger F4 event. For each field in the structure;
    &#1048766; Pass the fieldname to ‘FIELDNAME’
    &#1048766; Set ‘REGISTER’ to make the field registered,
    &#1048766; Set ‘GETBEFORE’ to provide field content transport before F4 in editable mode
    &#1048766; Set ‘CHNGEAFTER’ to make the data changed after F4 in editable mode.
    DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE .
    lt_f4-fieldname = 'PRICE'.
    lt_f4-register = 'X' .
    lt_f4-getbefore = 'X' .
    APPEND lt_f4 .
    CALL METHOD gr_alvgrid->register_f4_for_fields
    EXPORTING
    it_f4 = lt_f4[] .
    Preparing table for the fields to be registered to trigger F4 event
    METHOD handle_on_f4 .
    PERFORM f4_help USING e_fieldname es_row_no .
    er_event_data->m_event_handled = 'X' .
    ENDMETHOD .
    A sample “onf4” method implementation
    Again, we set the attribute “er_event_data->m_event_handled” to prevent further processing of standard F4 help.
    regards
    Ravish
    <b>
    reward if useful</b>

  • Error while adding a custom field with Input help via AET

    Hi All,
    I need to add two custom field under Service orders at Item level in component BT140I_SRVP.
    One field is required to have the input search help f4 and autopopulates the second field
    I am able to add one field(not requiring help) successfully through AET .
    I have created one Zsearch_help in se11 and its successfully running  and Autopopulating seocnd field while I am testing it
    While adding second field through AET,I need to enter following details as -
    field label,search relevant ,serach help etc.
    When I type the name of my 'Zsearch_help' against field search help it gives me following error
    'Search help is not compatible'.
    Secondly,not getting getter and setter methods for the attrributes in BTAdminI.
    Last,please tell me if i create zhelp and activate it,would it automatically appear in the list on AETwhile assiging it to input field?
    Please help me out.Kindly be detailed as I am new to SAP CRM.
    Thanks,
    Shivani

    The question is answered in CRM 7.0 forum:
    Getting error while adding a custom field (with input help) through AET

  • Double click in ALV tree output????

    Hi all,
    I am able to display output in tree format. But I want to add the double click functionality to some of the fields in output. Means if I double click on some value in output tree, it should call some transaction. Please help me with this issue of double clicking.
    Please tell how to handle events in this report tree display.
    For the following code its displaying output in tree format and in right way. But i need to add double click functionality to this.
    So provide me some sample program for this one....
    * create hierarchy
      CALL METHOD tree1->set_table_for_first_display
              EXPORTING
                   it_list_commentary   = lt_list_commentary
                   i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = ls_variant
              CHANGING
                   it_sort              = gt_sort[]
                   it_outtab            = itab_outtab
                   it_fieldcatalog      = t_fieldcat. "gt_fieldcatalog.
    * expand first level
      CALL METHOD tree1->expand_tree
             EXPORTING
                 i_level = 1.
    * optimize column-width
      CALL METHOD tree1->column_optimize
               EXPORTING
                   i_start_column = tree1->c_hierarchy_column_name
                   i_end_column   = tree1->c_hierarchy_column_name.
    In grid ALV we can have double cilck functionality using code:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program       = w_repid
                i_callback_pf_status_set = 'PF_STATUS'
                i_callback_user_command  = 'USER_COMMAND'
                is_layout                = ls_layout
                it_fieldcat              = gt_fc[]
    Here we can write subroutine for USER_COMMAND and handle the double click evenet. But tell me how to provide this in tree ALV.
    <REMOVED BY MODERATOR>
    Regards,
    Sachin
    Edited by: Alvaro Tejada Galindo on Feb 14, 2008 1:47 PM

    Hello Sachin
    The following sample report ZUS_SDN_ALV_TREE_DEMO demonstrates the crucial parts for double-click event handling (nodes & items) in ALV trees.
    *& Report  ZUS_SDN_ALV_TREE_DEMO
    *& Thread: double click in ALV tree output????
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="742412"></a>
    REPORT  zus_sdn_alv_tree_demo.
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    TYPE-POOLS: abap.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE knvv AS data.
    TYPES: nkey       TYPE lvc_nkey.
    TYPES: parent_key TYPE lvc_nkey.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab    TYPE ty_t_outtab.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_tree          TYPE REF TO cl_gui_alv_tree.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
        handle_node_double_click
          FOR EVENT node_double_click OF cl_gui_alv_tree
          IMPORTING node_key,
        handle_item_double_click
          FOR EVENT item_double_click OF cl_gui_alv_tree
          IMPORTING node_key
                    fieldname.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_node_double_click.
        message 'Event=Double-Click on Node' type 'I'.
        call transaction 'XD03'.
      ENDMETHOD.                    "handle_node_double_click
      METHOD handle_item_double_click.
        message 'Event=Double-Click on Item' type 'I'.
        call transaction 'VA03'.
      ENDMETHOD.                    "handle_item_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      PERFORM init_controls.
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      container                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL SCREEN '0100'.
    ** NOTE: no elements on screen
    **  PROCESS BEFORE OUTPUT.
    **    MODULE STATUS_0100.
    **  PROCESS AFTER INPUT.
    **    MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      TRANSLATE gd_okcode TO UPPER CASE.
      CASE gd_okcode.
        WHEN 'BACK'  OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'REFRESH'.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  init_controls
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * create tree control
      CREATE OBJECT go_tree
        EXPORTING
            parent              = go_docking
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection      = 'X'  " required for double-click event on item
            no_html_header      = ''
            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.
    * create Hierarchy-header
      DATA ls_hierarchy_header TYPE treev_hhdr.
      PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
    * create emty tree-control
      CALL METHOD go_tree->set_table_for_first_display
        EXPORTING
    **      i_structure_name     = 'KNVV'
          is_variant           = gs_variant
          i_save               = 'A'
    *      i_default            = 'X'
          is_hierarchy_header  = ls_hierarchy_header
    *      is_exception_field   =
    *      it_special_groups    =
    *      it_list_commentary   =
    *      i_logo               =
    *      i_background_id      =
    *      it_toolbar_excluding =
    *      it_except_qinfo      =
        CHANGING
          it_outtab            = gt_outtab
    *      it_filter            =
          it_fieldcatalog      = gt_fcat.
    * create hierarchy
      PERFORM create_hierarchy.
    * register events
      PERFORM register_events.
    * adjust column_width
      CALL METHOD go_tree->column_optimize.
    ENDFORM.                    " init_controls
    *&      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 = 'Hierarchy Header'.          "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'This is the Hierarchy Header !'.  "#EC NOTEXT
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
      REFRESH: gt_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNVV'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      DELETE gt_fcat FROM 8.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'TREE'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  create_hierarchy
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_hierarchy .
      DATA: ls_knvv    TYPE sflight,
            ls_outtab  TYPE ty_s_outtab,
            lt_outtab  TYPE ty_t_outtab.
    * get data
      SELECT * FROM knvv INTO CORRESPONDING FIELDS OF TABLE lt_outtab
                            UP TO 200 ROWS .                "#EC CI_NOWHERE
      SORT lt_outtab BY kunnr vkorg.
    * add data to tree
      DATA: ld_kunnr_key TYPE lvc_nkey,
            ld_vkorg_key TYPE lvc_nkey,
            ld_last_key  TYPE lvc_nkey.
      LOOP AT lt_outtab INTO ls_outtab.
        ON CHANGE OF ls_outtab-kunnr.
          PERFORM add_customer_line USING    ls_outtab-data
                                  CHANGING ld_kunnr_key.
        ENDON.
        ON CHANGE OF ls_outtab-vkorg.
          PERFORM add_salesorg_line USING    ls_outtab-data
                                             ld_kunnr_key
                                  CHANGING ld_vkorg_key.
        ENDON.
        PERFORM add_complete_line USING  ls_outtab-data
                                         ld_vkorg_key
                                CHANGING ld_last_key.
      ENDLOOP.
    * calculate totals
      CALL METHOD go_tree->update_calculations.
    * this method must be called to send the data to the frontend
      CALL METHOD go_tree->frontend_update.
    ENDFORM.                    " create_hierarchy
    *&      Form  add_customer_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_customer_line USING     us_data TYPE ty_s_outtab-data
                                     ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_data TYPE ty_s_outtab-data.
    * set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@A0@'.  " icon_customer.
      ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      APPEND ls_item_layout TO lt_item_layout.
    * add node
      l_node_text =  us_data-kunnr.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_data
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_customer_line
    *&      Form  add_salesorg_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_salesorg_line USING     us_data TYPE ty_s_outtab-data
                                     ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_data TYPE ty_s_outtab-data.
    * set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@DS@'.  " ICON_PARTNER_SALES_ACTIVITY
      ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      APPEND ls_item_layout TO lt_item_layout.
    * add node
      l_node_text =  us_data-vkorg.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_data
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_salesorg_line
    *&      Form  add_cmplete_line
    *       add hierarchy-level 3 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_complete_line USING     us_data TYPE ty_s_outtab-data
                                     ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_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 = go_tree->c_hierarchy_column_name.
      ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
    **  ls_item_layout-editable = 'X'.
      APPEND ls_item_layout TO lt_item_layout.
    **  CLEAR ls_item_layout.
    **  ls_item_layout-fieldname = 'PLANETYPE'.
    **  ls_item_layout-alignment = cl_gui_column_tree=>align_right.
    **  APPEND ls_item_layout TO lt_item_layout.
      l_node_text =  us_data-vtweg.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          is_outtab_line   = us_data
          i_node_text      = l_node_text
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_complete_line
    *&      Form  register_events
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM register_events.
    * define the events which will be passed to the backend
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event.
    * define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_header_click.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
    **  APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
      APPEND l_event TO lt_events.
      CALL METHOD go_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 Handler
      set handler:
        lcl_eventhandler=>handle_node_double_click for go_tree,
        lcl_eventhandler=>handle_item_double_click for go_tree.
    **  DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
    **  CREATE OBJECT l_event_receiver.
    **  SET HANDLER l_event_receiver->handle_node_ctmenu_request
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_node_ctmenu_selected
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_item_ctmenu_request
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_item_ctmenu_selected
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.
    ENDFORM.                               " register_events
    Regards
      Uwe

  • 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

  • Sort Icon/option in ALV tree repot using classes and methods

    Hi all,
    I have done an alv tree report using the class cl_gui_alv_tree
    and i need to let users re-sort the report by using a sort icon(as visible in a normal alv report).Is there any possibility to create an icon and set the functionality such that the entire tree structure gets resorted depending upon the sort criteria?Please give me an example of doing so if there is an option.

    if u want without classes then i can  give an example of Sort Icon/option.
    example:-
    DATA:   wa_sortinfo TYPE slis_sortinfo_alv.
           i_sortcat TYPE slis_t_sortinfo_alv.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program     = report_id
                i_grid_title           = ws_title
               i_callback_top_of_page = 'TOP-OF-PAGE'
                is_layout              = wa_layout
                it_fieldcat            = i_fieldcat[]
                it_sort                = i_sortcat
                i_save                 = 'A'
                it_events              = i_events
           TABLES
                t_outtab               = i_reportdata1
           EXCEPTIONS
                program_error          = 1
                OTHERS                 = 2.
      IF sy-subrc  0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      PERFORM sortcat_init CHANGING i_sortcat.
    FORM sortcat_init CHANGING i_sortcat TYPE slis_t_sortinfo_alv.
      CLEAR wa_sortinfo.
      wa_sortinfo-fieldname = 'EBELN'. (sales order)
      wa_sortinfo-tabname = 'I_REPORTDATA1'.
      wa_sortinfo-spos = 1.            " First sort by this field.
      wa_sortinfo-up = 'X'.            "   Ascending
      wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
      APPEND wa_sortinfo TO i_sortcat.
      CLEAR wa_sortinfo.
      wa_sortinfo-fieldname = 'EBELP'.
      wa_sortinfo-tabname = 'I_REPORTDATA1'.
      wa_sortinfo-spos = 2.            " Sec sort by this field.
      wa_sortinfo-up = 'X'.            "   Ascending
      wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
      APPEND wa_sortinfo TO i_sortcat.
    ENDFORM.                    " sortcat_init

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

  • ALV tree without using abap objects---------urgent

    hi
    can anybody send  me code for making alv tree without using ABAP objects.
    thanks in advance
    Aditya

    HI
    goto this link
    you will get all ALV TREE programs
    follow that code you can understand very easily
    http://www.sapdev.co.uk/reporting/alv/alvtree.htm
    <b>Reward if usefull</b>

  • Problem in displaying Alv grid output  using oops........

    hi,
    i have two problems in displaying ALV grid output Using Oops.
    1) How to modify the fieldcatalog after we getting a field catalog using general FM.
    2) initialy it is displaying 13 fields but there are 63 fields .
       eventhough we chage the layout to 63 fields it is displaying only 13 fields , these 13 fields may be different based on our selection but count  of displayed fileds are same . how can display 63 fields at a time .

    Hi,
    You can chnage using below code:
    loop at gt_fieldcat.
    if <gt_fieldcat-field_name> = 'FIELDNAME'.
    endif.
    modify gt_fieldcat.
    clear gt_fieldcat.
    endloop.
    Make sure that all the field should not have no_out = 'X' and tech = 'X'.
    Thanks,
    Sriram Ponna.

  • Editable Field in ALV TREE Display Using OOPs

    Hi,
    I am trying to make a field editable on the ALV Tree display. I could create an editable check box. But could not make a field Editable. I have made EDIT = 'X' in the fieldcatalog for the particular field. but  it is not working.
    Please help me in solving this. Its very urgent.

    You do this with the following code example
      DATA: ls_layout TYPE lvc_s_layi.
      CLEAR ls_layout.
      ls_layout-class     = cl_item_tree_control=>item_class_text.
      ls_layout-editable   = 'X'.
      ls_layout-fieldname = your fieldname.
      APPEND ls_layout TO lt_layout.
    add PO header to tree
          CALL METHOD tree->add_node
            EXPORTING
              i_relat_node_key = space
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = l_node_text
              is_outtab_line   = ls_po_item
              is_node_layout   = wa_layout_node
              it_item_layout   = lt_layout
    Roy

  • Getting error while adding a custom field (with input help) through AET

    Hi All,
    I need to add two custom field under Service orders at Item level in component BT140I_SRVP.
    One field is required to have the input search help f4 and autopopulates the second field
    I am able to add one field(not requiring help) successfully through AET .
    I have created one Zsearch_help in se11 and its successfully running while I am testing it
    While adding fsecond field through AET,I need to enter following details as -
    field label,search relevant ,serach help etc.
    When I type the name of my 'Zsearch_help' against field search help it gives me following error
    'Search help is not compatible'.
    Please help me out.Kindly be detailed as I am new to SAP CRM.

    Thanks for very helpful reply. After implementing the suggested SAP note, I am able to see the getter and setter methods.
    So one of my problem has got solved with your kind help:)
    As per your another suggestion,I have created the enhanced fields without the search help from AET in the node BTAdminI with names Plant(ZZPLANT) and Storage Location(ZZStoarge_Loc).
    Now I am facing below problem:
    Since Plant needs to autopopulated by Storage Location (search Help ZOFI_SHLP_STORAGE_LOC),So I need to Implement Getter setter method.
    I have written below code into Get_V_ZZStorage_Loc Method:
    method GET_V_ZZSTORAGE_LOC.
      DATA:
        ls_map    TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping,
        lt_inmap  TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping_tab,
        lt_outmap TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping_tab.
        ls_map-context_attr = 'ZZSTORAGE_LOC'.
        ls_map-f4_attr      = 'STORAGE_LOC'. (Storage_loc is the parameter defined in search help)
        APPEND ls_map TO: lt_inmap, lt_outmap.
      CREATE OBJECT rv_valuehelp_descriptor TYPE cl_bsp_wd_valuehelp_f4descr
        EXPORTING
          iv_help_id        = 'ZOFI_SHLP_STORAGE_LOC1'
          iv_help_id_kind   = if_bsp_wd_valuehelp_f4descr=>help_id_kind_callback
          iv_input_mapping  = lt_inmap
          iv_output_mapping = lt_outmap.
    endmethod.
    But its not working.Should I write some code in Get_P_XX or some other method also?
    Kindly suggest .

  • Runtime Error in ALV Tree Output

    Dear All, I am trying to create a ALV Tree using Class cl_gui_alv_tree. The Report Shows the Output with the first Node but when i try to expand it is dumping with a runtime error GETWA_NOT_ASSIGNED in class CL_ALV_TREE_BASE and method SET_ITEMS_FOR_COLUMN. The Reason being the data which was copied in the initial node display to mt_outtab is getting refreshed.
    Can any one of you help me the reason for the table getting refreshed. Do i need to pass any data.
    I am doing the following steps.
    1. Create Container,
    2. Create Tree Class object
    3. Generate the Field Catalog.
    4. Set table for first display  " With empty internal table
    5. Generate the Hierarchy
    6. Call the Method Frontend Update.
    Let me know if i had missed any steps in the process.
    Thank you,
    Regards,
    Swaroop Patri

    One reason for getting this error is using local defined tables for it_outtab parameter in the below code:
    To get rid of the dump, define two distinct output tables globally: one is an empty table which you will pass to the below method, other one is your real output table whose size increases dependently.
      CALL METHOD go_tree->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = ls_hier_header
          CHANGING
            it_outtab           = gt_data_e "Empty table
            it_fieldcatalog     = gt_fcat_tree.

  • F4 help in ALV report output  (FM REUSE_ALV_GRID_DISPLAY)

    Hello,
    I have developed ALV report using the FM REUSE_ALV_GRID_DISPLAY.
    My requirement is to have a customized search help on the output of ALV on one field.
    I tried to find it on SDN but all the methods are using OO ALV.
    How we can attaché customized search help in ALV developed using the FM REUSE_ALV_GRID_DISPLAY.
    Kindly Help
    Regards
    Sachin

    Hii..
    If you use OO then it is very easy to create a F4 help on the ALV..
    try this sample code
    <removed by moderator>
    Hope this will help u..
    Regards,
    Jhings
    Moderator message: please post only relevant code parts, your post must be less than 5000 characters to preserve formatting.
    Edited by: Thomas Zloch on Mar 28, 2011 12:51 PM

Maybe you are looking for

  • Problem with user exit EXIT_SAPLIEDI_001 for Inbound Idocs in replacing G/L

    Hello all, I am currently facing an issue where my IDOC where exit EXIT_SAPLIEDI_001 is not appearing to work properly. Basically I am using the FM that processes the inbound idoc (IDOC_INPUT_INVOIC_FI) to post an accounting document. We needed a sol

  • I Can't Burn A Usable MP3 CD On My Mac /10.7.5 / Lion

    I'm getting a little bummed out with this problem. I have tried many things, but still can't burn a useable CD with MP3 music on my Mac. When I try it, it seems to burn it, but the disc won't play in any of my CD players. Why does Mac make it so hard

  • Help me format

    I have a 250gb westeren digtal hard drive, exact info hhere Western Digital Which is located in an A-power encloure http://www.geeks.com/details.asp?invtid=AP35-C&cat=CAS All that is connected via firewire cord.....however that hard drive crashed, no

  • Age old questions parallels vs. boot camp

    I have heard for a while that bootcamp was better then parallels but now that parallels has revamped its approach does any have any thoughts I will be buying something soon whats your thoughts

  • Slow web page loading

    i have a linkysys modem and wrt150n router. i have one desk top and a laptop that uses the wireless connection. everything was working fine untill a couple of days ago. then webpages started loading slowly on the laptop. the signal strength is excell