Displaying ALV tree in expanded form in first ouput

Hi all,
      I have a problem with alv tree. My requirement is, on the first output itself the alv tree should appear expanded depending on one of the filter criteria in the tool bar. How can i trigger the toolbar event in PBO itself? Can it be done? if yes please provide sample code. Points assured for helpfull answers.
Thanks,
Shafiq

Hi Walter,
   The method CL_GUI_ALV_TREE->EXPAND_NODES has only one importing parameter and that is the nodes of the ALV tree. But the commenting of the following lines from my code made it work which i have made it bold.Thank you very much for your help.I Have awarded points for you.
REPORT  ztest_2105.
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
      gt_fieldcatalog TYPE lvc_t_fcat,
      ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm,           "OK-Code
      g_max TYPE i VALUE 255. "maximum of db records to select
DATA : it_node_key TYPE lvc_t_nkey,
       wa_node_key LIKE LINE OF it_node_key.
LOCAL CLASSES
*§1. Define a (local) class for event handling
CLASS lcl_tree_event_receiver DEFINITION.
  PUBLIC SECTION.
*§2. Define an event handler method for each event you want to react to
    METHODS handle_node_double_click
      FOR EVENT node_double_click OF cl_gui_alv_tree
      IMPORTING node_key sender.
'sender' is an implicit event parameter that is provided by
ABAP Objects runtime system. It contains a reference to the
object that fired the event. You may directly use it to
call methods of this instance.
ENDCLASS.
CLASS lcl_tree_event_receiver IMPLEMENTATION.
*§3. Implement your event handler methods.
  METHOD handle_node_double_click.
    DATA: lt_children TYPE lvc_t_nkey.
*first check if the node is a leaf, i.e. can not be expanded
    CALL METHOD sender->get_children
              EXPORTING i_node_key = node_key
              IMPORTING et_children = lt_children.
    IF NOT lt_children IS INITIAL.
      CALL METHOD sender->expand_node
                EXPORTING  i_node_key = node_key
                           i_level_count = 2.
    ENDIF.
  ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
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 g_alv_tree->expand_nodes
  EXPORTING
    it_node_key             = it_node_key
   EXCEPTIONS
     FAILED                  = 1
     CNTL_SYSTEM_ERROR       = 2
     ERROR_IN_NODE_KEY_TABLE = 3
     DP_ERROR                = 4
     NODE_NOT_FOUND          = 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.
    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.
    WHEN OTHERS.
§5. Call dispatch to process toolbar functions
Toolbar events are registered in constructur method of
CL_ALV_TREE_BASE as application events. So the dispatch call
is a must if you want to use the standard toolbar.
      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.
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.
  DATA l_hierarchy_header TYPE treev_hhdr.
  PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
Hide columns and sum up values initially using the fieldcatalog
  PERFORM build_fieldcatalog.
IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
(even after this method call). You can change data of your table
by calling methods of CL_GUI_ALV_TREE.
Furthermore, the output table 'gt_outtab' must be global and can
only be used for one ALV Tree Control.
  CALL METHOD g_alv_tree->set_table_for_first_display
     EXPORTING
               is_hierarchy_header  = l_hierarchy_header
     CHANGING
               it_fieldcatalog      = gt_fieldcatalog
               it_outtab            = gt_sflight. "table must be empty!
  PERFORM create_hierarchy.
  PERFORM register_events.
Update calculations which were initially defined by field DO_SUM
of the fieldcatalog. (see build_fieldcatalog).
  CALL METHOD g_alv_tree->update_calculations.
Send data to frontend.
  CALL METHOD g_alv_tree->frontend_update.
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 = 'Totals/Month/Carrier/Date'(300).
  p_hierarchy_header-tooltip = 'Flights in a month'(400).
  p_hierarchy_header-width = 35.
  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 build_fieldcatalog.
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.
The following function module generates a fieldcatalog according
to a given structure.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
            i_structure_name = 'SFLIGHT'
       CHANGING
            ct_fieldcat      = gt_fieldcatalog.
Now change the fieldcatalog to hide fields and to determine
some initial calculations for chosen fields.
  LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
    CASE ls_fieldcatalog-fieldname.
hide columns which are already displayed in our tree
      WHEN 'CARRID' OR 'FLDATE'.
        ls_fieldcatalog-no_out = 'X'.
Do some initial calculations:
ALV Tree uses the field 'do_sum' to declare that a function
for the corresponding column shall be calculated.
Use 'h_ftype' to set the function type (MAX, MIN, SUM, AVG).
      WHEN 'PRICE'.
        ls_fieldcatalog-do_sum = 'X'.
        ls_fieldcatalog-h_ftype = 'MAX'.
      WHEN 'SEATSMAX'.
        ls_fieldcatalog-do_sum = 'X'.
        ls_fieldcatalog-h_ftype = 'SUM'.
      WHEN 'SEATSOCC'.
        ls_fieldcatalog-do_sum = 'X'.
        ls_fieldcatalog-h_ftype = 'AVG'.
    ENDCASE.
    MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
  ENDLOOP.
The fieldcatalog is provided in form 'init_tree' using method
set_table_for_first_display.
ENDFORM.                               " build_fieldcatalog
FORM register_events.
*§4. Event registration: tell ALV Tree which events shall be passed
   from frontend to backend.
  DATA: lt_events TYPE cntl_simple_events,
        l_event TYPE cntl_simple_event,
        l_event_receiver TYPE REF TO lcl_tree_event_receiver.
*§4a. Frontend registration(i):  get already registered tree events.
The following four tree events registers ALV Tree in the constructor
method itself.
   - cl_gui_column_tree=>eventid_expand_no_children
(needed to load data to frontend when a user expands a node)
   - cl_gui_column_tree=>eventid_header_context_men_req
(needed for header context menu)
   - cl_gui_column_tree=>eventid_header_click
(allows selection of columns (only when item selection activated))
  - cl_gui_column_tree=>eventid_item_keypress
(needed for F1-Help (only when item selection activated))
Nevertheless you have to provide their IDs again if you register
additional events with SET_REGISTERED_EVENTS (see below).
To do so, call first method  GET_REGISTERED_EVENTS (this way,
all already registered events remain registered, even your own):
  CALL METHOD g_alv_tree->get_registered_events
        IMPORTING events = lt_events.
(If you do not these events will be deregistered!!!).
You do not have to register events of the toolbar again.
*§4b. Frontend registration(ii): add additional event ids
  l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
  APPEND l_event TO lt_events.
*§4c. Frontend registration(iii):provide new event table to alv tree
  CALL METHOD g_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.
*§4d. Register events on backend (ABAP Objects event handling)
  CREATE OBJECT l_event_receiver.
  SET HANDLER l_event_receiver->handle_node_double_click FOR g_alv_tree
ENDFORM.                               " register_events
*&      Form  create_hierarchy
      text
-->  p1        text
<--  p2        text
FORM create_hierarchy.
See BCALV_TREE_01 for more comments on building the 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,
        l_top_key TYPE lvc_nkey.
Select data
  SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.
sort table according to conceived hierarchy
  SORT lt_sflight BY fldate0(6) carrid fldate6(2).
  CLEAR : it_node_key, wa_node_key.
*  wa_node_key = '&VIRTUALROOT'.
APPEND wa_node_key TO it_node_key.</b>
Define one top node. In this way it is possible to calculate
values for the whole hierarchy.
  CALL METHOD g_alv_tree->add_node
    EXPORTING
          i_relat_node_key = ''
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = text-050
       IMPORTING
          e_new_node_key = l_top_key.
  wa_node_key = l_top_key.
  APPEND wa_node_key TO it_node_key.
  LOOP AT lt_sflight INTO ls_sflight.
    l_yyyymm = ls_sflight-fldate+0(6).
    l_carrid = ls_sflight-carrid.
    IF l_yyyymm <> l_yyyymm_last.      "on change of l_yyyymm
      l_yyyymm_last = l_yyyymm.
month nodes
      PERFORM add_month USING    l_yyyymm
                                      l_top_key
                             CHANGING l_month_key.
clear l_carrid_last because this is a new month
      CLEAR l_carrid_last.
      wa_node_key = l_month_key.
      APPEND wa_node_key TO it_node_key.
    ENDIF.
Carrier nodes:
    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.
      wa_node_key = l_carrid_key.
      APPEND wa_node_key TO it_node_key.
    ENDIF.
Leaf:
    PERFORM add_complete_line USING  ls_sflight
                                     l_carrid_key
                            CHANGING l_last_key.
*    wa_node_key = l_last_key.
   APPEND wa_node_key TO it_node_key.</b>
  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
  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
  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.
  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.
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.
  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

Similar Messages

  • To display ALV tree in one of the fields in Grid display..

    hi,
    I displayed 4 fields in Grid as we usually do.. but I have to display another field with ALV  tree in it.. Actually first what is the method to add a tree in Grid.. I searched in  class CL_GUI_ALV_GRID.. but i couldn't find appropriate method in it.. so plz help me out..
    thanks in advance..
    Edited by: RameshKumar on Jul 2, 2009 8:44 AM

    Hi Xier,
    Try this I will give you steps
    1) goto Message mapping >Choose the Date Function->select Current Date double click on the current date > choose it--> Remove the date in the date format (Make it emty) ---> choose second text box is time choose it which format do u want u can choose it. This one will display only time. because u choose the date is emty it won't display date. so u r problem will be solve
    If you need any info let me know.
    Regards
    Ramidi S

  • Best way to Display a tree in Adobe Forms i.e. Classification

    As I am new to Adobe interactive and do not have the experience that many of you have, I am posting a general question in that what is the best way to display a tree like structure of data in Adobe Forms so that a user can select a 'leaf' node easily. 
    I have looked at and coded drop downs that drive the data in the next drop down and it seems to work but it is not pretty and is a lot of work to handle the requirements for different levels of data.  we have suggested that they select the Classification in a Webdynpro pop-up before they go into the form meaning that the classification will only work when  they are on line.  I looked briefly at using imbeded tables but they would be too big(should I look at them further?)....   There could be upwards to 3000 rows in the classification table.
    Example of data
    Level 1
    === level 11
    === level 12
    Level 2
    === Level 21
    Level 3
    === Level 31
    ====== Level 311
    ====== Level 312
    Thanks in advance for any ideas and learnings you may have.
    Glenn

    After talking to a number of people, I have determined the best way is to use dynamic dropdown lists to show the hierarchy.
    Glenn

  • ALV Tree using ABAP Objects

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

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

  • OO - ALV Tree

    Hello ABAP Experts.
    I am trying to learn OO ABAP although have been using procedural ABAP for many years and I am writing an ALV Tree (which is also a first).
    My problem is:
    I have written a standard report which has a screen (which contains my ALV Tree) and a subscreen which has a single field which should get populated on double clicking on the node of the tree.
    I have written a single class which contains all the logic to build up my ALV Tree and have instantiated this in the PBO of my first screen, in the class I have also set up an event that captures the double clicking of a node, all this seems to work fine.
    The ALV Tree is displayed properly first time round and I can double click the node but I'm expecting (probably wrongly) that control is then passed from the class back to my report where I can manipulate the return, in debug after the double click indeed it does return to my calling program (flow logic of the first screen) however on clicking F5 on the debug, the screen is just redisplayed again and my field is still unpopulated but I need it to go into the PBO of my subscreen to display the data but I just can't seem to make this happen, I have also called the subscreen from within my main screen.
    I have looked around SDN and although people have had similar problems I can't find a reply that works.
    Thanks in advance.

    data:
        ls_events type cntl_simple_event,
        lt_events type cntl_simple_events.
    DOUBLE_CLICK
      clear ls_events.
      ls_events-eventid = event_double_click.
      ls_events-appl_event = 'X'.
      insert ls_events into table lt_events.
      call method ir_lb->set_registered_events
        exporting
          events = lt_events.
    If you use pass APPL_EVENT = 'X' then it becomes an application event so PBO and PAI would be called.

  • How to identify column name in ALV tree when user clicks a particular field

    Hi All,
    In My requirement i am displaying ALV Tree.
    In Which When the user clicks on a particular header column it should navigate to other transaction.
    Now the issue is it is navigating to other transaction when we click on any column of the header row.
    But, the user requires only for particular column .
    Is there any method  to catch the field name in CLASS 'CL_GUI_ALV_TREE'.
    Regards,
    Bhanu.R

    Check out for CUCOL system field.
    Regards,
    Lalit Mohan Gupta.

  • Double click in ALV tree display....

    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.
    My code as of now is as below:
    Please tell how to handle events in this report tree display and how and where to write the code for this functionlity of double click.
    FORM alv_tree.
    PERFORM build_sort_table.  “----
    table is sorted
    create container for alv-tree
      DATA: l_tree_container_name(30) TYPE c,
            l_custom_container TYPE REF TO cl_gui_custom_container.
      l_tree_container_name = 'TREE1'.
      CREATE OBJECT l_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.
    create tree control
      CREATE OBJECT tree1
        EXPORTING
            i_parent              = l_custom_container
            i_node_selection_mode =
                                  cl_gui_column_tree=>node_sel_mode_multiple
            i_item_selection      = 'X'
            i_no_html_header      = ''
            i_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.
    create info-table for html-header
      DATA: lt_list_commentary TYPE slis_t_listheader.
      PERFORM build_comment USING
                     lt_list_commentary. “----
    already created
    repid for saving variants
      DATA: ls_variant TYPE disvariant.
      ls_variant-report = sy-repid.
    register events
      PERFORM register_events.
    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.
    ENDFORM.                    " alv_tree
    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_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_context_men_req.
      append l_event to lt_events.
      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_header_click.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      append l_event to lt_events.
      call method tree1->set_registered_events
        exporting
          events = lt_events
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
    ENDFORM.                    " register_events

    hi
    (also check u have refresh the field)
    Check the demo program,In this double click the data fields it will display some field in screen,You can check it
    BCALV_GRID_DND_TREE
    Thanks
    Edited by: dharma raj on Jun 17, 2009 7:41 PM

  • Unable to expand child links in ALV Tree

    Hi,
    I have written the following code for ALV Tree using function modules.
    REPORT  ZSID_ALV_TREE.
    type pool declarations for tree
    TYPE-POOLS : fibs,stree.
    tables: ekko.
    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:w_repid type sy-cprog.
    *Data declaration for additional node information
    DATA : t_node TYPE snodetext.
    *Internal table and wa decl for nodes
    DATA : it_node LIKE TABLE OF t_node INITIAL SIZE 0,
           wa_node LIKE t_node.
    *Start of selection event
    START-OF-SELECTION.
    *Select the data for tree
    PERFORM fetch_data.
    *Build the hierarchy for tree
    PERFORM build_hierarchy.
    *Build Tree for display
    PERFORM build_tree.
    *& Form fetch_data
    text
    --> p1 text
    <-- p2 text
    FORM fetch_data .
      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.
    *& Form build_hierarchy
    text
    --> p1 text
    <-- p2 text
    FORM build_hierarchy .
    *Building the nodes and hierarchy for tree
    CLEAR : it_node[], wa_node.
    wa_node-type = 'T'.
    wa_node-name = 'Product Hierarchy Level'.
    wa_node-tlevel = '01'.
    wa_node-nlength = '35'.
    wa_node-color = '4'.
    wa_node-text = 'Test'.
    wa_node-tlength ='20'.
    wa_node-tcolor = 3.
    APPEND wa_node TO it_node.
    CLEAR wa_node.
    loop at it_ekpo into wa_ekpo.
    wa_node-type = 'P'.
    wa_node-name = 'Purchasing Doc'.
    wa_node-tlevel = '02'.
    wa_node-nlength = '25'.
    wa_node-color = '4'.
    wa_node-text = wa_ekpo-ebeln.
    wa_node-tlength ='20'.
    wa_node-tcolor = 3.
    APPEND wa_node TO it_node.
    CLEAR wa_node.
    *Filling the values of internal table into tree
    wa_node-type = 'P'.
    wa_node-name = 'Material No'.
    wa_node-tlevel = '03'.
    wa_node-nlength = '20'.
    wa_node-color = '1'.
    wa_node-text = wa_ekpo-matnr.
    wa_node-tlength ='20'.
    wa_node-tcolor = 4.
    APPEND wa_node TO it_node.
    CLEAR wa_node.
    ENDLOOP.
    ENDFORM. " build_hierarchy
    *& Form build_tree
    text
    --> p1 text
    <-- p2 text
    FORM build_tree .
    *Fm for constructing the tree
    CALL FUNCTION 'RS_TREE_CONSTRUCT'
    TABLES
    nodetab = it_node.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    w_repid = SY-CPROG.
    *FM for displaying the tree
                    CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
                     EXPORTING
                       CALLBACK_PROGRAM                = w_repid
                      CALLBACK_USER_COMMAND           = 'USER1_COMMAND'
                      CALLBACK_TEXT_DISPLAY           =
                      CALLBACK_MOREINFO_DISPLAY       =
                      CALLBACK_COLOR_DISPLAY          =
                      CALLBACK_TOP_OF_PAGE            =
                      CALLBACK_GUI_STATUS             =
                      CALLBACK_CONTEXT_MENU           =
                      STATUS                          = 'IMPLICIT'
                       CHECK_DUPLICATE_NAME            = '0'
                       COLOR_OF_NODE                   = '4'
                       COLOR_OF_MARK                   = '3'
                       COLOR_OF_LINK                   = '1'
                       COLOR_OF_MATCH                  = '5'
                       LOWER_CASE_SENSITIVE            = 'X'
                       MODIFICATION_LOG                = 'X'
                       NODE_LENGTH                     = 40
                       TEXT_LENGTH                     = 75
                       TEXT_LENGTH1                    = 0
                       TEXT_LENGTH2                    = 0
                       RETURN_MARKED_SUBTREE           = 'X'
                       SCREEN_START_COLUMN             = 0
                       SCREEN_START_LINE               = 0
                       SCREEN_END_COLUMN               = 0
                       SCREEN_END_LINE                 = 0
                       SUPPRESS_NODE_OUTPUT            = 'X'
                      LAYOUT_MODE                     = ' '
                       USE_CONTROL                     = 'L'.
                    IMPORTING
                      F15                             =
    ENDFORM. " build_tree
    FORM USER1_COMMAND TABLES node        STRUCTURE seucomm
                                 USING command
                             CHANGING value(exit)
                                     VALUE(LIST_REFRESH).
    write 'Hi'.
    endform.
    But I have a problem
    1.  I can expand the child links in tree structure when I comment the exporting parameter CALLBACK_USER_COMMAND in the function Module  'RS_TREE_LIST_DISPLAY'.
    2 But when i uncomment the exporting parameter I am unable to expand the child links in output.
    Please let me know if i have missed something in the code.
    Useful answers will be rewarded
    Regards,
    Siddharth

    Hi Sidhhart,
    Check out this prog.
    REPORT Z_KULDEEP_ALV_HIERARCHY
    message-id zord
    line-size 270.
    Tables:
      Vbap,
      Vbak.
    *& PROGRAM VARIABLES
    type-pools slis.
    *& INTERNAL TABLES & STRUCTURES
    data:
      begin of t_header occurs 0,
        EXPCOL type c,
        vbeln type vbak-vbeln,
        audat type vbak-audat,
        vkorg type vbak-vkorg,
        vtweg type vbak-vtweg,
        spart type vbak-spart,
      end of t_header,
      begin of t_item occurs 0,
        vbeln type vbap-vbeln,
        posnr type vbap-posnr,
        matnr type vbap-matnr,
        arktx type vbap-arktx,
        pstyv type vbap-pstyv,
      end of t_item,
      t_fieldcat type standard table of slis_fieldcat_alv with header line,
      t_event    type standard table of slis_alv_event with header line,
      x_keyinfo  type slis_keyinfo_alv,
      x_layout   type slis_layout_alv,
      x_variant  like disvariant.
    *& GLOBAL VARIABLES
      data:
        g_repid    type sy-repid,
        g_formname type slis_formname value 'TOP_OF_PAGE'.
    *& SELECTION SCREEN                                                    *
    selection-screen begin of block a with frame title text-000.
      Select-options : s_date for vbak-audat obligatory.
       p_date type vbak-audat.
    selection-screen end of block a.
    *& INITIALIZATION                                                      *
    initialization.
      clear : g_repid,t_header,t_item.
      refresh : t_header,t_item.
      g_repid = sy-repid.
    *& AT SELECTION-SCREEN                                                 *
    at selection-screen.
      if s_date-high > sy-datum.
        message e001.
      endif.
    start-of-selection.
      select vbeln audat vkorg vtweg spart from vbak
      into corresponding fields of table t_header
      where audat in s_date.
      select vbeln posnr matnr arktx pstyv from vbap
      into table t_item
      for all entries in t_header
      where vbeln = t_header-vbeln.
    end-of-selection.
      perform sub_display_alv.
    *&      Form  sub_display_alv
          text
    -->  p1        text
    <--  p2        text
    form sub_display_alv.
    *column 1
      perform sub_populate_fieldcatalog using:
          'VBELN'                             " field name
          'T_HEADER'                          " table name
          'ORDER'                             " column heading
          '8'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 2
        perform sub_populate_fieldcatalog  using:
          'AUDAT'                             " field name
          'T_HEADER'                          " table name
          'ORDERDATE'                         " column heading
          '10'                                " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 3
      perform sub_populate_fieldcatalog using:
          'VKORG'                             " field name
          'T_HEADER'                          " table name
          'SALES ORG'                         " column heading
          '6'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 4
      perform sub_populate_fieldcatalog  using:
          'VTWEG'                             " field name
          'T_HEADER'                          " table name
          'DIVISION'                          " column heading
          '2'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 5
      perform sub_populate_fieldcatalog  using:
          'SPART'                             " field name
          'T_HEADER'                          " table name
          'CHANNEL'                             " column heading
          '4'                                " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 6
    perform sub_populate_fieldcatalog using:
         'vbeln'                             " field name
         'T_item'                            " table name
         'Order'                             " column heading
         '8'                                 " column width
         ' '                                 " fix column?
         ' '                                 " key
         ' '                                 " no display
         ' '                                 " sum this column
         'X'                                 " do not sum
         ' '                                 " input allowed?
         ' '                                 " currenct type field name
         ' '                                 " data type
         'X'.                                 " hotspot.
    *column 7
      perform sub_populate_fieldcatalog using:
          'POSNR'                             " field name
          'T_ITEM'                            " table name
          'SALES DOC.ITEM'                    " column heading
          '8'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 8
      perform sub_populate_fieldcatalog using:
          'MATNR'                             " field name
          'T_ITEM'                            " table name
          'MATERIAL'                          " column heading
          '8'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 9
      perform sub_populate_fieldcatalog using:
          'ARKTX'                             " field name
          'T_ITEM'                            " table name
          'SALES ORDER ITEM'                  " column heading
          '8'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                 " hotspot.
    *column 10
      perform sub_populate_fieldcatalog using:
          'PSTYV'                             " field name
          'T_ITEM'                            " table name
          'ITEM CATEGORY'                     " column heading
          '8'                                 " column width
          ' '                                 " fix column?
          ' '                                 " key
          ' '                                 " no display
          ' '                                 " sum this column
          'X'                                 " do not sum
          ' '                                 " input allowed?
          ' '                                 " currenct type field name
          ' '                                 " data type
          'X'.                                " hotspot.
      perform sub_assign_events.
    Create a Layout for the ALV
      perform sub_layout.
    Define the key fields that links the header & item tables
      perform sub_define_key.
    dispaly list
      perform sub_call_list_display.
    endform.                    " sub_display_alv
    *&      Form  sub_populate_fieldcatalog
          text
         -->P_G_FIELDCAT  text
         -->P_0198   text
         -->P_0199   text
         -->P_0200   text
         -->P_0201   text
         -->P_0202   text
         -->P_0203   text
         -->P_0204   text
         -->P_0205   text
         -->P_0206   text
         -->P_0207   text
         -->P_0208   text
         -->P_0209   text
         -->P_0210   text
         -->P_0211   text
         -->P_0212   text
         -->P_0213   text
    form sub_populate_fieldcatalog  using
                                     l_fieldname
                                     l_tabname
                                     l_column_heading
                                     l_outputlen
                                     l_fix_column
                                     l_key
                                     l_no_out
                                     l_do_sum
                                     l_no_sum
                                     l_input
                                     l_cfieldname
                                     l_datatype
                                     l_hotspot.
      t_fieldcat-fieldname      = l_fieldname.
      t_fieldcat-tabname        = l_tabname.
      t_fieldcat-reptext_ddic   = l_column_heading.
      t_fieldcat-outputlen      = l_outputlen.
      t_fieldcat-fix_column     = l_fix_column.
      t_fieldcat-key            = l_key.
      t_fieldcat-no_out         = l_no_out.
      t_fieldcat-do_sum         = l_do_sum.
      t_fieldcat-no_sum         = l_no_sum.
      t_fieldcat-cfieldname     = l_cfieldname.
      t_fieldcat-datatype       = l_datatype.
      t_fieldcat-hotspot        = l_hotspot.
      append t_fieldcat.clear t_fieldcat.
    endform.                    " sub_populate_fieldcatalog
    *&      Form  sub_assign_events
          text
    -->  p1        text
    <--  p2        text
    form sub_assign_events.
      refresh t_event.
      call function 'REUSE_ALV_EVENTS_GET'
       exporting
         i_list_type           = 1
       importing
         et_events             = t_event[]
       exceptions
         list_type_wrong       = 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.
    Read the record for the top-of-page event
      read table t_event with key slis_ev_top_of_page.
      if sy-subrc = 0.
        t_event-form = g_formname.
        append t_event.
      endif.
    endform.                    " sub_assign_events
    *&      Form  SUB_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    form sub_layout.
       clear x_layout.
    x_layout-f2code = 'QUOTE'.
      x_layout-zebra  = 'X'.
      x_layout-expand_fieldname = 'EXPCOL'. " Field for expand/collapse
    *Stat
      x_layout-colwidth_optimize = 'X'.
      x_layout-no_totalline = 'X'.   " 0001+
    endform.                    " SUB_LAYOUT
    *&      Form  SUB_DEFINE_KEY
          text
    -->  p1        text
    <--  p2        text
    form sub_define_key.
       clear x_keyinfo.
      x_keyinfo-header01 = 'VBELN'.
      x_keyinfo-item01   = 'VBELN'.
    endform.                    " SUB_DEFINE_KEY
    form top_of_page.
      write :/10 sy-datum, 20 sy-pagno, 30 sy-uname.
    endform.
    form sub_user_command using f_ucomm like sy-ucomm
                                f_selfield type slis_selfield.
      if f_ucomm = 'QUOTE'.
        if f_selfield-fieldname = 'VBELN'.
          Set Parameter id 'AUN' field f_selfield-value.
          call transaction 'VA03'.
        endif.
      endif.
    endform.
    *&      Form  sub_call_list_display
          text
    -->  p1        text
    <--  p2        text
    form sub_call_list_display.
      call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      exporting
        i_callback_program             = g_repid
        i_callback_user_command        =  'SUB_USER_COMMAND '
        is_layout                      = x_layout
        it_fieldcat                    = t_fieldcat[]
        i_save                         = 'A'
        it_events                      = t_event[]
        i_tabname_header               = 'T_HEADER'
        i_tabname_item                 = 'T_ITEM'
        is_keyinfo                     = x_keyinfo
      tables
        t_outtab_header                = t_header[]
        t_outtab_item                  = t_item[]
    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.
    endform.                    " sub_call_list_display

  • Regarding ALV ( To be displayed in Tree Format)

    Hi all,
    I am working on a ALV report which is to be displayed in Tree Structure . I found some demo programs within SAP .. but do we have an Alternative .. all those Demos use  OOPS concept .. Can this Report be done without using OOPS in ALV.
    Please Suggest.
    Thanks & Regards
    Srinivas

    Hi,
    This is a ALV Report with tree structure.
    report  zwmr_pick_status_report no standard page heading
                                    message-id zw.
    Type Pools                                                           *
    type-pools: icon, slis.
    Tables                                                               *
    tables: tvst,
            likp,
            t30b,
            vekp,
            zpallettr,
            zvantr.
    Types                                                                *
    types:
      begin of ty_data,
         lgtor       like likp-lgtor,             " door
         vbeln       like likp-vbeln,             " delivery
         wbstk       like vbuk-wbstk,             " Goods movement status
         kostk       like vbuk-kostk,             " Picking status
         posnr       like lips-posnr,             " item
         route       like likp-route,             " route
         wadat       like likp-wadat,             " goods issue date
         lvsta       like vbup-lvsta,             " warehouse status
         packvorschr like vekp-packvorschr,       " pack mnemonic
         exidv       like vekp-exidv,             " handling unit
         zpallet_no(10),  "like zpallettr-zpallet_no,   " pallet no
         zcount_check like zpallettr-zcount_check," count check flag
         zvan_no(10),     "like zvantr-zvan_no,         " van no
         zvan_print  like zvantr-zvan_print,      " van manifest print
         zeod_print  like zvantr-zeod_print,      " eod manifest print
         zzpackclass like vekp-zzpackclass,       " package class
         zzti        like vekp-zzti,              " T.I. value
      end of ty_data.
    Data                                                                 *
    ranges: r_del   for likp-vbeln,
            r_lgtor for likp-lgtor.
    ranges: r_vanno for zvantr-zvan_no,
            r_palno for zpallettr-zpallet_no.
    data: begin of number_range occurs 0,
             mark(1),
             id(3),
             num(10) type n,
             desc like zpalletmd-zdesc,
          end of number_range.
    data: t_disp_tab  type standard table of zpickdisp,
          t_data_tab  type ty_data  occurs 0 with header line,
          t_disp_head type standard table of zpickhead.
    data: w_numrnge like number_range,
          w_number(10) type n.
    data: t_likp     like likp      occurs 0 with header line,
          t_lips     like lips      occurs 0 with header line,
          t_vbuk     like vbuk      occurs 0 with header line,
          t_vbup     like vbup      occurs 0 with header line,
          t_vepo     like vepo      occurs 0 with header line,
          t_vekp     like vekp      occurs 0 with header line,
          t_vantr    like zvantr    occurs 0 with header line,
          t_pallettr like zpallettr occurs 0 with header line,
          w_likp     like likp,
          w_lips     like lips,
          w_vbuk     like vbuk,
          w_vbup     like vbup,
          w_vepo     like vepo,
          w_vekp     like vekp.
    ALV DATA *****
    data:
         g_grid             type ref to cl_gui_alv_grid,
         g_sort             type slis_t_sortinfo_alv,
         g_custom_container type ref to cl_gui_custom_container,
         g_layout           type slis_layout_alv,
         gt_fieldcat        type slis_t_fieldcat_alv,
         t_fldcat           like line of gt_fieldcat,
         g_keyinfo          type slis_keyinfo_alv,
         gt_events          type slis_t_event,
         gs_event           type slis_alv_event,
         w_sy_repid         like sy-repid.
    data: begin of seltab occurs 0.
            include structure rsparams.
    data: end of seltab.
    SYSTEM GENERATED TABLE CONTROL DATA ********
    DECLARATION OF TABLECONTROL 'TC_TABCON' ITSELF
    controls: tc_tabcon type tableview using screen 0100.
    LINES OF TABLECONTROL 'TC_TABCON'
    data:     g_tc_tabcon_lines  like sy-loopc.
    data:     ok_code like sy-ucomm.
    Constants                                                            *
    constants: c_data_class like klah-class value 'DG_DATA',
               c_mat_class  like rmclf-klart value '001',
               c_pack       like lips-mtart value 'VERP',
               c_a(1)            value 'A',
               c_b(1)            value 'B',
               c_c(1)            value 'C',
               c_yes(1)          value 'X',
               c_no(1)           value ' '.
    Selection screen                                                     *
    standard report select options block
    selection-screen begin of block a with frame title text-002.
    select-options:
      s_wadat for likp-wadat no-extension obligatory.  " Goods Issue Date
    *parameters:                                           "TR01-
    p_vstel like tvst-vstel obligatory. " Shipping Point "TR01-
    select-options:                                             "TR01+
      p_vstel for tvst-vstel.            " Shipping Point  "TR01+
    select-options:
      s_lfart for likp-lfart,            " Delivery type
      s_lgtor for t30b-lgtor,            " Door selection
      s_exidv for vekp-exidv,            " Handling Unit
      s_vbeln for likp-vbeln.            " Delivery
    parameters:
      p_exdata as checkbox.              " Show extra columns flag
    selection-screen end of block a.
    van/pallet specific select options block
    selection-screen begin of block b with frame title text-001.
    select-options:
      s_palno for zpallettr-zpallet_no, " no-extension,
      s_vanno for zvantr-zvan_no.       " no-extension.
    selection-screen end of block b.
    Value Request Events                                                 *
    at selection-screen on value-request for s_palno-low.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_pal_nos.
      s_palno-low = w_number.
    at selection-screen on value-request for s_palno-high.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_pal_nos.
      s_palno-high = w_number.
    at selection-screen on value-request for s_vanno-low.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_van_nos.
      s_vanno-low = w_number.
    at selection-screen on value-request for s_vanno-high.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_van_nos.
      s_vanno-high = w_number.
    At Selection Screen                                                  *
    at selection-screen.
      perform validate_selections.
    Initialization                                                       *
    initialization.
    Start of selection                                                   *
    start-of-selection.
    clear all data tables
      clear: t_likp,
             t_lips,
             t_vbuk,
             t_vbup,
             t_vepo,
             t_vantr,
             t_pallettr,
             w_likp,
             w_lips,
             w_vbuk,
             w_vbup,
             w_vepo,
             w_vekp.
      refresh: t_likp,
               t_lips,
               t_vbuk,
               t_vbup,
               t_vepo,
               t_vantr,
               t_pallettr.
    select data for ALV
    due to different input parameters being used, to streamline the data
    selection process, different selection methods are required
      if not s_vanno is initial
      or not s_palno is initial.
      if selecting by van/pallet number, need to select the data from the
      handling unit upwards to delivery
        perform select_data_up.
      else.
      otherwise the data can be selected from the delivery downwards
        perform select_data_down.
      endif.
    End of selection                                                     *
    end-of-selection.
    call hierarchical ALV display function module
      call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
           exporting
                i_callback_program       = 'ZWMR_PICK_STATUS_REPORT'
                i_callback_pf_status_set = 'SET_STATUS'
                i_callback_user_command =
                   'USER_COMMAND' "custom gui status form
                is_layout                = g_layout  "user command form
                it_fieldcat              = gt_fieldcat
                it_sort                  = g_sort
                it_events                = gt_events
                i_tabname_header         = 't_disp_head'
                i_tabname_item           = 't_disp_tab'
                i_structure_name_header  = 'ZPICKHEAD'
                i_structure_name_item    = 'ZPICKDISP'
                is_keyinfo               = g_keyinfo
           tables
                t_outtab_header          = t_disp_head
                t_outtab_item            = t_disp_tab.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
                                FORMS                                    *
    Includes inserted by Screen Painter Wizard. DO NOT CHANGE THIS LINE!
      include zwmr_pick_status_reporto01 .
      include zwmr_pick_status_reporti01 .
      include zwmr_pick_status_reportf01 .
    *&      Form  select_pal_nos
          select pallet numbers for search help
    form select_pal_nos.
      data: begin of t_palno occurs 0,
              zpallet_no like zpallettr-zpallet_no,
            end of t_palno.
    select all available pallet numbers
      select distinct zpallet_no from zpallettr
                      into corresponding fields of table t_palno.
      loop at t_palno.
      get pallet id
        select single zpallet_id from zpallettr
                      into number_range-id
                      where zpallet_no = t_palno-zpallet_no.
      get pallet description
        select single zdesc from zpalletmd
                      into number_range-desc
                      where zpallet_id = number_range-id.
        number_range-num = t_palno-zpallet_no.
      append to search help table
        append number_range.
      endloop.
    call pop up dialog box
      call screen 0100 starting at 5 5.
    endform.                    " select_pal_nos
    *&      Form  select_van_nos
          select van numbers for search help
    form select_van_nos.
      data: begin of t_vanno occurs 0,
              zvan_no like zvantr-zvan_no,
            end of t_vanno.
    select available van numbers
      select distinct zvan_no from zvantr
                      into corresponding fields of table t_vanno.
      loop at t_vanno.
      select van id
        select single zvan_id from zvantr
                      into number_range-id
                      where zvan_no = t_vanno-zvan_no.
      select van description (maintained in pallet tables)
        select single zdesc from zpalletmd
                      into number_range-desc
                      where zpallet_id = number_range-id.
        number_range-num = t_vanno-zvan_no.
      append to search help table
        append number_range.
      endloop.
    call pop up dialog box
      call screen 0100 starting at 5 5.
    endform.                    " select_van_nos
    *&      Form  select_data_down
          select data if selecting from delivery down
    form select_data_down.
    select all deliveries from LIKP that fulfill selection criteria
      select * from likp into table t_likp
                         where vbeln in s_vbeln
                       and   vstel eq p_vstel                 "TR01-
                         and   vstel in p_vstel
                         and   lgtor in s_lgtor
                         and   wadat in s_wadat
                         and   lfart in s_lfart.
      if sy-subrc ne 0.
      no data found
        message i007.
        exit.
      endif.
      if not t_likp[] is initial.
      select sales document headers from VBUK
        select * from vbuk into table t_vbuk
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln.
      select all relevant delivery items from LIPS
        select * from lips into table t_lips
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln
                      and   pstyv ne 'ZPAC'
                      and   pstyv ne 'ZGDP'                     "TR02+
                      and   lfimg gt 0.                         "TR01+
      endif.
      if not t_lips[] is initial.
      select all sales document line items from VBUP
        select * from vbup into table t_vbup
                      for all entries in t_lips
                      where vbeln eq t_lips-vbeln
                      and   posnr = t_lips-posnr.
      select corresponding handling unit ID's (venum)
    TR03 Replace start
       select * from vepo appending corresponding fields of table t_vepo
                     for all entries in t_lips
                     where vbeln = t_lips-vbeln
                     and   posnr = t_lips-posnr
                     and   matnr = t_lips-matnr
                     and   charg = t_lips-charg.
        select * from vepo
                      inner join vekp on vepovenum = vekpvenum
                      appending corresponding fields of table t_vepo
                      for all entries in t_lips
                      where vepo~vbeln = t_lips-vbeln
                      and   vepo~posnr = t_lips-posnr
                      and   vepo~matnr = t_lips-matnr
                      and   vepo~charg = t_lips-charg
                      and   vekp~exidv in s_exidv.
    TR03 Replace end
      endif.
    build process table
      perform move_to_table.
    endform.   "select_data_down
    *&      Form  select_data_up
          select data if selecting from van/pallet up
    form select_data_up.
      if not s_vanno is initial.
      if van then select van numbers and hence pallet numbers
        select * from zvantr into table t_vantr
                              where zvan_no in s_vanno.
                            and   vstel   eq p_vstel."TR01-
        if not t_vantr[] is initial.
          select * from zpallettr into table t_pallettr
                                  for all entries in t_vantr
                                  where zpallet_no eq t_vantr-zpallet_no.
                                and   vstel      eq p_vstel."TR01-
        endif.
      else.
      otherwise can get pallet numbers directly
        select * from zpallettr into table t_pallettr
                                where zpallet_no in s_palno.
                              and   vstel      eq p_vstel."TR01-
      endif.
      if not t_pallettr[] is initial.
      from the pallet nos. we can select the handling units
        select * from vekp into table t_vekp
                           for all entries in t_pallettr
                           where exidv eq t_pallettr-exidv
                           and   exidv ne space
                           and   exidv in s_exidv               "TR03+
                           and ( exida = 'E'                    "TR01+
                           or    exida = 'F' ).                 "TR01+
      endif.
      if not t_vekp[] is initial.
      build vbeln range from t_vekp.
        loop at t_vekp.
          r_del-sign = 'I'.
          r_del-option = 'EQ'.
          r_del-low = t_vekp-vpobjkey.
          append r_del.
        endloop.
      select all deliveries from LIKP that correspond to HU's
        select * from likp into table t_likp
                           where vbeln in r_del
                           and   wadat in s_wadat
                           and   lfart in s_lfart.
      endif.
      if not t_likp[] is initial.
      select sales document headers from VBUK
        select * from vbuk into table t_vbuk
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln.
      select all relevant delivery items from LIPS
        select * from lips into table t_lips
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln
                      and   pstyv ne 'ZPAC'
                      and   pstyv ne 'ZGDP'                     "TR02+
                      and   lfimg gt 0.                         "TR01+
      endif.
      if not t_lips[] is initial.
      select all sales document line items from VBUP
        select * from vbup into table t_vbup
                      for all entries in t_lips
                      where vbeln eq t_lips-vbeln
                      and   posnr = t_lips-posnr.
      select corresponding handling unit ID's (venum)
        select * from vepo appending corresponding fields of table t_vepo
                      for all entries in t_lips
                      where vbeln = t_lips-vbeln
                      and   posnr = t_lips-posnr
                      and   matnr = t_lips-matnr
                      and   charg = t_lips-charg.
      endif.
    build process table
      perform move_to_table.
    endform.   "select_data_up
    *&      Form  move_to_table
          move data to processing table
    form move_to_table.
      loop at t_vepo.
        clear t_data_tab.
      delivery lines.
        clear w_lips.
        read table t_lips with key vbeln = t_vepo-vbeln
                                   posnr = t_vepo-posnr
                                   into w_lips.
        move-corresponding w_lips to t_data_tab.
      sales document line items
        clear w_vbup.
        read table t_vbup with key vbeln = t_vepo-vbeln
                                   posnr = t_vepo-posnr
                                   into w_vbup.
      if w_vbup-kosta = space.                   "TR01-
        not relevant for picking
        delete t_vepo.                           "TR01-
        continue.                                "TR01-
      else.                                      "TR01-
        move-corresponding w_vbup to t_data_tab.
      endif.                                     "TR01-
      sales doc header
        clear w_vbuk.
        read table t_vbuk with key vbeln = t_vepo-vbeln
                               into w_vbuk.
        move-corresponding w_vbuk to t_data_tab.
      delivery header
        clear w_likp.
        read table t_likp with key vbeln = t_vepo-vbeln
                               into w_likp.
        move-corresponding w_likp to t_data_tab.
      select handling unit info using vepo entry
        clear w_vekp.
        if t_vekp[] is initial.
          select single * from vekp into w_vekp
                                    where venum = t_vepo-venum.
        else.
          read table t_vekp with key venum = t_vepo-venum
                                     into w_vekp.
          if sy-subrc ne 0.
            select single * from vekp into w_vekp
                            where venum = t_vepo-venum.
          endif.
        endif.
        move-corresponding w_vekp to t_data_tab.
      select pallet / van load information
        select single zpallet_no zcount_check from zpallettr
                                 into (t_data_tab-zpallet_no,
                                       t_data_tab-zcount_check)
                                 where exidv eq w_vekp-exidv.
        if not t_data_tab-zpallet_no in s_palno.                "TR01+
          continue.                                             "TR01+
        endif.                                                  "TR01+
        if sy-subrc = 0.
          select single zvan_no zvan_print zeod_print from zvantr
                        into (t_data_tab-zvan_no,
                              t_data_tab-zvan_print,
                              t_data_tab-zeod_print)
                        where zpallet_no eq t_data_tab-zpallet_no.
          if not t_data_tab-zvan_no in s_vanno.                 "TR01+
            continue.                                           "TR01+
          endif.                                                "TR01+
        endif.
        append t_data_tab.
      endloop.
    *-----> TR01+ start
    If the delivery has yet to be packed, then need to include in report
    Thus delete t_lips here and if any entries left after looping through
    t_vepo, these will also need to be added to t_data_tab
    if the selection is by handling unit though we do not want these"TR03+
      if s_exidv is initial.                                          "TR03+
        loop at t_vepo.
          read table t_lips with key vbeln = t_vepo-vbeln
                                     posnr = t_vepo-posnr.
          if sy-subrc = 0.
            delete t_lips index sy-tabix.
          endif.
        endloop.
        if not t_lips[] is initial.
      move any unpacked items to the data table
          perform move_lips_to_table.
        endif.
      endif.                                                          "TR03+
    *<---- TR01+ End
    get relevant status icons
      perform select_icons.
    prepare ALV data
      perform prepare_alv.
    endform.                    " select_data
    *&      Form  select_icons
          select icons for display and move data to display table
    form select_icons.
      data: w_disp_tab like zpickdisp,
            w_disp_head like zpickhead,
            w_color like zpickdisp-color,
            ov_icon like zpickdisp-ov_icon,
            gi_icon like zpickdisp-gi_icon,
            to_icon like zpickdisp-to_icon,
            lp_icon like zpickdisp-lp_icon,
            pc_icon like zpickdisp-pc_icon,
            lv_icon like zpickdisp-lv_icon,
            vm_icon like zpickdisp-vm_icon,
            em_icon like zpickdisp-em_icon,
            t_ovst_tab like t_disp_tab with header line.
      constants: c_col1(3) value 'C10',
                 c_col2(3) value 'C20'.
      sort t_data_tab by lgtor vbeln.
      w_color = c_col2.
      loop at t_data_tab.
        at new lgtor.
        fill ALV header table
          clear w_disp_head.
          w_disp_head-lgtor = t_data_tab-lgtor.
          append w_disp_head to t_disp_head.
        endat.
      goods issue status & overall amber/green only
        case t_data_tab-wbstk.
          when c_c.
            move icon_green_light to gi_icon.
            move icon_green_light to ov_icon.
          when others.
            move icon_red_light to gi_icon.
            move icon_yellow_light to ov_icon.
        endcase.
      transfer order status
        case t_data_tab-lvsta.
          when c_a.
            move icon_red_light to to_icon.
          when c_b.
            move icon_yellow_light to to_icon.
          when c_c.
            move icon_green_light to to_icon.
          when space.
          write N/A
            to_icon = 'N/A'.
        endcase.
      loaded to pallet status
        if not t_data_tab-zpallet_no is initial.
          move icon_green_light to lp_icon.
        else.
          move icon_red_light to lp_icon.
        endif.
      pallet count status
        if not t_data_tab-zcount_check is initial.
          move icon_green_light to pc_icon.
        else.
          move icon_red_light to pc_icon.
        endif.
      loaded to van status
        if not t_data_tab-zvan_no is initial.
          move icon_green_light to lv_icon.
        else.
          move icon_red_light to lv_icon.
        endif.
      van manifest status
        if not t_data_tab-zvan_print is initial.
          move icon_green_light to vm_icon.
        else.
          move icon_red_light to vm_icon.
        endif.
      end of day manifest status
        if not t_data_tab-zeod_print is initial.
          move icon_green_light to em_icon.
        else.
          move icon_red_light to em_icon.
        endif.
      move working data table to display table
        move-corresponding t_data_tab to w_disp_tab.
        w_disp_tab-ov_icon = ov_icon.
        w_disp_tab-gi_icon = gi_icon.
        w_disp_tab-to_icon = to_icon.
        w_disp_tab-lp_icon = lp_icon.
        w_disp_tab-pc_icon = pc_icon.
        w_disp_tab-lv_icon = lv_icon.
        w_disp_tab-vm_icon = vm_icon.
        w_disp_tab-em_icon = em_icon.
        w_disp_tab-color = w_color.
      fill N/A values for initial fields for display
        if w_disp_tab-packvorschr is initial.
          w_disp_tab-packvorschr = 'N/A'.
        endif.
        if w_disp_tab-exidv is initial.
          w_disp_tab-exidv = 'N/A'.
        endif.
        if w_disp_tab-zpallet_no is initial.
          write 'N/A' to w_disp_tab-zpallet_no.
        endif.
        if w_disp_tab-zvan_no is initial.
          write 'N/A' to w_disp_tab-zvan_no.
        endif.
      display different color for new doc number
        at end of vbeln.
          if w_color = c_col1.
            w_color = c_col2.
          elseif w_color = c_col2.
            w_color = c_col1.
          endif.
        endat.
        append w_disp_tab to t_disp_tab.
        clear w_disp_tab.
      endloop.
    we have all the icons in display but need to check the overall status
    as this refers to the line items
    green and amber statuses already set and use the same criteria as the
    goods issue status unless detected as red here
      data: ov_stat_red(1).
      clear w_disp_tab.
      sort t_disp_tab by vbeln.
      loop at t_disp_tab into w_disp_tab.
        at new vbeln.
        check all line items for delivery
          loop at t_data_tab where vbeln = w_disp_tab-vbeln.
            if t_data_tab-lvsta = c_a.
            set overall status to red
              ov_stat_red = c_yes.
              exit.
            else.
            leave green/amber status icon as previosly determined
            endif.
          endloop.
          if ov_stat_red = c_yes.
          set overall status to red for all items in that delivery
            clear ov_stat_red.
            move icon_red_light to w_disp_tab-ov_icon.
            modify t_disp_tab from w_disp_tab transporting ov_icon
                              where vbeln = w_disp_tab-vbeln.
          endif.
        endat.
      endloop.
    endform.                    " select_icons
    *&      Form  fill_layout
          fill ALV layout parameters
    form fill_layout.
      clear g_layout.
      g_layout-colwidth_optimize = c_yes.   " column width optimisation
      g_layout-zebra = space.               " alternate line colors
      g_layout-box_fieldname = 'MARK'.      " checkbox fieldname
      g_layout-info_fieldname = 'COLOR'.    " highlight row indicator
      g_layout-no_vline = space.            " vertical line
      g_layout-key_hotspot = space.         " hotspot field
      g_layout-f2code = 'PICK'.             " F2 ok_code
      g_layout-numc_sum = c_yes.            " sum numc fields
      g_layout-box_tabname = 't_disp_head'. " checkbox table name
      g_layout-expand_fieldname = 'EXPAND'. " expand field name
    endform.                    " fill_layout
    *&      Form  fill_sort
          fill ALV sort table
    form fill_sort.
      data: w_g_sort type slis_sortinfo_alv.
      w_g_sort-spos      = 1.
      w_g_sort-fieldname = 'LGTOR'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
      w_g_sort-spos      = 2.
      w_g_sort-fieldname = 'VBELN'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
      w_g_sort-spos      = 3.
      w_g_sort-fieldname = 'POSNR'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
      w_g_sort-spos      = 4.
      w_g_sort-fieldname = 'WADAT'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
    endform.                    " fill_sort
    *&      Form  fill_fieldcat
          Fill field category structure for ALV
    form fill_fieldcat.
      clear t_fldcat.
    create field catalogue for header table
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
           exporting
                i_program_name         = 'ZWMR_PICK_STATUS_REPORT'
                i_internal_tabname     = 't_disp_head'
                i_structure_name       = 'ZPICKHEAD'
                i_client_never_display = c_yes
           changing
                ct_fieldcat            = gt_fieldcat[].
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    ceate field catalogue for items table
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
           exporting
                i_program_name         = 'ZWMR_PICK_STATUS_REPORT'
                i_internal_tabname     = 't_disp_tab'
                i_structure_name       = 'ZPICKDISP'
                i_client_never_display = c_yes
           changing
                ct_fieldcat            = gt_fieldcat[].
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    modify field catalogue for this report
    set no display flag if not requested on selection screen
      if p_exdata ne c_yes.
        t_fldcat-no_out    =  c_yes.
        modify gt_fieldcat from t_fldcat transporting no_out
                           where fieldname eq 'PACKVORSCHR'
                           or    fieldname eq 'EXIDV'
                           or    fieldname eq 'ZPALLET_NO'
                           or    fieldname eq 'ZVAN_NO'
                           or    fieldname eq 'ZZPACKCLASS'
                           or    fieldname eq 'ZZTI'.
      endif.
    set no display flag for item level LGTOR field
      t_fldcat-no_out    =  c_yes.
      modify gt_fieldcat from t_fldcat transporting no_out
                         where fieldname eq 'LGTOR'
                         and   tabname   eq 't_disp_tab'.
    prevent display of technical fields
      t_fldcat-tech = c_yes.
      modify gt_fieldcat from t_fldcat transporting tech
                         where fieldname eq 'EXPAND'
                         or    fieldname eq 'SELKZ'.
    set vbeln as key
      t_fldcat-key = c_yes.
      modify gt_fieldcat from t_fldcat transporting key
                         where fieldname eq 'VBELN'.
    prevent scrolling for info fields
      t_fldcat-fix_column = c_yes.
      modify gt_fieldcat from t_fldcat transporting fix_column
                         where fieldname eq 'VBELN'.
    endform.                    " fill_fieldcat
    *&      Form  prepare_ALV
          Fill ALV parameters
    form prepare_alv.
    fill ALV key info
      g_keyinfo-header01 = 'LGTOR'.
      g_keyinfo-item01   = 'LGTOR'.
    fill ALV events
      gs_event-name = 'TOP_OF_PAGE'.
      gs_event-form = 'TOP_OF_PAGE'.
      append gs_event to gt_events.
    fill ALV sort table
      perform fill_sort.
    fill ALV layout structure
      perform fill_layout.
    fill ALV field category
      perform fill_fieldcat.
    endform.                    " prepare_ALV
    *&      Form  user_command
          form called on user command from ALV list
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
      data: index type i,
            w_disp_head like line of t_disp_head,
            w_door like likp-lgtor.
      clear r_lgtor. refresh r_lgtor.
      case r_ucomm.
        when 'PICK'. " Double click line
        when 'VANM'. " Van Manifest button
        read the header table where has been selected
          loop at t_disp_head into w_disp_head where mark = c_yes.
            r_lgtor-sign   = 'I'.
            r_lgtor-option = 'EQ'.
            r_lgtor-low    = w_disp_head-lgtor.
            append r_lgtor.
          endloop.
        print the van manifest
          perform print_van_manifest tables r_lgtor.
        when 'EODM'. " EOD Manifest button
        read the header table where has been selected
          loop at t_disp_head into w_disp_head where mark = c_yes.
            r_lgtor-sign   = 'I'.
            r_lgtor-option = 'EQ'.
            r_lgtor-low    = w_disp_head-lgtor.
            append r_lgtor.
          endloop.
        print the end of day manifest
          perform print_eod_manifest tables r_lgtor.
        when 'REFR'. "Refresh
        refresh display
          w_sy_repid = sy-repid.
          call function 'RS_REFRESH_FROM_SELECTOPTIONS'
               exporting
                    curr_report     = w_sy_repid
               tables
                    selection_table = seltab.
              exceptions
                  not_found       = 1
                  no_report       = 2
                  others          = 3.
          if sy-

  • ALV tree - Displaying of footer

    Hi Experts,
    I have an ALV report which has a tree output.I want to display some text in the footer.How can I do that?
    I searched a lot but I just got information on how to display the footer in an alv grid but nothing about alv tree.
    Thanks in advance.
    Regards,
    Puja

    hii puja,
    check below code where ALV footer is printed which will display the selection screen parameter at bottom of output ________________________________________________________________ SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001. "General Selections SELECT-OPTIONS: s_bukrs FOR gs_knb1-bukrs NO INTERVALS OBLIGATORY, "Company code s_grupp for gv_grupp no intervals no-extension. "Customer credit group SELECT-OPTIONS: s_kunnr FOR gs_kna1-kunnr . "Customer number SELECTION-SCREEN: END OF BLOCK blk1. "General Selections SELECTION-SCREEN: BEGIN OF BLOCK blk2 WITH FRAME . SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(41) text-002. PARAMETERS : p_tmoney(3) TYPE c . "Target money at risk SELECTION-SCREEN END OF LINE. SELECTION-SCREEN: END OF BLOCK blk2. _______________________________________________________________ CLASS lcl_event_receiver DEFINITION. PUBLIC SECTION. METHODS: end_of_list FOR EVENT end_of_list OF cl_gui_alv_grid IMPORTING e_dyndoc_id. ENDCLASS. "lcl_event_receiver DEFINITION &---- *& CLASS IMPLEMENTATION &---- &---- * CLASS lcl_event_receiver IMPLEMENTATION &---- * Class implementation for TOP-OF-PAGE &---- CLASS lcl_event_receiver IMPLEMENTATION. METHOD end_of_list. "implementation DATA : lv_text TYPE sdydo_text_element, lv_tbmar(15) TYPE c, " All Customers Base Money at Risk lv_tmr(15) TYPE c, " Total Money at Risk lv_emr(15) TYPE c, " Excess Money at Risk lv_mtemr(15) TYPE c, " Monthly Target Excess Money at Risk lv_var(15) TYPE c, " Variance lv_bukrs TYPE bukrs, lv_grupp TYPE grupp_cm, lv_kunnr TYPE kunnr, lv_kunnr1 TYPE kunnr, lv_tmoney(6) TYPE c. * To display all the parameters in selection screen *Company code CALL METHOD go_dyndoc_id->new_line. CALL METHOD go_dyndoc_id->new_line. MOVE s_bukrs-low TO lv_bukrs. CONCATENATE text-027 lv_bukrs INTO lv_text SEPARATED BY space. CALL METHOD go_dyndoc_id->add_text EXPORTING text = lv_text sap_style = cl_dd_area=>key. *Customer Credit Group CALL METHOD go_dyndoc_id->new_line. MOVE s_grupp-low TO lv_grupp. CONCATENATE text-028 lv_grupp INTO lv_text SEPARATED BY space. CALL METHOD go_dyndoc_id->add_text EXPORTING text = lv_text sap_style = cl_dd_area=>key. *Customer Number CALL METHOD go_dyndoc_id->new_line. MOVE s_kunnr-low TO lv_kunnr. MOVE s_kunnr-high TO lv_kunnr1. IF lv_kunnr1 IS INITIAL. CONCATENATE text-029 lv_kunnr INTO lv_text SEPARATED BY space. ELSE. CONCATENATE text-029 lv_kunnr ' TO ' lv_kunnr1 INTO lv_text SEPARATED BY space. ENDIF. CALL METHOD go_dyndoc_id->add_text EXPORTING text = lv_text sap_style = cl_dd_area=>key. *Target Excess Money at risk CALL METHOD go_dyndoc_id->new_line. MOVE p_tmoney TO lv_tmoney. CONCATENATE text-030 lv_tmoney INTO lv_text SEPARATED BY space. CALL METHOD go_dyndoc_id->add_text EXPORTING text = lv_text sap_style = cl_dd_area=>key. IF go_html_cntrl IS INITIAL. CREATE OBJECT go_html_cntrl EXPORTING parent = go_parent_html. ENDIF. DATA: lv_background_id TYPE sdydo_key VALUE space. CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET' EXPORTING document = go_dyndoc_id bottom = space. CALL METHOD go_dyndoc_id->merge_document. CALL METHOD go_dyndoc_id->set_document_background EXPORTING picture_id = lv_background_id. go_dyndoc_id->html_control = go_html_cntrl. CALL METHOD e_dyndoc_id->display_document EXPORTING reuse_control = abap_true parent = go_parent_html EXCEPTIONS html_display_error = 1. IF sy-subrc 0. MESSAGE i014. ENDIF. ENDMETHOD. "END_OF_LIST ENDCLASS. "lcl_event_receiver IMPLEMENTATION _________________________________________________________ &---- *& Module mod_init_9000 OUTPUT &---- * Place the values from grid object to custom container for ALV display ---- MODULE mod_init_9000 OUTPUT. DATA: lo_event_receiver TYPE REF TO lcl_event_receiver."#EC * IF cl_gui_alv_grid=>offline( ) IS INITIAL. IF go_container IS INITIAL. * Create a custom container control for ALV control CREATE OBJECT go_container EXPORTING container_name = 'CN_GRID_CONTROL'. * Split Controls CREATE OBJECT go_splitter EXPORTING parent = go_container rows = 2 columns = 1. CALL METHOD go_splitter->set_row_height EXPORTING id = 1 height = 68. CALL METHOD go_splitter->get_container EXPORTING row = 2 column = 1 RECEIVING container = go_parent_html. CALL METHOD go_splitter->get_container EXPORTING row = 1 column = 1 RECEIVING container = go_parent_grid. * Create a ALV Control CREATE OBJECT go_grid EXPORTING i_parent = go_parent_grid. CREATE OBJECT go_dyndoc_id EXPORTING style = gc_style. "ALV_GRID PERFORM sub_fieldcat_layout. CREATE OBJECT lo_event_receiver. SET HANDLER lo_event_receiver->end_of_list FOR go_grid. CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid. * Set Table for first display PERFORM sub_table_display. CALL METHOD go_dyndoc_id->initialize_document. CALL METHOD go_grid->list_processing_events EXPORTING i_event_name = gc_event "END_OF_LIST i_dyndoc_id = go_dyndoc_id. ENDIF. ENDIF. ENDMODULE. " mod_init_9000 OUTPUT _____________________________________________________ &---- *& Form SUB_TABLE_DISPLAY &---- * Display the output ---- FORM sub_table_display . DATA gs_layo TYPE lvc_s_layo. gs_layo-zebra = abap_true. gs_layo-sel_mode = gc_save. CALL METHOD go_grid->set_table_for_first_display EXPORTING i_save = gv_save i_default = gc_Default is_layout = gs_layo CHANGING it_outtab = gt_final[] it_fieldcatalog = gt_fcat. ENDFORM. " SUB_TABLE_DISPLAY
    regards,
    Shweta

  • How to expand a Root-Element in ALV-Tree?

    Hi,
    i use ALV-Tree and try to expand the first hierarchie.
    I try this:
      TRY.
          GR_TREE_NODE = GR_TREE_NODES->ADD_NODE(
            RELATED_NODE = ROOT_KEY
            *EXPANDER     = ABAP_TRUE*
            RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_FIRST_CHILD
            TEXT         = 'Meldungen').
        CATCH CX_SALV_MSG.
      ENDTRY.
    but this element will not be expandet?
    I know this for expand all:     CALL METHOD GR_TREE_NODES->EXPAND_ALL.
    but want to expand only the first hierarch-elemet (root).
    Can anyone tell me what i'm doing wrong?
    Thanks.
    Regards, Dieter

    Hi,
    solved by this:
    GR_TREE_NODE->EXPAND( ).
    Regards, Dieter

  • Call Transaction in ALV Tree Display on Double Click

    Hi Experts,
    How can i call any Transaction on Double clicking  a field in ALV Tree?
    I'm able to call the transaction when Double clicked a field but it is not reading the value of the field on which i double click. It calls the transaction skipping the first screen with always the same value of the field.
          E.g : Whether i click on Purchase order no.  450000010 or 450000003 it displays the purchase order 4500000010 after it goes to ME23N transaction skipping the first screen.
            I am Trying Method ITEM_DOUBLE_CLICK of Class CL_GUI_COLUMN_TREE
    by passing the parameter NODE_KEY.But it's not working.
    Thanks & Regards,
    Vinit Ranjan

    hi
    (also check u have refresh the field)
    Check the demo program,In this double click the data fields it will display some field in screen,You can check it
    BCALV_GRID_DND_TREE
    Thanks
    Edited by: dharma raj on Jun 17, 2009 7:41 PM

  • ALV Tree, Expanded node do not show data in certain column

    Hi all,
    I need your help regard to below problem.
    I have an ALV grid in which one of the columns has F4 (search help). If search help is called by pressing a F4 button a dialog box will be shown with ALV tree on it.
    The ALV Tree has 2 columns which are: hierarchy column and one other column called WBS column. At the first show, all expanded node show data contained in WBS column, but if I click to expand a collapsed node, data is not shown in WBS column for the new expanded rows, only shows data in hierarchy column. How to show data in WBS column for the new expanded rows..?
    Basically if at the first show I expand all node, data in WBS column are shown for all rows. It seems that the Expand Node event doesn't update all column data to be shown.
    Please share if anyone of you has faced this kind of problem. Thank you.
    Regards,
    Ramses Hutahaean
    Edited by: Ramses Hutahaean on Feb 29, 2012 1:38 PM

    Hi Fenja,
    as the click-events only raise the node_key (at least I couldn't detect another information), I assume the only way is maintaining an internal helper table by yourself which you build up in parallel when creating the tree and its nodes.
    The (hashed) table might contain 2 columns:
    1. node_key (as table key)
    2. reference to an object
    When a click-event is raised, you look up the corresponding object reference in your table.
    Regards,
    Ulrich

  • 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

  • How to avoid blank column display in output in ALV TREE

    how to avoid blank column display in output while decreasing the length of other columns in ALV Tree.
    Example: please refer to BCALV_TREE_01 and see the output, then decrease the length of all columns . Then you can see a blank column appearing in screen at last, i.e in container. so how to avoid that.
    Thanks for reply.
    Edited by: morpeous on Jul 1, 2009 1:53 PM

    Hi,
    Check BCALV_TREE_02 on how to hide columns.
    Thanks & Regards,
    Anand Patil

Maybe you are looking for

  • Need to read Unicode in a file

    Hi, My need to read Unicode from a file (on a Windows box) is due to the fact my software is used in different countries and on different keyboard naturally. All the users are not computer literate but, like me, they are all lazy and want to put thei

  • How to restore ipad in recovery mode

    I am trying to restore an iPad Gen 3 on IOS 6 using recovery mode but iTunes cannot find the backup file on my PC while the iPad is in recovery mode. However, on my PC, iTunes shows that a backup exists when I say that I need to do a restore. The res

  • R-Tree Index v's Quadtree Index

    Hi, In the 8.1.7 spatial documentation it says that R-Tree index may not be a good choice for a geometry table that has heavy update activity. Can anyone define and quantify what heavy update is? Thanks

  • Hide / Show fields in screen

    Hi!. How can I desactive the right-click option in screen:      *'user's options': hide/show fields of screen in a web dynpro?. I don't want that users change the design of the web dynpro, and they hide the fields. Thanks in advance. Ana

  • How to boot from SD-card on Satellite Pro S300?

    My windows 7 32bit based S300 has a build-in SD card reader. The Toshiba utility for making the SD card bootable comes with an error message stating Fault: 00-61-FF02-26. Is does not see or recognize the card. In the BIOS version 3.00 WIN there is al