Add_node

Hello Everbody!
How can I implement customer specific hierarchy via alv-tree.
like:
Customer-Nr
Period
-> Information.
These both upper hierarchies "Customer-Nr" and "Period" should have a
Folder-Icon as usually which indicates being the upper hierarchy.
Is the method add_node responsible for it ? If so
at which part of this method must it determined.
call method gd_tree->add_node
Generally whereby is it specified exactly what node the upper hierarchy
is (Folder-Icon ) and not. How can I stear it to my desire.
Reagards
Ilhan

Amit Khare thank you but it doesn' t answers my question.
I only want to know how can I create my own hierarchy concerning
to an existing code-problem. If you have one minute take a look at this code.
It is problematical to  construct the folowing hierarchy :
1 hierarchy (yellow Folder icon)-> Customer-Nr
2 hierarchy (yellow Folder icon)-> Period
3 hierarchy (any other icon)->  datas
TABLES:     ZQMCOMP.
TYPE-POOLS: slis.                                 "ALV Declarations
DATA: it_ekko     TYPE STANDARD TABLE OF ZQMCOMP INITIAL SIZE 0,
      it_ekpo     TYPE STANDARD TABLE OF ZQMCOMP INITIAL SIZE 0,
      it_emptytab TYPE STANDARD TABLE OF ZQMCOMP INITIAL SIZE 0,
      wa_ekko     TYPE ZQMCOMP,
      wa_ekpo     TYPE ZQMCOMP.
DATA: ok_code like sy-ucomm,           "OK-Code
      save_ok like sy-ucomm.
*ALV data declarations
DATA: fieldcatalog  TYPE lvc_t_fcat WITH HEADER LINE.
DATA: gd_fieldcat   TYPE lvc_t_fcat,
      gd_tab_group  TYPE slis_t_sp_group_alv,
      gd_layout     TYPE slis_layout_alv.
*ALVtree data declarations
CLASS cl_gui_column_tree DEFINITION LOAD.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA: gd_tree             TYPE REF TO cl_gui_alv_tree,
      gd_hierarchy_header TYPE treev_hhdr,
      gd_report_title     TYPE slis_t_listheader,
      gd_logo             TYPE sdydo_value,
      gd_variant          TYPE disvariant.
DATA: l_tree_container_name(30) TYPE c,
      l_custom_container        TYPE REF TO cl_gui_custom_container,
     gd_tree_container_name    TYPE REF TO cl_gui_custom_container,
     gd_custom_container TYPE REF TO cl_gui_custom_container.
* Add following code to 'Z......F01' INCLUDE
*&      Form  CREATE_ALVTREE_CONTAINER
*       Create container for alv-tree
FORM create_alvtree_container.
  create object gd_custom_container
      exporting
            container_name = 'SCREEN_CONTAINER'
      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'.
  endif.
ENDFORM.
START-OF-SELECTION.
  PERFORM data_retrieval.
  PERFORM build_fieldcatalog.
  PERFORM build_layout.
  PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
  PERFORM build_report_title USING gd_report_title gd_logo.
  PERFORM build_variant.
  call screen 100.
*&      Form  DATA_RETRIEVAL
*       Retrieve data into Internal tables
FORM data_retrieval.
  select * from ZQMCOMP into TABLE it_ekko.
  select * from ZQMCOMP into TABLE it_ekpo.
ENDFORM.                    " DATA_RETRIEVAL
*&      Form  BUILD_FIELDCATALOG
*       Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
  fieldcatalog-fieldname   = 'EBELN'.           "Field name in itab
  fieldcatalog-scrtext_s   = 'Kunden-Nr'.  "Column text
  fieldcatalog-col_pos     = 0.                 "Column position
  fieldcatalog-outputlen   = 15.                "Column width
  fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
  fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
  APPEND fieldcatalog TO gd_fieldcat.
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'EBELP'.
  fieldcatalog-scrtext_s   = 'PO Iten'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 1.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'STATU'.
  fieldcatalog-scrtext_s   = 'Status'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 2.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'AEDAT'.
  fieldcatalog-scrtext_s   = 'Item change date'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 3.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'MATNR'.
  fieldcatalog-scrtext_s   = 'Material Number'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 4.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'MENGE'.
  fieldcatalog-scrtext_s   = 'PO quantity'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 5.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'MEINS'.
  fieldcatalog-scrtext_s   = 'Order Unit'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 6.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'NETPR'.
  fieldcatalog-scrtext_s   = 'Net Price'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 7.
  fieldcatalog-datatype     = 'CURR'.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
  fieldcatalog-fieldname   = 'PEINH'.
  fieldcatalog-scrtext_s   = 'Price Unit'.
  fieldcatalog-outputlen   = 15.
  fieldcatalog-col_pos     = 8.
  APPEND fieldcatalog TO gd_fieldcat..
  CLEAR  fieldcatalog.
ENDFORM.                    " BUILD_FIELDCATALOG
*&      Form  BUILD_LAYOUT
*       Build layout for ALV grid report
FORM build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
  gd_layout-totals_text       = 'Totals'(230).
*  gd_layout-totals_only        = 'X'.
*  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
*                                         "click(press f2)
  gd_layout-zebra             = 'X'.
*  gd_layout-group_change_edit = 'X'.
*  gd_layout-header_text       = 'helllllo'.
ENDFORM.                    " BUILD_LAYOUT
*&      Form  build_hierarchy_header
*       build hierarchy-header-information
*      -->P_L_HIERARCHY_HEADER  structure for hierarchy-header
FORM build_hierarchy_header CHANGING
                               p_hierarchy_header TYPE treev_hhdr.
  p_hierarchy_header-heading = 'Kunden-Nr.'(013).
  p_hierarchy_header-tooltip = 'Kundenummer'(014).
  p_hierarchy_header-width = 30.
  p_hierarchy_header-width_pix = ''.
ENDFORM.                               " build_hierarchy_header
*&      Form  BUILD_REPORT_TITLE
*       Build table for ALVtree header
*  <->  p1        Header details
*  <->  p2        Logo value
FORM build_report_title CHANGING
      pt_report_title  TYPE slis_t_listheader
      pa_logo             TYPE sdydo_value.
  DATA: ls_line TYPE slis_listheader,
        ld_date(10) TYPE c.
* List Heading Line(TYPE H)
  CLEAR ls_line.
  ls_line-typ  = 'H'.
* ls_line-key     "Not Used For This Type(H)
  ls_line-info = 'INFO'.
  APPEND ls_line TO pt_report_title.
* Status Line(TYPE S)
  ld_date(2) = sy-datum+6(2).
  ld_date+2(1) = '/'.
  ld_date+3(2) = sy-datum+4(2).
  ld_date+5(1) = '/'.
  ld_date+6(4) = sy-datum(4).
  ls_line-typ  = 'S'.
  ls_line-key  = 'Date'.
  ls_line-info = ld_date.
  APPEND ls_line TO pt_report_title.
* Action Line(TYPE A)
  CLEAR ls_line.
  ls_line-typ  = 'A'.
  ls_line-info = 'Liste pro Kunde'.
  APPEND ls_line TO pt_report_title.
ENDFORM.
*&      Form  BUILD_VARIANT
*       Build variant
form build_variant.
* Set repid for storing variants
  gd_variant-report = sy-repid.
endform.                    " BUILD_VARIANT
*&      Module  STATUS_0100  OUTPUT
*       text
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'STATUS1'.
  SET TITLEBAR 'STATUS1'.
  IF gd_tree IS INITIAL.
    PERFORM create_alvtree_container.
    PERFORM create_object_in_container.
    PERFORM create_empty_alvtree_control.
    PERFORM create_alvtree_hierarchy.
  ENDIF.
  CALL METHOD cl_gui_cfw=>flush.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
*       text
MODULE USER_COMMAND_0100 INPUT.
  DATA return TYPE REF TO cl_gui_event.
  save_ok = ok_code.
  case ok_code.
    when 'BACK' or '%EX' or 'RW'.
*     Exit program
      leave to screen 0.
*   Process ALVtree user actions
    when others.
      call method cl_gui_cfw=>get_current_event_object
              receiving
                 event_object = return.
      call method cl_gui_cfw=>dispatch.
  endcase.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
* Add following code to 'Z......F01' INCLUDE
*&      Form  CREATE_OBJECT_IN_CONTAINER
*       Create ALVtree control
FORM create_object_in_container.
  create object gd_tree
    exporting
        parent              = gd_custom_container
        node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
        item_selection      = 'X'
        no_html_header      = ''
        no_toolbar          = ''
    exceptions
        cntl_error                   = 1
        cntl_system_error            = 2
        create_error                 = 3
        lifetime_error               = 4
        illegal_node_selection_mode  = 5
        failed                       = 6
        illegal_column_name          = 7.
  if sy-subrc <> 0.
    message x208(00) with 'ERROR'.
  endif.
ENDFORM.
* Add following code to 'Z......F01' INCLUDE
*&      Form  CREATE_EMPTY_ALVTREE_CONTROL
*       Create empty tree control
FORM create_empty_alvtree_control.
* Create emty tree-control
  CLEAR: it_emptytab.
  REFRESH: it_emptytab.
  CALL METHOD gd_tree->set_table_for_first_display
     EXPORTING
               I_STRUCTURE_NAME     = 'ZQMCOMP'
               is_hierarchy_header  = gd_hierarchy_header
               it_list_commentary   = gd_report_title
               i_logo               = gd_logo
               i_background_id      = 'ALV_BACKGROUND'
               i_save               = 'A'
               is_variant            = gd_variant
     CHANGING
               it_outtab            =  it_emptytab  .    "Must be empty
*               it_fieldcatalog      =  gd_fieldcat.
ENDFORM.                    " CREATE_EMPTY_ALVTREE_CONTROL
* Add following code to 'Z......F01' INCLUDE
*&      Form  CREATE_ALVTREE_HIERARCHY
*       text
*       Builds ALV tree display, (inserts nodes, subnodes etc)
form create_alvtree_hierarchy.
  data: ld_ebeln_key type lvc_nkey,
        ld_ebelp_key type lvc_nkey.
  loop at it_ekko into wa_ekko.
    perform add_ekko_node using      wa_ekko
                                changing ld_ebeln_key.
    perform add_node_date using      wa_ekko
                               changing ld_ebeln_key.
    perform add_ekpo_line using      wa_ekko
                                          ld_ebeln_key
                                 changing ld_ebelp_key.
  endloop.
* calculate totals
  call method gd_tree->update_calculations.
* this method must be called to send the data to the frontend
  call method gd_tree->frontend_update.
endform.                    " CREATE_ALVTREE_HIERARCHY
*&      Form  add_node_date
*       text
*      -->P_WA_EKPO  text
*      -->P_0553   text
*      <--P_EBELN_KEY  text
form add_node_date using    ps_ekko like wa_ekko
                            value(p_relate_key)
                   changing p_node_key.
  data: ld_node_text type lvc_value,
        ls_sflight type sflight.
* Set item-layout
  data: lt_item_layout type lvc_t_layi,
        ls_item_layout type lvc_s_layi.
  ls_item_layout-t_image   = '@1U@'.
  ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
  ls_item_layout-style     = cl_gui_column_tree=>style_default.
  ld_node_text             = 'Period'.
  append ls_item_layout to lt_item_layout.
* Add node
  call method gd_tree->add_node
    exporting
          i_relat_node_key = p_relate_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_node_text
          is_outtab_line   = ps_ekko-KUNDE
          it_item_layout   = lt_item_layout
       importing
          e_new_node_key = p_node_key.
endform.                    " ADD_EKKO_NODE
*       FORM add_ekko_node                                            *
*  -->  PS_EKKO                                                       *
*  -->  VALUE(P_RELATE_KEY)                                           *
*  -->  P_NODE_KEY                                                    *
form add_ekko_node using    ps_ekko like wa_ekko
                            value(p_relate_key)
                   changing p_node_key.
  data: ld_node_text type lvc_value,
        ls_sflight type sflight.
* Set item-layout
  data: lt_item_layout type lvc_t_layi,
        ls_item_layout type lvc_s_layi.
  ls_item_layout-t_image   = '@A0@'.
  ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
  ls_item_layout-style     = cl_gui_column_tree=>style_default.
  ld_node_text             = 'Customer-Nr..'.
  append ls_item_layout to lt_item_layout.
* Add node
  call method gd_tree->add_node
    exporting
          i_relat_node_key = p_relate_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_node_text
          is_outtab_line   = ps_ekko-KUNDE
          it_item_layout   = lt_item_layout
       importing
          e_new_node_key = p_node_key.
endform.                    " ADD_EKKO_NODE
*&      Form  ADD_EKPO_LINE
*       text
*      -->P_WA_EKPO  text
*      -->P_LD_EBELN_KEY  text
*      <--P_LD_EBELP_KEY  text
form add_ekpo_line using    ps_ekpo like wa_ekpo
                            value(p_relate_key)
                   changing p_node_key.
  data: ld_node_text type lvc_value,
        ls_sflight type sflight.
* Set item-layout
  data: lt_item_layout type lvc_t_layi,
        ls_item_layout type lvc_s_layi.
  ls_item_layout-t_image   = '@90@'.
  ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
  ls_item_layout-style     = cl_gui_column_tree=>style_default.
  ld_node_text             = ps_ekpo-KUNDE.
  append ls_item_layout to lt_item_layout.
* Add node
  call method gd_tree->add_node
    exporting
          i_relat_node_key = p_relate_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_node_text
          is_outtab_line   = ps_ekpo
          it_item_layout   = lt_item_layout
       importing
          e_new_node_key = p_node_key.
endform.                    " ADD_EKPO_LINE

Similar Messages

  • Add_node method

    Hi Expert!!
    I need you help i am creating column tree with using my local class with reference to cl_gui_column_tree the method add_node is not in this class .As this method is present in cl_column_tree_model class.Please advice which method i can use as similarly add_node in cl_gui_column_tree.
    Thanks in advance.
    Ankur Garg

    Hello Ankur
    Sample report SAPCOLUMN_TREE_CONTROL_DEMO shows how to build a tree using class cl_gui_column_tree.
    Below you see part of the coding where the tree nodes are created:
    * add some nodes to the tree control
    * NOTE: the tree control does not store data at the backend. If an
    * application wants to access tree data later, it must store the
    * tree data itself.
      PERFORM BUILD_NODE_AND_ITEM_TABLE USING NODE_TABLE ITEM_TABLE.
      CALL METHOD G_TREE->ADD_NODES_AND_ITEMS
        EXPORTING
          NODE_TABLE = NODE_TABLE
          ITEM_TABLE = ITEM_TABLE
          ITEM_TABLE_STRUCTURE_NAME = 'MTREEITM'
        EXCEPTIONS
          FAILED = 1
          CNTL_SYSTEM_ERROR = 3
          ERROR_IN_TABLES = 4
          DP_ERROR = 5
          TABLE_STRUCTURE_NAME_NOT_FOUND = 6.
      IF SY-SUBRC <> 0.
        MESSAGE A000.
      ENDIF.
    * expand the node with key 'Root'
      CALL METHOD G_TREE->EXPAND_NODE
        EXPORTING
          node_key            = c_nodekey-Root
        EXCEPTIONS
          FAILED              = 1
          ILLEGAL_LEVEL_COUNT = 2
          CNTL_SYSTEM_ERROR   = 3
          NODE_NOT_FOUND      = 4
          CANNOT_EXPAND_LEAF  = 5.
      IF SY-SUBRC <> 0.
        MESSAGE A000.
      ENDIF.
    ENDFORM.                    " CREATE_AND_INIT_TREE
    It seems that this class does not have a method for adding a single node. Thus, use method ADD_NODES_AND_ITEMS with a single entry in the node and item itabs.
    Regards
      Uwe

  • Script modification need

    DOCU – WINDOW
    This is the window on the top right side
    1.Document no (hard coded)
    2.Then display the document number for the first document for the current row. Maybe you should check prior to printing if the current row was posted error free   
       and invoke printing only if this is the case. Then get the first(!!!) document number from the error/message log for this row. ZGF_ICO_RECHR_L-DOCFR
    3. Document date (hard coded) it is P_BLDAT on the selection screen, already correct in the form
    4. VAT No (hard coded)
    5. Then display the EU VAT reg.no of that company. This is in table KNA1, where KUNNR = L_ROW-CUSTFR. The field is KNA1-STCEG, if it is empty, try to populate
         KNA1-STCD1.
    6. Order number(Hard coded)
    7. Just concatenate L_ROW-REF + the last number for that reference from the log table ZGF_ICO_RECHR_L (notice this table has not yet been created!!! and also
        the part is missing where we populate that table when posting both documents for a particular row) ZGF_ICO_RECHR_L-REF+NUMBER
    report  ZG00F_.
    Top Include for the data declarations
    class LCL_REF definition deferred.
    include ZG00F_INT_POST_INVOICE_TOP.
    data: G_ALV_TREE         type ref to CL_GUI_ALV_TREE,
          G_CUSTOM_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER,
          G_TEXT_CONTAINER   type ref to CL_GUI_CUSTOM_CONTAINER,
          G_LOGGER           type ref to CL_GUI_TEXTEDIT,
          G_TOOLBAR          type ref to CL_GUI_TOOLBAR.
    data: " gt_zgf_ico_rechr      type zgf_ico_rechr occurs 0,
                           "Output-Table
          OKCODE like SY-UCOMM.
          CLASS LCL_REF DEFINITION
    class LCL_REF definition.
      public section.
        data : VALID type BOOLEAN,
               CAN type BOOLEAN.
        methods : CONSTRUCTOR
                    importing IM_REF type ZGF_ICO_RECHR,
                  CAN_POST
                    returning VALUE(CAN) type BOOLEAN,
                  IS_VALID
                    returning VALUE(IS_VALID) type BOOLEAN,
                  GET_DIVA  returning VALUE(DIVA) type LVC_S_LAYN,
                  GET_DIVAC returning VALUE(DIVAC) type LVC_S_LACN,
                  FILL_BAPI_TABLES,
                  GET_REF returning VALUE(R_REF) type ZGF_ICO_RECHR-REF,
                  POST_INVOICE,
                  PRINT_INVOICE,
                  GET_ERRORS returning
                  VALUE(R_ERROR_TAB) type ABAPTXT255_TAB,
                  GET_PRDATA returning
                  VALUE(PR_REF) type ZGF_ICO_RECHR.
      private section.
        data: LINE type ABAPTXT255,
              ERROR_TAB type ABAPTXT255_TAB,
              FIELD like LINE.
        methods :  CHECK_VALIDITY.
    endclass.                    "lcl_ref DEFINITION
          CLASS lcl_ref IMPLEMENTATION
    class LCL_REF implementation.
      method GET_ERRORS.
        R_ERROR_TAB = ME->ERROR_TAB.
      endmethod.                    "get_errors
      method IS_VALID.
        IS_VALID = ME->VALID.
      endmethod.                    "is_valid
      method GET_PRDATA.
        PR_REF = L_REF.
      endmethod.                    "is_valid
      method PRINT_INVOICE.
        data: L_KUNNR type KNA1-KUNNR.
        data: L_ROW type ZGF_ICO_RECHR.
        call function 'OPEN_FORM'
         exporting
           APPLICATION                       = 'TX'
        ARCHIVE_INDEX                     =
        ARCHIVE_PARAMS                    =
           DEVICE                            = 'PRINTER'
           DIALOG                            = 'X'
             FORM                              = 'ZGF_INVOICE'
             LANGUAGE                          = SY-LANGU
         OPTIONS                           = is_options
         exceptions
             CANCELED                          = 1
             DEVICE                            = 2
             others                            = 12.
        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 function 'START_FORM'
         exporting
           ARCHIVE_INDEX          =
           FORM                   = 'ZGF_INVOICE'
           LANGUAGE               = SY-LANGU
         exceptions
           FORM                   = 1
           others                 = 8.
        if SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
        IF L_REF-TOTAL >= 0.
          IV_INVOICE = 'INVOICE  (COMCoE Recharge)'.
        ELSE.
          IV_INVOICE = 'Credit Memo  (COMCoE Recharge)'.
        ENDIF.
        call method ME->GET_PRDATA
          receiving
            PR_REF = L_ROW.
        L_KUNNR = L_ROW-CUSTFR.
        select single RCOMP ADRNR LAND1 ORT01
        into (IV_RCOMP, IV_ADRNR, IV_COMPLAND1, IV_COMPORT01)
        from T001 where BUKRS = L_ROW-CCFR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'INVOICE'
            ELEMENT = 'T3'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        IV_DOCDATE = P_BLDAT.
        IV_ORDNU = L_ROW-REF.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'DOCU'
            ELEMENT = 'T2'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        select single KUNNR STRAS NAME1 LAND1 ORT01 STCEG
        into
        (IV_CUSTNO, IV_CUSTADD, IV_CUSTNAME1, IV_CUSTLAND1, IV_CUSTCITY,
    IV_DOCVAT)
        from KNA1
        where KUNNR = L_KUNNR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'CUST'
            ELEMENT = 'T6'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        IV_CUSTNO = L_KUNNR.
        IV_CURR = L_ROW-CURR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'CUSTNO'
            ELEMENT = 'T4'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        data: L_VAR(21).
        concatenate P_DATEFR0(4) '/' P_DATEFR4(2) '/' P_DATEFR+6(2)
        '-' P_DATETO0(4) '/' P_DATETO4(2) '/' P_DATETO+6(2)
        into L_VAR.
        IV_PERDAT = L_VAR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'MAIN'
            ELEMENT = 'T1'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'FOOTER'
            ELEMENT = 'T5'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
    *CALL FUNCTION 'END_FORM'
    IMPORTING
      RESULT                         =
    EXCEPTIONS
      UNOPENED                       = 1
      BAD_PAGEFORMAT_FOR_PRINT       = 2
      SPOOL_ERROR                    = 3
    CODEPAGE                        = 4
      OTHERS                         = 5.
        call function 'END_FORM'
          exceptions
            UNOPENED = 1.
        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 function 'CLOSE_FORM'
          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.
      endmethod.                    "is_valid
      method GET_REF.
        R_REF = REF.
      endmethod.                    "get_ref
      method CONSTRUCTOR.
        L_REF = IM_REF.
        REF = IM_REF-REF.
        call method ME->CHECK_VALIDITY.
      endmethod.                    "constructor
      method GET_DIVA.
        DIVA-ISFOLDER = ''.
        if VALID <> 'X'.
          DIVA-N_IMAGE = ICON_NEGATIVE.
        else.
          DIVA-N_IMAGE = ICON_POSITIVE.
        endif.
      endmethod.                    "get_diva
      method GET_DIVAC.
        if V_ERROR1 = 'Y' or V_ERROR2 = 'Y'.
          DIVAC-N_IMAGE = ICON_RED_LIGHT.
        elseif V_ERROR1 = 'N' and V_ERROR2 = 'N'.
          DIVAC-N_IMAGE = ICON_GREEN_LIGHT.
        endif.
        DIVAC-U_N_IMAGE = 'X'.
      endmethod.                    "get_divac
      method CAN_POST.
        CAN = 'X'.
        call method ME->FILL_BAPI_TABLES.
      endmethod.                    "can_post
      method CHECK_VALIDITY.
    *Reference field must begin with M, Q, Y or J. Otherwise display an
    *error msg with text symbol TEXT-001 (ZGF_ICO_RECHR validation error –
    *Reference incorrect – rec.x) where x ist the numebr of the incorrect
    *record.
        data:  L_CHAR(1),
               L_REF1 type ZGF_ICO_RECHR-REF,
               L_ERR type OUTTAB_LINE_ERROR,
               L_NUM type N,
               L_KNB1 type KNB1,
               L_TBSL type TBSL,
               L_CSKS type CSKS,
               L_LFB1 type LFB1.
              l_flag(1).
        clear: L_CHAR, L_NUM, VALID.
        VALID = 'X'.
        L_REF1 = L_REF-REF.
        L_CHAR = L_REF1+0(1).
        if not ( L_CHAR = 'M'  or L_CHAR = 'Q'
                 or L_CHAR = 'Y' or L_CHAR = 'J').
         MESSAGE E398(00) WITH TEXT-001 ' ' ' ' ' '.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-001.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
        clear: L_CHAR, L_NUM.
        L_CHAR = L_REF1+1(1).
        L_NUM = L_CHAR.
        if not L_CHAR = '0'.
          if L_NUM = 0.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-001.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
        endif.
        clear: L_CHAR, L_NUM.
        L_CHAR = L_REF1+2(1).
        L_NUM = L_CHAR.
        if not L_CHAR = '0'.
          if L_NUM = 0.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-001.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
        endif.
        clear: L_CHAR, L_NUM.
        L_CHAR = L_REF1+3(1).
        L_NUM = L_CHAR.
        if not L_CHAR = '0'.
          if L_NUM = 0.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-001.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR-ERR_MESG to GT_ZGF_ICO_RECHR_ERRORS.
            VALID = 'F'.
          endif.
        endif.
        if not ( L_REF-FREQ = 'M' or L_REF-FREQ = 'Q' or L_REF-FREQ = 'Y').
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-002.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
        if not ( L_REF-CODE = 'A' or L_REF-CODE = 'B' or L_REF-CODE = 'C'
                 or L_REF-CODE = 'D' or L_REF-CODE = 'E'
                 or L_REF-CODE = 'F' ).
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-003.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
    *Customer FROM must not be flagged for deletion in KNB1. (KNB1-LOEVM
    *must be space), otherwise error message with TEXT-007. (ZGF_ICO_RECHR
    *validation error – From customer marked for deletion– rec.x) where x
    *ist the number of the incorrect record.
        select single * from KNB1 into L_KNB1
               where KUNNR = L_REF-CUSTFR.
        if SY-SUBRC = 0.
          if not L_KNB1-LOEVM is initial.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-007.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
          if not L_KNB1-SPERR  is initial.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-006.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
        endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKFRD.
       if not L_TBSL-KOART = 'D'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-008.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKFRS.
       if not L_TBSL-KOART = 'S'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-009.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
       if not L_REF-PLTFR is initial.
         select single * from CSKS into L_CSKS
         where ZZWERKS = L_REF-PKFRS.
         if SY-SUBRC <> 0.
           clear L_ERR.
           L_ERR = L_REF.
           L_ERR-ERR_MESG = TEXT-012.
           L_ERR-REC_NO = G_CNTR.
           append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
           append L_ERR-ERR_MESG to ERROR_TAB.
           VALID = 'F'.
         endif.
       endif.
        select single * from LFB1 into L_LFB1
               where LIFNR = L_REF-CUSTTO.
        if not L_LFB1-LOEVM is initial.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-018.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
        if not LFB1-SPERR is initial.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-019.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKTOK.
       if not L_TBSL-KOART = 'K'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-020.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKTOS.
       if not L_TBSL-KOART = 'S'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-021.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
        if not L_REF-TOTAL > 0.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-017.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
       return valid.
      endmethod.                    "check_validity
    --- Method Post Invoice Start ---
      method POST_INVOICE.
      endmethod.                    "post_invoice
    --- Method Post Invoice End ---
    --- Method Filling Bapi Tables Start ---
      method FILL_BAPI_TABLES.
    *---- Populating Bapi for Customer
        V_TOTAL = L_REF-TOTAL.
        perform FILL_BAPI_CUSTOMER.
        V_ERROR1 = 'N'.
        V_ERROR2 = 'N'.
        delete IT_ERROR where NODE_ID = L_SELECTED_NODE.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR  = SY-ULINE(30).
        append IS_ERROR to IT_ERROR.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR  = L_REF-REF.
        append IS_ERROR to IT_ERROR.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR  = SY-ULINE(30).
        append IS_ERROR to IT_ERROR.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR   = '*** Checking Customer Document ***'.
        append IS_ERROR to IT_ERROR.
        clear IS_ERROR.
    *---- Checking for 1st Document
        call function 'BAPI_ACC_DOCUMENT_CHECK'
          exporting
            DOCUMENTHEADER       = WA_DOCUMENTHEADER
          tables
            ACCOUNTGL            = LT_ACCOUNTGL
            ACCOUNTRECEIVABLE     =
            LT_ACCOUNTRECEIVABLE
            ACCOUNTTAX           = LT_ACCOUNTTAX
            CURRENCYAMOUNT       = LT_CURRENCYAMOUNT
            RETURN               = LT_RETURN.
        loop at LT_RETURN into WA_RETURN.
          if WA_RETURN-TYPE = 'E' or WA_RETURN-TYPE = 'A'.
            V_ERROR1 = 'Y'.
          endif.
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          concatenate WA_RETURN-TYPE WA_RETURN-MESSAGE into IS_ERROR-ERROR
            separated by '-'.
          append IS_ERROR to IT_ERROR.
        endloop.
    *--- Checking for 2nd Document
        if V_ERROR1 = 'N'.
    *---- Populating Bapi for Vendor
          L_REF-TOTAL = V_TOTAL.
          perform FILL_BAPI_VENDOR.
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          IS_ERROR-ERROR   = '*** Checking for Vendor Document ***'.
          append IS_ERROR to IT_ERROR.
          clear IS_ERROR.
          call function 'BAPI_ACC_DOCUMENT_CHECK'
            exporting
              DOCUMENTHEADER = WA_DOCUMENTHEADER2
            tables
              ACCOUNTGL      = LT_ACCOUNTGL2
              ACCOUNTPAYABLE = LT_ACCOUNTPAYABLE
              ACCOUNTTAX     = LT_ACCOUNTTAX2
              CURRENCYAMOUNT = LT_CURRENCYAMOUNT2
              RETURN         = LT_RETURN2.
          loop at LT_RETURN2 into WA_RETURN2.
            if WA_RETURN-TYPE = 'E' or WA_RETURN-TYPE = 'A'.
              V_ERROR2 = 'Y'.
            endif.
            IS_ERROR-NODE_ID = L_SELECTED_NODE.
            concatenate WA_RETURN2-TYPE WA_RETURN2-MESSAGE into
             IS_ERROR-ERROR separated by '-'.
            append IS_ERROR to IT_ERROR.
          endloop.
        endif.
    *--- CHECK WHETHER BOTH DOCUMENTS ARE CORRECT OR NOT returned SUCCESS
        if V_ERROR1 = 'N' and V_ERROR2 = 'N'.
    *--- Posting 1st Document - Customer
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          IS_ERROR-ERROR   = '*** Posting Customer Document ***'.
          append IS_ERROR to IT_ERROR.
          clear IS_ERROR.
          call function 'BAPI_ACC_DOCUMENT_POST'
            exporting
              DOCUMENTHEADER       = WA_DOCUMENTHEADER
            tables
              ACCOUNTGL            = LT_ACCOUNTGL
              ACCOUNTRECEIVABLE     =
              LT_ACCOUNTRECEIVABLE
              ACCOUNTTAX           = LT_ACCOUNTTAX
              CURRENCYAMOUNT       = LT_CURRENCYAMOUNT
              RETURN               = LT_RETURN.
          call function 'BAPI_TRANSACTION_COMMIT'.
          loop at LT_RETURN into WA_RETURN.
            IS_ERROR-NODE_ID = L_SELECTED_NODE.
           concatenate WA_RETURN-TYPE WA_RETURN-MESSAGE into IS_ERROR-ERROR
             separated by '-'.
            append IS_ERROR to IT_ERROR.
          endloop.
    *--- Posting 2nd Document - Vendor
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          IS_ERROR-ERROR   = '*** Posting Vendor Document ***'.
          append IS_ERROR to IT_ERROR.
          clear IS_ERROR.
          call function 'BAPI_ACC_DOCUMENT_POST'
            exporting
              DOCUMENTHEADER = WA_DOCUMENTHEADER2
            tables
              ACCOUNTGL      = LT_ACCOUNTGL2
              ACCOUNTPAYABLE = LT_ACCOUNTPAYABLE
              ACCOUNTTAX     = LT_ACCOUNTTAX2
              CURRENCYAMOUNT = LT_CURRENCYAMOUNT2
              RETURN         = LT_RETURN2.
          call function 'BAPI_TRANSACTION_COMMIT'.
          loop at LT_RETURN2 into WA_RETURN2.
            IS_ERROR-NODE_ID = L_SELECTED_NODE.
            concatenate WA_RETURN2-TYPE WA_RETURN2-MESSAGE into
             IS_ERROR-ERROR separated by '-'.
            append IS_ERROR to IT_ERROR.
          endloop.
        endif. "if V_ERROR1 = 'N' and V_ERROR2 = 'N'.
    *--- Setting colour of node.
        data:  LO_REF type ref to LCL_REF,
               IS_NODE_LAYOUT type LVC_S_LACN,
               L_NODE_TEXT type LVC_VALUE,
               WA_OREF type TY_REF.
        clear :IS_NODE_LAYOUT,L_NODE_TEXT, WA_OREF, LO_REF.
        create object LO_REF exporting IM_REF = LS_ZGF_ICO_RECHR.
        IS_NODE_LAYOUT = LO_REF->GET_DIVAC( ).
        read table GT_ZGF_ICO_RECHR into L_REF index L_SELECTED_NODE.
        L_NODE_TEXT = L_REF-REF.
        call method G_ALV_TREE->CHANGE_NODE
          exporting
            I_NODE_KEY     = L_SELECTED_NODE
            I_OUTTAB_LINE  = L_REF
            IS_NODE_LAYOUT = IS_NODE_LAYOUT
            I_NODE_TEXT    = L_NODE_TEXT
            I_U_NODE_TEXT  = 'X'
          exceptions
            NODE_NOT_FOUND = 1
            others         = 2.
        call method G_ALV_TREE->FRONTEND_UPDATE.
        call method CL_GUI_CFW=>FLUSH
          exceptions
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
      endmethod.                    "fill_int_tables
    endclass.                    "lcl_ref IMPLEMENTATION
          CLASS lcl_event_handler DEFINITION
    class LCL_EVENT_HANDLER definition.
      public section.
        class-methods : ON_NODE_CLICK for event
          NODE_DOUBLE_CLICK of CL_GUI_ALV_TREE
            importing NODE_KEY.
        methods: ON_FUNCTION_SELECTED
                   for event FUNCTION_SELECTED of CL_GUI_TOOLBAR
                     importing FCODE.
    endclass.                    "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    class LCL_EVENT_HANDLER implementation.
      method  ON_NODE_CLICK.
      endmethod.                    "on_node_click
      method ON_FUNCTION_SELECTED.
        data: LT_SELECTED_NODES type LVC_T_NKEY,
              L_RC              type C,
              L_CAN             type C,
              L_REC             type I,
              WA_OREF           type TY_REF,
              L_LINE            type SY-TABIX.
    Determine which line is selected
        call method G_ALV_TREE->GET_SELECTED_NODES
          changing
            CT_SELECTED_NODES = LT_SELECTED_NODES.
        call method CL_GUI_CFW=>FLUSH.
    remark: The user can not select more than one node since the
            default value of NODE_SELECTION_MODE is
            cl_gui_column_Tree=>NODE_SEL_MODE_SINGLE (see constructor).
        describe table LT_SELECTED_NODES lines L_REC.
        if L_REC = 0 and FCODE = 'ERROR'.
    *--- Show log for all if nothing is selected then.
          refresh LT_ERRORS.
          clear LT_ERRORS.
          loop at IT_ERROR into IS_ERROR.
            IS_ERRORS-LINE = IS_ERROR-ERROR.
            append IS_ERRORS to LT_ERRORS.
          endloop.
          call method G_LOGGER->SET_TEXT_AS_R3TABLE
            exporting
              TABLE = LT_ERRORS.
        endif.
        loop at  LT_SELECTED_NODES into L_SELECTED_NODE.
          clear : L_REF, WA_OREF.
          L_LINE = SY-TABIX.
          read table GT_OREF into WA_OREF index L_SELECTED_NODE.
          read table GT_ZGF_ICO_RECHR into L_REF index L_SELECTED_NODE.
          if SY-SUBRC = 0.
            case FCODE.
              when 'ERROR'.
                refresh LT_ERRORS.
                clear LT_ERRORS.
                loop at IT_ERROR into IS_ERROR where NODE_ID =
                                                      L_SELECTED_NODE.
                  IS_ERRORS-LINE = IS_ERROR-ERROR.
                  append IS_ERRORS to LT_ERRORS.
                endloop.
                call method G_LOGGER->SET_TEXT_AS_R3TABLE
                  exporting
                    TABLE = LT_ERRORS.
              when 'POST'.
                if L_LINE = 1.
                  if WA_OREF-O_REF->IS_VALID( ) = 'X'.
                    clear L_RC.
                    call function 'POPUP_TO_CONFIRM_STEP'
                      exporting
                        TEXTLINE1      = 'Do you want to post'  "(902)
                        TEXTLINE2      = '?'                    "(903)
                        TITEL          = 'Confirmation'         "(904)
                        CANCEL_DISPLAY = ' '
                      importing
                        ANSWER         = L_RC.
                  else.
                    call function 'POPUP_TO_INFORM'
                      exporting
                        TITEL = 'Select Another Record..'
                        TXT1  = 'Data Wrong,'
                        TXT2  = 'Posting Can Not be Done'.
                  endif.
                else.
                  L_RC = 'J'.
                endif.
                if L_RC eq 'J'.
    *---Post Invoice.
                  if WA_OREF-O_REF->CAN_POST( ) = 'X'.
                    call method WA_OREF-O_REF->POST_INVOICE.
    *---Printing Log.
                    refresh LT_ERRORS.
                    clear LT_ERRORS.
                    loop at IT_ERROR into IS_ERROR.
                      IS_ERRORS-LINE = IS_ERROR-ERROR.
                      append IS_ERRORS to LT_ERRORS.
                    endloop.
                    call method G_LOGGER->SET_TEXT_AS_R3TABLE
                      exporting
                        TABLE = LT_ERRORS.
                  endif.
                endif.
              when 'PRINT'.
                call method WA_OREF-O_REF->PRINT_INVOICE.
            endcase.
          else.
            message I000(0K) with 'Please select a node.'.
          endif.
        endloop.
      endmethod.                    "on_function_selected
    endclass.                    "lcl_event_handler IMPLEMENTATION
    START-OF-SELECTION.
    start-of-selection.
    end-of-selection.
      call screen 100.
    *&      Module  STATUS_0100  OUTPUT
    module STATUS_0100 output.
      set pf-status 'MAIN100'.
      set titlebar 'MAINTITLE'.
      if G_ALV_TREE is initial.
        perform INIT_TREE.
        call method CL_GUI_CFW=>FLUSH
          exceptions
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
        if SY-SUBRC ne 0.
         call function 'POPUP_TO_INFORM'
           exporting
             titel = 'Automation Queue failure'(801)
             txt1  = 'Internal error:'(802)
             txt2  = 'A method in the automation queue'(803)
             txt3  = 'caused a failure.'(804).
        endif.
      endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Form  init_tree
          text
    -->  p1        text
    <--  p2        text
    form INIT_TREE .
      data: L_TREE_CONTAINER_NAME(30) type C.
    *Reference tree
      L_TREE_CONTAINER_NAME = 'ZCONTAINER'.
      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_MULTIPLE
           NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
            ITEM_SELECTION      = 'X'
            NO_HTML_HEADER      = ''
            NO_TOOLBAR          = ''
        exceptions
            CNTL_ERROR                   = 1
            CNTL_SYSTEM_ERROR            = 2
            CREATE_ERROR                 = 3
            LIFETIME_ERROR               = 4
            ILLEGAL_NODE_SELECTION_MODE  = 5
            FAILED                       = 6
            ILLEGAL_COLUMN_NAME          = 7.
      if SY-SUBRC <> 0.
        message X208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    ****logger
      L_TREE_CONTAINER_NAME = 'ZLOGGER'.
      create object G_TEXT_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 object G_LOGGER
          exporting PARENT = G_TEXT_CONTAINER
          NAME = 'Error Log'.
      call method G_LOGGER->SET_READONLY_MODE.
    endlogger
      data L_HIERARCHY_HEADER type TREEV_HHDR.
      data: LT_LIST_COMMENTARY type SLIS_T_LISTHEADER,
            L_LOGO             type SDYDO_VALUE.
      data : WA_FIELDCATALOG type LVC_S_FCAT.
      perform BUILD_HIERARCHY_HEADER changing L_HIERARCHY_HEADER.
      perform BUILD_COMMENT using LT_LIST_COMMENTARY
                                  L_LOGO.
      clear : WA_FIELDCATALOG, GT_FIELDCATALOG.
    get fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          I_STRUCTURE_NAME = 'ZGF_ICO_RECHR'
        changing
          CT_FIELDCAT      = GT_FIELDCATALOG.
      loop at GT_FIELDCATALOG into WA_FIELDCATALOG.
        case WA_FIELDCATALOG-FIELDNAME.
          when 'REF'.
            WA_FIELDCATALOG-NO_OUT = 'X'.
        endcase.
        WA_FIELDCATALOG-OUTPUTLEN = 15.
        modify GT_FIELDCATALOG from WA_FIELDCATALOG.
      endloop.
      call method G_ALV_TREE->SET_TABLE_FOR_FIRST_DISPLAY
        exporting
          IT_LIST_COMMENTARY  = LT_LIST_COMMENTARY
          I_LOGO              = L_LOGO
         i_structure_name    = 'ZGF_ICO_RECHR'
          IS_HIERARCHY_HEADER = L_HIERARCHY_HEADER
        changing
          IT_FIELDCATALOG     = GT_FIELDCATALOG
          IT_OUTTAB           = GT_ZGF_ICO_RECHR. "table must be empty !
      perform CREATE_HIERARCHY.
      perform CHANGE_TOOLBAR.
      perform REGISTER_EVENTS.
      call method G_ALV_TREE->FRONTEND_UPDATE.
    endform.                    " init_tree
    *&      Form  build_hierarchy_header
    form BUILD_HIERARCHY_HEADER  changing
            P_HIERARCHY_HEADER type TREEV_HHDR.
      P_HIERARCHY_HEADER-HEADING = 'Reference Number'(300).
      P_HIERARCHY_HEADER-TOOLTIP = 'Reference numbers for invoices'(400).
      P_HIERARCHY_HEADER-WIDTH = 30.
      P_HIERARCHY_HEADER-WIDTH_PIX = ' '.
    endform.                    " build_hierarchy_header
    *&      Form  create_hierarchy
    form CREATE_HIERARCHY .
      clear : LS_ZGF_ICO_RECHR, L_LAST_KEY.
    §4a. Select data
      refresh GT_ZGF_ICO_RECHR.
      select * from ZGF_ICO_RECHR into table LT_ZGF_ICO_RECHR
       where FREQ in SO_FREQ
         and  REF in SO_REF.
      sort LT_ZGF_ICO_RECHR by REF.
    Note: The top level nodes do not correspond to a field of the
    output table. Instead we use data of the table to invent another
    hierarchy level above the levels that can be build by sorting.
    §4c. Add data to tree
      G_CNTR = 1.
    sort by oref->get_diva->image .
      loop at LT_ZGF_ICO_RECHR into LS_ZGF_ICO_RECHR.
        perform ADD_COMPLETE_LINE using  LS_ZGF_ICO_RECHR
                                          changing L_LAST_KEY.
        G_CNTR = G_CNTR + 1.
    perform add_node using ls_zgf_ico_rechr-ref
                      changing l_last_key.
      endloop.
    endform.                    " create_hierarchy
    *&      Module  USER_COMMAND_0100  INPUT
    module USER_COMMAND_0100 input.
      SAVE_OK = OKCODE.
      clear OKCODE.
      case SAVE_OK.
        when 'EXIT' or 'BACK' or 'CANC'.
          perform EXIT_PROGRAM.
        when others.
    §6. Call dispatch to process toolbar functions
          call method CL_GUI_CFW=>DISPATCH.
      endcase.
      call method CL_GUI_CFW=>FLUSH.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  exit_program
          text
    form EXIT_PROGRAM .
      call method G_CUSTOM_CONTAINER->FREE.
      leave to screen 0.
    endform.                    " exit_program
    *&      Form  add_complete_line
    form ADD_COMPLETE_LINE  using    P_LS_ZGF_ICO_RECHR type ZGF_ICO_RECHR
                                     P_RELAT_KEY type LVC_NKEY
                            changing P_NODE_KEY type LVC_NKEY.
      data: L_NODE_TEXT type LVC_VALUE,
            LO_REF type ref to LCL_REF,
            L_NODE_LAYOUT type LVC_S_LAYN.
    add leaf:
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set.
    Since these nodes will never get children they stay leaves
    (as intended).
      clear L_NODE_LAYOUT.
      create object LO_REF exporting IM_REF = P_LS_ZGF_ICO_RECHR.
      data : WA_OREF type TY_REF.
      clear WA_OREF.
      WA_OREF-O_REF = LO_REF.
      append WA_OREF to GT_OREF.
      L_NODE_LAYOUT = LO_REF->GET_DIVA( ).
      L_NODE_TEXT = P_LS_ZGF_ICO_RECHR-REF.
      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   = P_LS_ZGF_ICO_RECHR   "_REF
          I_NODE_TEXT      = L_NODE_TEXT
          IS_NODE_LAYOUT   = L_NODE_LAYOUT
        importing
          E_NEW_NODE_KEY   = P_NODE_KEY.
    endform.                    " add_complete_line
    *&      Form  add_node
    form ADD_NODE  using    P_REF
                   changing P_NODE_KEY type LVC_NKEY.
      clear L_NODE_LAYOUT.
      L_NODE_LAYOUT-ISFOLDER = ''.
      L_NODE_LAYOUT-N_IMAGE = ICON_POSITIVE.
      L_NODE_TEXT =  'Reference1'. " 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   = P_REF
          IS_NODE_LAYOUT   = L_NODE_LAYOUT
        importing
          E_NEW_NODE_KEY   = P_NODE_KEY.
    endform.                    " add_node
    *&      Form  register_events
    form REGISTER_EVENTS .
      data: LT_EVENTS type CNTL_SIMPLE_EVENTS,
            L_EVENT type CNTL_SIMPLE_EVENT,
            L_EVENT_RECEIVER type ref to LCL_EVENT_HANDLER.
      call method G_ALV_TREE->GET_REGISTERED_EVENTS
        importing
          EVENTS = LT_EVENTS.
    *NODE_DOUBLE_CLICK
      clear L_EVENT.
      move CL_GUI_COLUMN_TREE=>EVENTID_NODE_DOUBLE_CLICK to L_EVENT-EVENTID.
      append L_E

    Ok fine that can be acchived by setting the retention policy and by issuing delete obsolete command.That's perfect.If FRA is configured then even delete obsolete command is also not required.
    but i want to keep the last full backup for 15 days and archived logs only for one day.In this case can we set seperate retention policy for full backup and backup of archived logs
    for the time being i just want to modify my present existing OS script to acchive my task and i will conside changing RMAN script later on.Can u provide me the modified OS script so that my work gets finishes succesfully.
    Thank You...

  • Problem in ALV Tree

    Hello Friends,
    I am using ALV Tree to display a report.
    In this report for a particular input.2 nodes are cerated.
    On clicking on the 2nd node the details for the same are shown .
    However on clicking the 1st node , the system automatically logs off closing all the SAP sessions and even the SAP Logon pad.
    Suppose i am on executing the program on development server,even the sessions of test server are closed.
    Can anyone please help me in this.....
    its a bit urgent.
    i am attaching my code for reference.
    REPORT  ZPRPROUTOPERATIONS1                     .
    tables : mapl,t001w,zroutpromast.
    TYPE-POOLS: slis,kkblo.
    include <icon>.
    data : it_zrouteledtl like zrouteledtl occurs 0 with header line.
    data : it_zeledtl type zeledtl occurs 0 with header line.
    data : conv_sec(5) type c value '0.036'.
    types : begin of it_output2,
           Srno like zrouteledtl-srno,
           srno1 type p decimals 8,
           subgid like zrouteledtl-subgid,
           subopn like zrouteledtl-subopn,
           movetype type zeledtl-movetype,
           DESC type zeledtl-description,
           Add_desc like zrouteledtl-DESCRIPTION,
           Freq type p decimals 2,
           div_freq type p decimals 2,
           men type p decimals 2,
           offline(3),
           CT type p decimals 2,
           CW type p decimals 2,
           Ideal_ct type p decimals 2,
           ideal_cw type p decimals 2,
           A_trg type p decimals 2,
           b_Trg type p decimals 2,
           g_Trg type p decimals 2,
           p_Trg type p decimals 2,
           m_Trg type p decimals 2,
           t_Trg type p decimals 2,
           i_Trg type p decimals 2,
           Autocycle type p decimals 2,
           online_time type p decimals 2,
           offline_time type p decimals 2,
           online_p_time type p decimals 2,
           offline_p_time type p decimals 2,
           end of it_output2.
    *types : begin of it_output3,
          Srno like zrouteledtl-srno,
          mop_gid like zroutdetails-MOP_GID,
          MOp_opn like zroutdetails-MOP_OPN,
          sub_gid like zpromast-subgid,
          subopn like zpromast-subopn,
          DESC like zpromast-description,
          Add_desc like zroutdetails-ADD_INFO,
          Freq type p decimals 2,
          batch type p decimals 2,
          mix type p decimals 2,
          offline(3),
          CT type p decimals 2,
          CW type p decimals 2,
          Ideal_ct type p decimals 2,
          ideal_cw type p decimals 2,
          A_trg type p decimals 2,
          b_Trg type p decimals 2,
          g_Trg type p decimals 2,
          p_Trg type p decimals 2,
          m_Trg type p decimals 2,
          t_Trg type p decimals 2,
          i_Trg type p decimals 2,
          Autocycle type p decimals 2,
          online_time type p decimals 2,
          offline_time type p decimals 2,
          online_p_time type p decimals 2,
          offline_p_time type p decimals 2,
          end of it_output3.
    data : it_output type it_output2 occurs 0 with header line,
           it_output1 type it_output2 occurs 0 with header line,
           it_emptytab type standard table of it_output2 INITIAL SIZE 0.
    data : a_trg type f,b_trg type f,g_trg type f,p_trg type f,m_trg type f,t_trg type f,i_trg type f,
           autocycle type f,online_p_time type f,offline_p_time type f.
    data : ch1 type c,ch2.
    DATA: ok_code like sy-ucomm,           "OK-Code
          save_ok like sy-ucomm.
    data : ct_fieldcat type KKBLO_T_FIELDCAT.
    *ALV data declarations
    DATA: fieldcatalog  TYPE lvc_t_fcat WITH HEADER LINE.
    DATA: gd_fieldcat   TYPE lvc_t_fcat,
          gd_tab_group  TYPE slis_t_sp_group_alv,
          gd_layout     TYPE slis_layout_alv.
    *ALVtree data declarations
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    DATA: gd_tree             TYPE REF TO cl_gui_alv_tree,
          gd_hierarchy_header TYPE treev_hhdr,
          gd_report_title     TYPE slis_t_listheader,
          gd_logo             TYPE sdydo_value,
          gd_variant          TYPE disvariant.
    *Create container for alv-tree
    DATA: gd_tree_container_name(30) TYPE c,
          gd_custom_container        TYPE REF TO cl_gui_custom_container.
    *data mr_toolbar type ref to cl_gui_toolbar.  "Add to top include
    selection-screen begin of block start with frame title text-001.
    select-options: p_gid for zroutpromast-mop_gid obligatory no-extension no intervals,
                    p_opn for zroutpromast-mop_opn obligatory no-extension no intervals,
                    p_werks for t001w-werks obligatory no-extension no intervals.
    selection-screen end of block start.
    *selection-screen begin of block detail with frame title text-002.
    *parameter : radio1 radiobutton group dept default 'X',
               radio2 radiobutton group dept.
    *selection-screen end of block detail.
    include ZTEST_TOOLBAR_EVENT_RECEIVER.
    start-of-selection.
    ALVtree setup data
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
      PERFORM build_report_title USING gd_report_title gd_logo.
      PERFORM build_variant.
    Display ALVtree report
      call screen 100.
    *&      Form  data_retrieval
          text
    -->  p1        text
    <--  p2        text
    FORM data_retrieval .
      select * from zrouteledtl into table it_zrouteledtl where mop_gid in p_gid and
                                                                  mop_opn in p_opn
                                                                  and werks in p_werks.
      if sy-subrc ne 0.
      message i001(0) with 'No Records Found'.
      leave program.
      endif.
      select * from zeledtl into table it_zeledtl for all entries in it_zrouteledtl
                                                          where subgid = it_zrouteledtl-subgid
                                                          and subopn = it_zrouteledtl-subopn
                                                          and werks = it_zrouteledtl-werks.
      loop at it_zeledtl.
        it_output1-srno = it_zeledtl-srno.
        it_output1-srno1 = it_zeledtl-srno.
        it_output1-subgid = it_zeledtl-subgid.
        it_output1-subopn = it_zeledtl-subopn.
        it_output1-movetype = it_zeledtl-movetype.
        it_output1-desc = it_zeledtl-DESCRIPTION.
        it_output1-freq = it_zeledtl-frequency.
        it_output1-div_freq = it_zeledtl-div_freq.
        it_output1-men = it_zeledtl-men.
        it_output1-offline = it_zeledtl-offline1.
        it_output1-ct = it_zeledtl-cy_time * conv_sec.
        it_output1-cw = it_zeledtl-wc_time * conv_sec.
        it_output1-ideal_ct = it_zeledtl-cy_trg_time * conv_sec.
        it_output1-ideal_cw = it_zeledtl-wc_trg_time * conv_sec.
        if it_zeledtl-men = 0.
        it_output-autocycle = it_zeledtl-cy_time * conv_sec.
        endif.
        if it_zeledtl-men ne 0 and it_zeledtl-offline1 eq 'NO'
              and ( it_zeledtl-movetype eq 'A' or it_zeledtl-movetype eq 'C' ).
        case it_zeledtl-movetype.
              when 'A'.
                if it_zeledtl-SIM_AUTO = 'TRUE'.
                  ch2 = 0.
                else.
                  ch2 = 1.
                endif.
                it_output-online_p_time = ( it_zeledtl-autocycle * ch2 * conv_sec ) * it_zeledtl-frequency / it_zeledtl-div_freq.
              when 'C'.
                if it_zeledtl-sim5 = 'TRUE'.
                  ch1 = 0.
                else.
                  ch1 = 1.
                endif.
                it_output-online_p_time =  ( it_zeledtl-index5 * it_zeledtl-par_freq5 * ch1
    it_zeledtl-frequency * 10 ) / it_zeledtl-div_freq  .
            endcase.
          elseif it_zeledtl-men ne 0 and it_zeledtl-offline1 eq 'YES'
                  and ( it_zeledtl-movetype eq 'A' or it_zeledtl-movetype eq 'C' ).
            case it_zeledtl-movetype.
              when 'A'.
                if it_zeledtl-SIM_AUTO = 'TRUE'.
                  ch2 = 0.
                else.
                  ch2 = 1.
                endif.
                it_output1-offline_p_time = ( it_zeledtl-autocycle * ch2 * conv_sec ) * it_zeledtl-frequency / it_zeledtl-div_freq.
              when 'C'.
                if it_zeledtl-sim5 = 'TRUE'.
                  ch1 = 0.
                else.
                  ch1 = 1.
                endif.
                it_output-offline_p_time =  ( it_zeledtl-index5 * it_zeledtl-par_freq5 * ch1
    it_zeledtl-frequency * 10 ) / it_zeledtl-div_freq  .
            endcase.
          endif.
          it_output1-a_trg = it_zeledtl-TARGET_A * conv_sec.
          it_output1-b_trg = it_zeledtl-target_B * conv_sec.
          it_output1-g_trg = it_zeledtl-TARGET_G * conv_sec.
          it_output1-p_trg = it_zeledtl-TARGET_P * conv_sec.
          it_output1-M_trg = it_zeledtl-TARGET_M * conv_sec.
          it_output1-t_trg = it_zeledtl-TARGET_T * conv_sec.
          it_output1-i_trg = it_zeledtl-TARGET_I * conv_sec.
        append it_output1.
      endloop.
      sort it_output1 ascending by subgid subopn srno1.
      clear ch1.
      loop at it_zrouteledtl.
        move-corresponding it_zrouteledtl to it_output.
        select single description from zpromast into it_output-desc
                                      where subgid = it_zrouteledtl-subgid and
                                      subopn = it_zrouteledtl-subopn and
                                      werks in p_werks.
        it_output-add_desc = it_zrouteledtl-description.
        it_output-freq = it_zrouteledtl-frequency.
        it_output-div_freq = it_zrouteledtl-div_freq.
        it_output-men = it_zrouteledtl-men.
        it_output-ct = it_zrouteledtl-cy_time * conv_sec.
        it_output-cw = it_zrouteledtl-wc_time * conv_sec.
        it_output-ideal_ct = it_zrouteledtl-cy_trg_time * conv_sec.
        it_output-ideal_cw = it_zrouteledtl-wc_trg_time * conv_sec.
        if it_zrouteledtl-offline1 = '1'.
          it_output-offline = 'No'.
        else.
          it_output-offline = 'Yes'.
        endif.
        append it_output.
      endloop.
      loop at it_output.
        if it_output-offline = 'Yes'.
        ch1 = 0.
        else.
        ch1 = 1.
        endif.
        loop at it_output1 where subgid = it_output-subgid and
                                 subopn = it_output-subopn.
          a_trg = A_trg + it_output1-A_trg.
          b_Trg = b_Trg + it_output1-b_Trg.
          g_Trg = g_Trg + it_output1-g_Trg.
          p_Trg = p_Trg + it_output1-p_Trg.
          m_Trg = m_Trg + it_output1-m_Trg.
          t_Trg = t_Trg + it_output1-t_Trg.
          i_Trg = i_Trg + it_output1-i_Trg.
          autocycle = autocycle + it_output1-Autocycle.
          online_p_time = online_p_time + it_output1-online_p_time.
          offline_p_time = offline_p_time + it_output1-offline_p_time.
        endloop.
          it_output-autocycle = ( autocycle * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-a_trg = ( a_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-b_trg = ( b_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-g_trg = ( g_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-p_trg = ( p_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-m_trg = ( m_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-t_trg = ( t_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-i_trg = ( i_trg * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-online_time = ( it_output-ct - it_output-autocycle ) * ch1.
          it_output-offline_time = ( it_output-ct - it_output-cw ) + it_output-autocycle.
          it_output-online_p_time = ( online_p_time * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          it_output-offline_p_time = ( offline_p_time * ch1 * it_output-freq ) / it_output-div_freq / it_output-men.
          clear : a_trg,b_trg,g_trg,p_trg,m_trg,t_trg,i_trg,online_p_time,offline_p_time,ch1,ch2,it_zeledtl,
                  autocycle,online_p_time,offline_p_time,zroutpromast.
        modify it_output.
      endloop.
    ENDFORM.                    " data_retrieval
    *&      Form  build_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcatalog .
    Please not there are a number of differences between the structure of
    ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
    For example the field seltext_m is replace by scrtext_m in ALVtree.
      DATA: COL_POS TYPE I VALUE 0.
      fieldcatalog-fieldname   = 'SRNO'.
      fieldcatalog-SCRTEXT_L   = 'Sr No.'.
      fieldcatalog-SCRTEXT_m   = 'Sr No.'.
      fieldcatalog-SCRTEXT_s   = 'Sr No.'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'SUBGID'.           "Field name in itab
      fieldcatalog-SCRTEXT_L   = 'Sub Opn GID'.  "Column text
      fieldcatalog-SCRTEXT_m   = 'Sub Opn GID'.  "Column text
      fieldcatalog-SCRTEXT_s   = 'Sub Opn GID'.  "Column text
      fieldcatalog-col_pos     = COL_POS.     "Column position
      fieldcatalog-outputlen   = 15.                "Column width
      fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
      fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
    fieldcatalog-do_sum      = 'X'.              "Sum Column?
    fieldcatalog-no_zero     = 'X'.              "Don't display if zero
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'SUBOPN'.
      fieldcatalog-SCRTEXT_L   = 'Sub Opn'.
      fieldcatalog-SCRTEXT_m   = 'Sub Opn'.
      fieldcatalog-SCRTEXT_s   = 'Sub Opn'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
      fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'MOVETYPE'.
      fieldcatalog-SCRTEXT_L   = 'Movetype'.
      fieldcatalog-SCRTEXT_m   = 'Movetype'.
      fieldcatalog-SCRTEXT_s   = 'Movetype'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'DESC'.
      fieldcatalog-SCRTEXT_L   = 'Description'.
      fieldcatalog-SCRTEXT_m   = 'Description'.
      fieldcatalog-SCRTEXT_s   = 'Description'.
      fieldcatalog-outputlen   = 600.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'ADD_DESC'.
      fieldcatalog-SCRTEXT_L   = 'Add. Description'.
      fieldcatalog-SCRTEXT_m   = 'Add. Description'.
      fieldcatalog-SCRTEXT_s   = 'Add. Description'.
      fieldcatalog-outputlen   = 100.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'FREQ'.
      fieldcatalog-SCRTEXT_L   = 'Frequency'.
      fieldcatalog-SCRTEXT_m   = 'Frequency'.
      fieldcatalog-SCRTEXT_s   = 'Frequency'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'DIV_FREQ'.
      fieldcatalog-SCRTEXT_L   = 'Div Freq'.
      fieldcatalog-SCRTEXT_m   = 'Div Freq'.
      fieldcatalog-SCRTEXT_s   = 'Div Freq'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'MEN'.
      fieldcatalog-SCRTEXT_L   = 'Men'.
      fieldcatalog-SCRTEXT_m   = 'Men'.
      fieldcatalog-SCRTEXT_s   = 'Men'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
    COL_POS = COL_POS + 1.
    fieldcatalog-fieldname   = 'BATCH'.
    fieldcatalog-SCRTEXT_L   = 'Batch/Div Freq'.
    fieldcatalog-SCRTEXT_m   = 'Batch/Div Freq'.
    fieldcatalog-SCRTEXT_s   = 'Batch/Div Freq'.
    fieldcatalog-outputlen   = 15.
    fieldcatalog-col_pos     = COL_POS.
    APPEND fieldcatalog TO gd_fieldcat.
    CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'OFFLINE'.
      fieldcatalog-SCRTEXT_L   = 'Offline'.
      fieldcatalog-SCRTEXT_m   = 'Offline'.
      fieldcatalog-SCRTEXT_s   = 'Offline'.
      fieldcatalog-outputlen   = 6.
      fieldcatalog-col_pos     = COL_POS.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'CT'.
      fieldcatalog-SCRTEXT_L   = 'Cycle Time'.
      fieldcatalog-SCRTEXT_m   = 'Cycle Time'.
      fieldcatalog-SCRTEXT_s   = 'Cycle Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'CW'.
      fieldcatalog-SCRTEXT_L   = 'Work Content'.
      fieldcatalog-SCRTEXT_m   = 'Work Content'.
      fieldcatalog-SCRTEXT_s   = 'Work Content'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'IDEAL_CT'.
      fieldcatalog-SCRTEXT_L   = 'Ideal CT'.
      fieldcatalog-SCRTEXT_m   = 'Ideal CT'.
      fieldcatalog-SCRTEXT_s   = 'Ideal CT'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'IDEAL_CW'.
      fieldcatalog-SCRTEXT_L   = 'Ideal CW'.
      fieldcatalog-SCRTEXT_m   = 'Ideal CW'.
      fieldcatalog-SCRTEXT_s   = 'Ideal CW'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'A_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target A'.
      fieldcatalog-SCRTEXT_m   = 'Target A'.
      fieldcatalog-SCRTEXT_s   = 'Target A'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'B_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target B'.
      fieldcatalog-SCRTEXT_m   = 'Target B'.
      fieldcatalog-SCRTEXT_s   = 'Target B'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'G_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target G'.
      fieldcatalog-SCRTEXT_m   = 'Target G'.
      fieldcatalog-SCRTEXT_s   = 'Target G'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'P_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target P'.
      fieldcatalog-SCRTEXT_m   = 'Target P'.
      fieldcatalog-SCRTEXT_s   = 'Target P'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'M_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target M'.
      fieldcatalog-SCRTEXT_m   = 'Target M'.
      fieldcatalog-SCRTEXT_s   = 'Target M'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'T_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target T'.
      fieldcatalog-SCRTEXT_m   = 'Target T'.
      fieldcatalog-SCRTEXT_s   = 'Target T'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'I_TRG'.
      fieldcatalog-SCRTEXT_L   = 'Target I'.
      fieldcatalog-SCRTEXT_m   = 'Target I'.
      fieldcatalog-SCRTEXT_s   = 'Target I'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'AUTOCYCLE'.
      fieldcatalog-SCRTEXT_L   = 'AutoCycle'.
      fieldcatalog-SCRTEXT_m   = 'AutoCycle'.
      fieldcatalog-SCRTEXT_s   = 'AutoCycle'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'ONLINE_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Online Time'.
      fieldcatalog-SCRTEXT_m   = 'Online Time'.
      fieldcatalog-SCRTEXT_s   = 'Online Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'OFFLINE_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Offline Time'.
      fieldcatalog-SCRTEXT_m   = 'Offline Time'.
      fieldcatalog-SCRTEXT_s   = 'Offline Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'ONLINE_P_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Online Process Time'.
      fieldcatalog-SCRTEXT_m   = 'Online Process Time'.
      fieldcatalog-SCRTEXT_s   = 'Online Process Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      COL_POS = COL_POS + 1.
      fieldcatalog-fieldname   = 'OFFLINE_P_TIME'.
      fieldcatalog-SCRTEXT_L   = 'Offline Process Time'.
      fieldcatalog-SCRTEXT_m   = 'Offline Process Time'.
      fieldcatalog-SCRTEXT_s   = 'Offline Process Time'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = COL_POS.
      fieldcatalog-do_sum      = 'X'.
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
    ENDFORM.                    " build_fieldcatalog
    *&      Form  build_layout
          text
    -->  p1        text
    <--  p2        text
    FORM build_layout .
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
      gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    ENDFORM.                    " build_layout
    *&      Form  build_hierarchy_header
          text
         <--P_GD_HIERARCHY_HEADER  text
    FORM build_hierarchy_header CHANGING
                                        p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Drill Down For Detail'(022).
      p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                    " build_hierarchy_header
    *&      Form  build_report_title
          text
         -->P_GD_REPORT_TITLE  text
         -->P_GD_LOGO  text
    FORM build_report_title  using
                     pt_report_title  TYPE slis_t_listheader
                     pa_logo TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader,
            ld_date(10) TYPE c,
            string1 type string,string2 type string.
    List Heading Line(TYPE H)
    concatenate 'Material: ' p_matnr-low into string1 separated by space.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
      ls_line-key  = 'MOST Operation'.
      concatenate p_gid-low p_opn-low into string2 separated by space.
      ls_line-info = string2.
      APPEND ls_line TO pt_report_title.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Text'.
      select single DESCRIPTION from zroutpromast into string1 where mop_gid = p_gid-low
                                                               and mop_opn = p_opn-low
                                                               and werks = p_werks-low.
      ls_line-info = string1.
      APPEND ls_line TO pt_report_title.
    ls_line-typ  = 'S'.
    ls_line-key  = 'Routing Counter:'.
    ls_line-info = counter.
    APPEND ls_line TO pt_report_title.
    Status Line(TYPE S)
      ld_date(2) = sy-datum+6(2).
      ld_date+2(1) = '/'.
      ld_date3(2) = sy-datum4(2).
      ld_date+5(1) = '/'.
      ld_date+6(4) = sy-datum(4).
      ls_line-typ  = 'S'.
      ls_line-key  = 'Date'.
      ls_line-info = ld_date.
      APPEND ls_line TO pt_report_title.
    Action Line(TYPE A)
    CLEAR ls_line.
    ls_line-typ  = 'A'.
    CONCATENATE 'Report: ' sy-repid INTO ls_line-info  SEPARATED BY space.
    APPEND ls_line TO pt_report_title.
    ENDFORM.                    " build_report_title
    *&      Form  build_variant
          text
    -->  p1        text
    <--  p2        text
    FORM build_variant .
      gd_variant-report = sy-repid.
    ENDFORM.                    " build_variant
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'STATUS1'.
      SET TITLEBAR 'ZTITLE'.
      IF gd_tree IS INITIAL.
    Create ALVtree (must be performed within screen PBO module)
        PERFORM create_alvtree_container.
        PERFORM create_object_in_container.
        PERFORM create_empty_alvtree_control.
        perform change_toolbar.
        PERFORM create_alvtree_hierarchy.
      ENDIF.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      case sy-ucomm.
        when 'EXIT' or 'BACK' or 'CANC'.
          call method gd_tree->free.
          leave program.
        when others.
          call method cl_gui_cfw=>dispatch.
      endcase.
      clear ok_code.
      call method cl_gui_cfw=>flush.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  create_alvtree_container
          text
    -->  p1        text
    <--  p2        text
    FORM create_alvtree_container .
      gd_tree_container_name = 'SCREEN_CONTAINER'.
      create object gd_custom_container
          exporting
                container_name = gd_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'.
      endif.
    ENDFORM.                    " create_alvtree_container
    *&      Form  create_object_in_container
          text
    -->  p1        text
    <--  p2        text
    FORM create_object_in_container .
      create object gd_tree
          exporting
              parent              = gd_custom_container
              node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
              item_selection      = 'X'
              no_html_header      = ''
              no_toolbar          = ''
          exceptions
              cntl_error                   = 1
              cntl_system_error            = 2
              create_error                 = 3
              lifetime_error               = 4
              illegal_node_selection_mode  = 5
              failed                       = 6
              illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.
      endif.
    ENDFORM.                    " create_object_in_container
    *&      Form  create_empty_alvtree_control
          text
    -->  p1        text
    <--  p2        text
    FORM create_empty_alvtree_control .
      CLEAR: it_emptytab.
      REFRESH: it_emptytab.
      CALL METHOD gd_tree->set_table_for_first_display
         EXPORTING
                   is_hierarchy_header  = gd_hierarchy_header
                   it_list_commentary   = gd_report_title
                  i_logo               = gd_logo
                  i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = gd_variant
         CHANGING
                   it_outtab            =  it_emptytab      "Must be empty
                   it_fieldcatalog      =  gd_fieldcat.
    ENDFORM.                    " create_empty_alvtree_control
    *&      Form  create_alvtree_hierarchy
          text
    -->  p1        text
    <--  p2        text
    FORM create_alvtree_hierarchy .
      data: ls_sflight type sflight,
              lt_sflight type sflight occurs 0.
      data: ld_mop_gid_key type lvc_nkey,
            ld_mop_opn_key type lvc_nkey.
      loop at it_output.
        perform add_ekko_node using      it_output
                                changing ld_mop_gid_key.
        loop at it_output1 where subgid eq it_output-subgid
                                 and subopn eq it_output-subopn.
          perform add_ekpo_line using      it_output1
                                           ld_mop_gid_key
                                  changing ld_mop_opn_key.
        endloop.
      endloop.
    calculate totals
      call method gd_tree->update_calculations.
    this method must be called to send the data to the frontend
      call method gd_tree->frontend_update.
    ENDFORM.                    " create_alvtree_hierarchy
    *&      Form  add_ekko_node
          text
         -->P_IT_OUTPUT  text
         -->P_2478   text
         <--P_LD_MOP_GID_KEY  text
    FORM add_ekko_node  USING  ps_output like it_output
                               VALUE(p_relate_key)
                        CHANGING p_node_key.
      data: ld_node_text type lvc_value,
             ls_sflight type sflight.
      data : text128(128).
    Set item-layout
      concatenate ps_output-subgid ps_output-subopn into text128 separated by space.
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = text128.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_output
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    ENDFORM.                    " add_ekko_node
    *&      Form  add_ekpo_line
          text
         -->P_IT_OUTPUT1  text
         -->P_LD_MOP_GID_KEY  text
         <--P_LD_MOP_OPN_KEY  text
    FORM add_ekpo_line  USING    Ps_OUTPUT1 like it_output1
                                 value(p_relate_key)
                        CHANGING p_node_key.
    data: ld_node_text type lvc_value,
          ls_sflight type sflight.
    data : text128(128).
    concatenate ps_output1-srno ps_output1-movetype into text128 separated by space.
    Set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = text128.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_output1
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    ENDFORM.                    " add_ekpo_line
    *&      Form  change_toolbar
          text
    -->  p1        text
    <--  p2        text
    FORM change_toolbar .
    get toolbar control
      call method gd_tree->get_toolbar_object
              importing
                  er_toolbar = mr_toolbar.
      check not mr_toolbar is initial.
    add seperator to toolbar
      call method mr_toolbar->add_button
              exporting
                  fcode     = ''
                  icon      = ''
                  butn_type = cntb_btype_sep
                  text      = ''
                  quickinfo = 'This is a Seperator'.         "#EC NOTEXT
    add Standard Button to toolbar (for Delete Subtree)
      call method mr_toolbar->add_button
              exporting
                  fcode     = 'EXPORT'           "Function code of button
                  icon      = '@49@'             "Icon ID (see )
                  butn_type = cntb_btype_button  "Button type
                  text      = ''                 "Button text
                  quickinfo = 'Download To Excel'.  "Quick info text
    add Dropdown Button to toolbar (for Insert Line)
    call method mr_toolbar->add_button
             exporting
                 fcode     = 'INSERT_LC'         "Function code of button
                 icon      = '@17@'              "Icon ID (see )
                 butn_type = cntb_btype_dropdown "Button type
                 text      = ''                  "Button text
                 quickinfo = 'Insert Line'.      "Quick info text
    set event-handler for toolbar-control
      data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
      create object toolbar_event_receiver.
      set handler toolbar_event_receiver->on_function_selected
                                                          for mr_toolbar.
      set handler toolbar_event_receiver->on_toolbar_dropdown
                                                          for mr_toolbar.
    ENDFORM.                    " change_toolbar
    Edited by: Darshan Shah on Jan 2, 2008 1:31 PM

    Gui patch was not available on my pc

  • Event double -click doens't work

    Dear All,
    Pls help event double -click doens't work.
    What can the reason be for it ?
    Regards
    Ilhan
    data tree1 type ref to cl_gui_alv_tree.
    data mr_toolbar type ref to cl_gui_toolbar.
    include <icon>.
    data: gt_sflight      type ZQMCOMP occurs 0,      "Output-Table
          gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
          ok_code like sy-ucomm.           "OK-Code
    *  TREE_EVENT_RECEIVER                                                 *
    class tree_event_receiver definition.
      public section.
        methods on_doubleclick
         for event link_click of cl_gui_alv_tree
          importing node_key fieldname.
    ENDCLASS.                    "lcl_handler DEFINITION
    *       CLASS tree_event_receiver IMPLEMENTATION
    class tree_event_receiver implementation.
      METHOD on_doubleclick.
        MESSAGE I000(38) WITH fieldname.
      ENDMETHOD.                    "on_doubleclick
    endclass.
    start-of-selection.
    end-of-selection.
    call screen 100.
    *&      Module  PBO  OUTPUT
    *       process before output
    module pbo output.
      set pf-status 'MAIN100'.
      if tree1 is initial.
        perform init_tree.
      endif.
      call method cl_gui_cfw=>flush.
    endmodule.                             " PBO  OUTPUT
    *&      Module  PAI  INPUT
    *       process after input
    module pai input.
      case ok_code.
        when 'EXIT' or 'BACK' or 'CANC'.
          perform exit_program.
        when others.
          call method cl_gui_cfw=>dispatch.
      endcase.
      clear ok_code.
      call method cl_gui_cfw=>flush.
    endmodule.                             " PAI  INPUT
    *&      Form  build_fieldcatalog
    *       build fieldcatalog for structure sflight
    form build_fieldcatalog.
      data: ls_fieldcatalog type lvc_s_fcat.
      ls_fieldcatalog-fieldname = 'DUNS'.
      ls_fieldcatalog-col_pos  = 7.
      ls_fieldcatalog-coltext  = 'Duns'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'MONAT'.
      ls_fieldcatalog-col_pos  = 8.
      ls_fieldcatalog-coltext  = 'Monat'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'ZE'.
      ls_fieldcatalog-col_pos  = 13.
      ls_fieldcatalog-coltext  = 'Ze'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'MATKOSTEN'.
      ls_fieldcatalog-col_pos  = 14.
      ls_fieldcatalog-coltext  = 'Mat.Kosten'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'ANTEIL'.
      ls_fieldcatalog-col_pos  = 15.
      ls_fieldcatalog-coltext  = 'Anteil'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'GESMAT'.
      ls_fieldcatalog-col_pos  = 16.
      ls_fieldcatalog-coltext  = 'Ges.Mat'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'GESLOH'.
      ls_fieldcatalog-col_pos  = 17.
      ls_fieldcatalog-coltext  = 'Ges.Lohn'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      clear ls_fieldcatalog.
      ls_fieldcatalog-fieldname = 'GESAMT'.
      ls_fieldcatalog-col_pos  = 19.
      ls_fieldcatalog-coltext  = 'Gesamt'.
      APPEND ls_fieldcatalog TO gt_fieldcatalog.
      call function 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name = 'ZQMCOMP'
           CHANGING
                ct_fieldcat      = gt_fieldcatalog.
    endform.                               " build_fieldcatalog
    *&      Form  build_hierarchy_header
    *       build hierarchy-header-information
    *      -->P_L_HIERARCHY_HEADER  strucxture for hierarchy-header
    form build_hierarchy_header changing
                                   p_hierarchy_header type treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy-Kopf'.            "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'Hierarchy-Kopf !'.
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    endform.                               " build_hierarchy_header
    *&      Form  exit_program
    *       free object and leave program
    form exit_program.
      call method tree1->free.
      leave program.
    endform.                               " exit_program
    *&      Form  build_header
    *       build table for html_header
    *  -->  p1        text
    *  <--  p2        text
    form build_comment using
          pt_list_commentary type slis_t_listheader
          p_logo             type sdydo_value.
      data: ls_line type slis_listheader.
      clear ls_line.
      ls_line-typ  = 'H'.
      ls_line-info = 'LIBOLO '.
      append ls_line to pt_list_commentary.
      clear ls_line.
      clear ls_line.
      ls_line-typ  = 'A'.
      ls_line-info = 'Liste'.
      append ls_line to pt_list_commentary.
    *  p_logo = 'ENJOYSAP_LOGO'.
    endform.
    *       FORM create_hierarchy                                         *
    FORM create_hierarchy.
      data: ls_sflight type ZQMCOMP,
            lt_sflight type ZQMCOMP occurs 0.
    * get data
      select * from ZQMCOMP into table lt_sflight.
    *  sort lt_sflight by carrid connid fldate.
    * add data to tree
      data: l_carrid_key type lvc_nkey,
            l_connid_key type lvc_nkey,
            l_last_key type lvc_nkey.
      loop at lt_sflight into ls_sflight.
        on change of ls_sflight-KUNDE.
          perform add_carrid_line using    ls_sflight
                                  changing l_carrid_key.
        endon.
        on change of ls_sflight-MONAT.
          perform add_connid_line using    ls_sflight
                                           l_carrid_key
                                  changing l_connid_key.
        endon.
        perform add_complete_line using  ls_sflight
                                         l_connid_key
                                changing l_last_key.
      endloop.
    * calculate totals
      call method tree1->update_calculations.
    * this method must be called to send the data to the frontend
      call method tree1->frontend_update.
    endform.                               " create_hierarchy
    *&      Form  add_carrid_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    form add_carrid_line using     ps_sflight type ZQMCOMP
                 p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_sflight type ZQMCOMP.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3P@'.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      append ls_item_layout to lt_item_layout.
    * add node
      l_node_text =  ps_sflight-KUNDE.
      call method tree1->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
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                               " add_carrid_line
    *&      Form  add_connid_line
    *       add hierarchy-level 2 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    form add_connid_line using     ps_sflight type ZQMCOMP
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_sflight type sflight.
    * set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3Y@'.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensified.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      append ls_item_layout to lt_item_layout.
    * add node
      l_node_text =  ps_sflight-MONAT.
      call method tree1->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
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                               " add_connid_line
    *&      Form  add_cmplete_line
    *       add hierarchy-level 3 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    form add_complete_line using   ps_sflight type ZQMCOMP
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value.
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      append ls_item_layout to lt_item_layout.
      l_node_text =  ps_sflight-QMART.
      call method tree1->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
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                               " add_complete_line
    *&      Form  register_events
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form register_events.
      data: lt_events type cntl_simple_events,
            l_event type cntl_simple_event.
      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_context_men_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_click.
      append L_EVENT to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      append L_EVENT to lt_events.
    * set Handler
      data: l_event_receiver type ref to tree_event_receiver.
      create object l_event_receiver.
      set handler l_event_receiver->on_doubleclick for tree1.
      call method tree1->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.
    endform.                               " register_events
    *&      Form  change_toolbar
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form change_toolbar.
    * get toolbar control
      call method tree1->get_toolbar_object
              importing
                  er_toolbar = mr_toolbar.
      check not mr_toolbar is initial.
    * add seperator to toolbar
      call method mr_toolbar->add_button
              exporting
                  fcode     = ''
                  icon      = ''
                  butn_type = cntb_btype_sep
                  text      = ''
                  quickinfo = 'This is a Seperator'.            "#EC NOTEXT
    * add Standard Button to toolbar (for Delete Subtree)
      call method mr_toolbar->add_button
              exporting
                  fcode     = 'DELETE'
                  icon      = '@18@'
                  butn_type = cntb_btype_button
                  text      = ''
                  quickinfo = 'Delete subtree'.                 "#EC NOTEXT
    * add Dropdown Button to toolbar (for Insert Line)
      call method mr_toolbar->add_button
              exporting
                  fcode     = 'INSERT_LC'
                  icon      = '@17@'
                  butn_type = cntb_btype_dropdown
                  text      = ''
                  quickinfo = 'Insert Line'.                    "#EC NOTEXT
    endform.                               " change_toolbar
    *&      Form  init_tree
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_tree.
    * create fieldcatalog for structure sflight
      perform build_fieldcatalog.
    * 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'.
      if sy-batch is initial.
        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.
        if sy-subrc <> 0.
          message x208(00) with 'ERROR'.                        "#EC NOTEXT
        endif.
      endif.
    * create tree control
      create object tree1
        exporting
            parent              = l_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        exceptions
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    * create Hierarchy-header
      data l_hierarchy_header type treev_hhdr.
      perform build_hierarchy_header changing l_hierarchy_header.
    * create info-table for html-header
      data: lt_list_commentary type slis_t_listheader,
            l_logo             type sdydo_value.
      perform build_comment using
                     lt_list_commentary
                     l_logo.
    * repid for saving variants
      data: ls_variant type disvariant.
      ls_variant-report = sy-repid.
    * create emty tree-control
      call method tree1->set_table_for_first_display
         exporting
                   I_STRUCTURE_NAME     = 'ZQMCOMP'
                   is_hierarchy_header  = l_hierarchy_header
                   it_list_commentary   = lt_list_commentary
    *               i_logo               = l_logo
                   i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = ls_variant
         changing
                   it_outtab            = gt_sflight "table must be emty !!
                  it_fieldcatalog      = gt_fieldcatalog.
    * create hierarchy
      perform create_hierarchy.
    * add own functioncodes to the toolbar
      perform change_toolbar.
    * register events
      perform register_events.
    * adjust column_width
      call method tree1->COLUMN_OPTIMIZE.
    ENDFORM.                    " init_tree

    Hi,
    to do so, you need to declare those fields in the form CREATE_HIERARCHY.
    For example, to add FLDATE node, you should do:
        ON CHANGE OF LS_SFLIGHT-CARRID.
          PERFORM ADD_CARRID_LINE USING    LS_SFLIGHT
                                  CHANGING L_CARRID_KEY.
        ENDON.
        ON CHANGE OF LS_SFLIGHT-CONNID.
          PERFORM ADD_CONNID_LINE USING    LS_SFLIGHT
                                           L_CARRID_KEY
                                  CHANGING L_CONNID_KEY.
        ENDON.
        ON CHANGE OF LS_SFLIGHT-FLDATE.
          PERFORM ADD_FLDATE_LINE USING    LS_SFLIGHT
                                           L_CONNID_KEY
                                  CHANGING L_FLDATE_KEY.
        ENDON.
        ON CHANGE OF LS_SFLIGHT-PRICE.
          PERFORM ADD_PRICE_LINE USING     LS_SFLIGHT
                                           L_FLDATE_KEY
                                  CHANGING L_PRICE_KEY.
        ENDON.
    and then create the new FORMS PERFORM ADD_PRICE_LINE and
    PERFORM ADD_FLDATE_LINE  by copy of the existent
    PERFORM ADD_CONNID_LINE and change the  L_NODE_TEXT in the form.
    I suposed you are new to ALV's, so i have a sugestion for you.
    Instead of  CL_GUI_ALV_TREE try to use some examples of CL_GUI_ALV_TREE_SIMPLE. It's much more simple to understand and to work with. For example Report BCALV_TREE_SIMPLE_DEMO.
    In this case, to add more nodes to the the you just need to add 3 lines of code in
    perform build_sort_table.
    Regards,

  • Creating TREE REPORT with CHECKBOX against each row

    Hi Friends,
    I need to create a <b>TREE REPORT with  CHECK BOX</b> against each row. when the user selects a row and clicks on a custom button then those should get populated into an internal table. <b>This is HIGH priority</b> one and I have tried my best but couldnt find any solution. Please advise me some sol.
    thanks in advance for your valuable time and help.
    Regards
    srithan
    Message edited by me for easyness
            Reddy

    Hi
    Following code is to add checkboxes in ALV tree:
    FORM add_root_request USING pls_data_ TYPE csg_gs_outtab_p_key__l_is_sub_node_ TYPE c
    CHANGING pl_carrid_key._node = nodes->add_node( related_node = p_key
    relationship = cl_gui_column_tree=>relat_last_child ).
    ... §0.2 if information should be displayed at
    the hierarchy column set the carrid as text for this node
    text = p_ls_data-object.
    node->set_text( text ).
    ... §0.3 set the data for the nes node
    node->set_data_row( p_ls_data ).
    item = node->get_hierarchy_item( ).
    item = node->get_item( 'FCHECKBOX' ). "FCHECKBOX is my radio button field in internal table which I am using to populate the ALV
    item->set_type( if_salv_c_item_type=>checkbox ).
    pl_carrid_key = node->get_key( )._
    CATCH cx_salv_msg.
    ENDFORM_._Following code is for handling checbox_change event
    PERFORM application_action_events.
    FORM application_action_events .
    data: lr_events type ref to cl_salv_events_tree.
    *data gr_events type ref to lcl_handle_events.
    lr_events = gr_tree->get_event( ).
    create object gr_events.
    set handler gr_events->check for lr_events.
    set handler gr_events->on_link_click for lr_events.
    set handler gr_events->on_before_user_command for lr_events.
    set handler gr_events->on_after_user_command for lr_events.
    set handler gr_events->on_keypress for lr_events.
    endform. " application_action_events----
    CLASS lcl_handle_events DEFINITION.
    PUBLIC SECTION.
    METHODS:
    check FOR EVENT checkbox_change OF cl_salv_events_tree IMPORTING node_key columnname checked. "Here node_key is the row number
    ENDCLASS. "lcl_handle_events DEFINITION
    CLASS lcl_handle_events IMPLEMENTATION
    §4.2 implement the events for handling the events of cl_salv_table
    CLASS lcl_handle_events IMPLEMENTATION_._
    METHOD check_._
    WRITE 'hello'_._
    DATA lwa_modify_check_ TYPE REF TO csg_gs_outtab.
    node_key = node_key - 1_._
    READ TABLE csg_gt_list INDEX node_key REFERENCE INTO lwa_modify_check._
    if columnname = 'FCHECKBOX'_._
    IF checked = 'X'_._
    If the value in internal table is set to X, then it is deselct
    lwa_modify_check->fcheckbox =_ ' '_._
    ELSE_._
    lwa_modify_check->fcheckbox =_ 'X'_._
    ENDIF_._
    ENDIF_._
    if columnname = 'CHECKBOX_READ'_._
    IF checked = 'X'_._
    If the value in internal table is set to X, then it is deselct
    lwa_modify_check->checkbox_read =_ ' '_._
    ELSE_._
    lwa_modify_check->checkbox_read =_ 'X'_._
    ENDIF_._
    ENDIF_._
    *MODIFY TABLE csg_gt_list from l_wa_modify_check.
    flag_test = flag_test + 1_._
    ENDMETHOD_._ "check
    ENDCLASS_._ "lcl_handle_events IMPLEMENTATION
    Please give me reward points

  • How to set selected row on startup of an alv tree build with cl_salv_tree

    HI,
    I have a cl_salv_tree and want the tree structure to open a specific node when starting the report. My coding is something like that:
      DATA: lr_selections       TYPE REF TO cl_salv_selections_tree,
            lr_nodes            TYPE REF TO cl_salv_nodes,
            lr_node             TYPE REF TO cl_salv_node,
            lv_node_index(12)   TYPE c,
            lt_nodes            TYPE salv_t_nodes,
            ls_nodes            TYPE salv_s_nodes,
            lr_item             TYPE REF TO cl_salv_item.
    lr_selections = lr_tree->get_selections( ).
    lt_nodes = lr_selections->get_selected_nodes( ).
    lr_item = lr_selections->get_selected_item( ).
    IF lr_item IS NOT BOUND.
      lr_nodes = lr_tree->get_nodes( ).
      lr_node = lr_nodes->get_node( lv_node_index ).  "lv_node_index is the index of the node i want to be open on startup
      ls_nodes-key = lv_node_index.
      ls_nodes-node = lr_node.
      APPEND ls_nodes TO lt_nodes.
      lr_selections->set_selected_nodes( lt_nodes ).
    ELSE.
      ls_nodes-node = lr_item->get_node( ).
      ls_nodes-key = ls_nodes-node->get_key( ).
      APPEND ls_nodes TO lt_nodes.
      lr_selections->set_selected_nodes( lt_nodes ).
    ENDIF.
    This coding is also used, when the report is running and someone clicks an a row. So thats why I check if a item is marked
    or the total row.
    But the tree always starts without opening the node.
    Do I use the right methods or am I totally wrong ????
    Thx for your help in advance
    dinodini
    Edited by: dinodini on Nov 16, 2010 6:51 PM

    What you are looking for is the similar functionality which could be achieved by the method EXPAND_NODE of the ALV Tree created using CL_GUI_ALV_TREE. In SALV Tree, you can use the method EXPAND of the class CL_SALV_NODE to show all the subnodes of that node, not by using the SELECTION.
    Once you add the Node using the method ADD_NODE, you should call the method EXPAND to expand that subtree.
                lr_nodes  = lr_tree->get_nodes( ).
                lr_node =  lr_nodes->ADD_NODE( ... )
                lr_node->EXPAND( COMPLETE_SUBTREE = 'X' ).
    Regards,
    Naimesh Patel

  • Runtime error while i add a node in ALV Tree in oops

    i am adding a node to alv tree using oop am passing a work area and when i execute it is going for a dump and it says UC_OBJECTS_NOT_CONVERTIBLE
    and the below where it is bold and italic it is where the dump is occuring
    METHOD ADD_NODE.
    FIELD-SYMBOLS: <TAB1> TYPE standard TABLE,
    <wa> type any.
    assign mt_outtab->* to <tab1>.
    insert line in outtab
    DATA: L_INDEX TYPE SY-TABIX.
    if is_outtab_line is initial.
    create initial line
    data l_dref_wa type ref to data.
    create data l_dref_wa like line of <tab1>.
    assign l_dref_wa->* to <wa>.
    l_index = 0.
    append <wa> to <Tab1>.
    else.
    APPEND IS_OUTTAB_LINE TO <TAB1>. endif.
    L_INDEX = SY-TABIX.
    add node to model
    CALL METHOD ME->ADD_MODEL_NODE
    EXPORTING
    I_RELAT_NODE_KEY = I_RELAT_NODE_KEY
    I_RELATIONSHIP = I_RELATIONSHIP
    IS_NODE_LAYOUT = IS_NODE_LAYOUT
    IT_ITEM_LAYOUT = IT_ITEM_LAYOUT
    I_NODE_TEXT = I_NODE_TEXT
    I_INDEX_OUTTAB = L_INDEX
    IMPORTING
    E_NEW_NODE_KEY = E_NEW_NODE_KEY.
    ENDMETHOD.

    HI Mohsin,
    please refer to the below ....
    might be helpful for u .....
    https://scn.sap.com/thread/2050188
    http://scn.sap.com/message/6407195
    http://r0005001.benxbrain.com/de%28bD1lbiZjPTAwMQ==%29/index.do?onInputProcessing=brai_thread&001_thread_id=1759814%20&001_temp=R3TR|PROG|RCSBI010||P01|
    Hope thiw will help ....
    Regards,
    AKS

  • 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

  • Double click in ALV tree output????

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

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

  • How to get Text for nodes in Tree Structure

    Hi Friends,
    How to get Text for nodes in Tree Structure
    REPORT  YFIIN_REP_TREE_STRUCTURE  no standard page heading.
                       I N I T I A L I Z A T I O N
    INITIALIZATION.
    AUTHORITY-CHECK OBJECT 'ZPRCHK_NEW' :
                      ID 'YFIINICD' FIELD SY-TCODE.
      IF SY-SUBRC NE 0.
        MESSAGE I000(yFI02) with SY-TCODE .
        LEAVE PROGRAM.
      ENDIF.
    class screen_init definition create private.
    Public section
      public section.
        class-methods init_screen.
        methods constructor.
    Private section
      private section.
        data: container1 type ref to cl_gui_custom_container,
              container2 type ref to cl_gui_custom_container,
              tree type ref to cl_gui_simple_tree.
        methods: fill_tree.
    endclass.
    Class for Handling Events
    class screen_handler definition.
    Public section
      public section.
        methods: constructor importing container
                   type ref to cl_gui_custom_container,
                 handle_node_double_click
                   for event node_double_click
                   of cl_gui_simple_tree
                   importing node_key .
    Private section
      private section.
    endclass.
    *&                        Classes implementation
    class screen_init implementation.
    *&                        Method INIT_SCREEN
      method init_screen.
        data screen type ref to screen_init.
        create object screen.
      endmethod.
    *&                        Method CONSTRUCTOR
      method constructor.
        data: events type cntl_simple_events,
              event like line of events,
              event_handler type ref to screen_handler.
        create object: container1 exporting container_name = 'CUSTOM_1',
                       tree exporting parent = container1
                         node_selection_mode =
                cl_gui_simple_tree=>node_sel_mode_multiple.
        create object: container2 exporting container_name = 'CUSTOM_2',
        event_handler exporting container = container2.
    event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
        event-appl_event = ' '.   "system event, does not trigger PAI
        append event to events.
        call method tree->set_registered_events
             exporting events = events.
        set handler event_handler->handle_node_double_click for tree.
         call method: me->fill_tree.
      endmethod.
    *&                        Method FILL_TREE
      method fill_tree.
        data: node_table type table of abdemonode,
              node type abdemonode.
    types:    begin of tree_node,
              folder(50) type c,
              tcode(60) type c,
              tcode1(60) type c,
              tcode2(60) type c,
              text(60) type c,
              text1(60) type c,
              text2(60) type c,
              end of tree_node.
      data:  wa_tree_node type tree_node,
                t_tree_node type table of tree_node.
    wa_tree_node-folder = text-001.
    wa_tree_node-tcode  = text-002.
    wa_tree_node-text =  'Creditors ageing'.
    wa_tree_node-tcode1 = text-003.
    wa_tree_node-text1 =  'GR/IR aging'.
    wa_tree_node-tcode2 = text-004.
    wa_tree_node-text2 =  'Bank Balance'.
    append wa_tree_node to t_tree_node.
    clear wa_tree_node .
    wa_tree_node-folder = text-005.
    wa_tree_node-tcode  = text-006.
    wa_tree_node-text =  'Creditors ageing'.
    wa_tree_node-tcode1 = text-007.
    wa_tree_node-text1 =  'Creditors ageing'.
    wa_tree_node-tcode2 = text-008.
    wa_tree_node-text2 =  'Creditors ageing'.
    append wa_tree_node to t_tree_node.
    clear wa_tree_node .
    wa_tree_node-folder = text-009.
    wa_tree_node-tcode  = text-010.
    wa_tree_node-text =  'Creditors ageing'.
    wa_tree_node-tcode1 = text-011.
    wa_tree_node-text1 =  'Creditors ageing'.
    wa_tree_node-tcode2 = text-012.
    wa_tree_node-text2 =  'Creditors ageing'.
    append wa_tree_node to t_tree_node.
    clear wa_tree_node .
    node-hidden = ' '.                 " All nodes are visible,
        node-disabled = ' '.               " selectable,
        node-isfolder = 'X'.                                    " a folder,
        node-expander = ' '.               " have no '+' sign forexpansion.
        loop at t_tree_node into wa_tree_node.
          at new folder.
            node-isfolder = 'X'.                      " a folder,
            node-node_key = wa_tree_node-folder.
                   clear node-relatkey.
            clear node-relatship.
            node-text = wa_tree_node-folder.
            node-n_image =   ' '.
            node-exp_image = ' '.
            append node to node_table.
          endat.
         at new tcode .
            node-isfolder = ' '.                          " a folder,
            node-n_image =   '@CS@'.       "AV is the internal code
            node-exp_image = '@CS@'.       "for an airplane icon
            node-node_key = wa_tree_node-tcode.
             node-text = wa_tree_node-text .
                     node-relatkey = wa_tree_node-folder.
            node-relatship = cl_gui_simple_tree=>relat_last_child.
          endat.
          append node to node_table.
        at new tcode1 .
            node-isfolder = ' '.                          " a folder,
            node-n_image =   '@CS@'.       "AV is the internal code
            node-exp_image = '@CS@'.       "for an airplane icon
            node-node_key = wa_tree_node-tcode1.
                     node-relatkey = wa_tree_node-folder.
            node-relatship = cl_gui_simple_tree=>relat_last_child.
              node-text = wa_tree_node-text1.
         endat.
          append node to node_table.
           at new tcode2 .
            node-isfolder = ' '.                          " a folder,
            node-n_image =   '@CS@'.       "AV is the internal code
            node-exp_image = '@CS@'.       "for an airplane icon
            node-node_key = wa_tree_node-tcode2.
                     node-relatkey = wa_tree_node-folder.
            node-relatship = cl_gui_simple_tree=>relat_last_child.
            node-text = wa_tree_node-text2.
         endat.
          append node to node_table.
        endloop.
        call method tree->add_nodes
             exporting table_structure_name = 'ABDEMONODE'
                       node_table = node_table.
      endmethod.
    endclass.
    *&                        Class implementation
    class screen_handler implementation.
    *&                        Method CONSTRUCTOR
      method constructor.
       create object: HTML_VIEWER exporting PARENT = CONTAINER,
                      LIST_VIEWER exporting I_PARENT = CONTAINER.
      endmethod.
    *&                 Method HANDLE_NODE_DOUBLE_CLICK
      method handle_node_double_click.
      case node_key(12).
    when 'Creditors'.
    submit YFIIN_REP_CREADITORS_AGING  via selection-screen and return.
    when  'Vendor'.
    submit YFIIN_REP_VENDOR_OUTSTANDING  via selection-screen and return.
    when 'Customer'.
    submit YFIIN_REP_CUSTOMER_OUTSTANDING  via selection-screen and
    return.
    when 'GR/IR'.
    submit YFIIN_REP_GRIR_AGING  via selection-screen and return.
    when 'Acc_Doc_List'.
    submit YFIIN_REP_ACCOUNTINGDOCLIST  via selection-screen and return.
    when 'Bank Bal'.
    submit YFIIN_REP_BANKBALANCE  via selection-screen and return.
    when 'Ven_Cus_Dtl'.
    submit YFIIN_REP_VENDORCUST_DETAIL via selection-screen and return.
    when 'G/L_Open_Bal'.
    submit YFIIN_REP_OPENINGBALANCE via selection-screen and return.
    when 'Usr_Authn'.
    submit YFIIN_REP_USERAUTHRIZATION via selection-screen and return.
    endcase.
      endmethod.
    endclass.
    Program execution ************************************************
    load-of-program.
      call screen 9001.
    at selection-screen.
    Dialog Modules PBO
    *&      Module  STATUS_9001  OUTPUT
          text
    module status_9001 output.
      set pf-status 'SCREEN_9001'.
      set titlebar 'TIT_9001'.
      call method screen_init=>init_screen.
    endmodule.                 " STATUS_9001  OUTPUT
    Dialog Modules PAI
    *&      Module  USER_COMMAND_9001  INPUT
          text
    module user_command_9001 input.
    endmodule.                 " USER_COMMAND_9001  INPUT
    *&      Module  exit_9001  INPUT
          text
    module exit_9001 input.
    case sy-ucomm.
    when 'EXIT'.
      set screen 0.
    endcase.
    endmodule.
            exit_9001  INPUT

    you can read  the table node_table with nody key value which imports when docubble click the the tree node (Double clifk event).
    Regards,
    Gopi .
    Reward points if helpfull.

  • How to create input text of the node in AVL tree

    Hi experts,
    I create a simple AVL tree to display the sales order items, just two classes for one relationship. Like the left part on the screen in this program "DEMO_ABAP_OBJECTS_CONTROLS".
    I want to let the node of the second class be maintained serial no., somthing like input field behind the node or double click the node, then show up the input field on another space on the same screen.
    And there is a button on screen, I can do some check for the text of input field when pressing the button. If the input data is wrong , then show up the error message.
    I have searched BCALV* in SE38, but i don't see anything helpful.
    Plz give me some advice, thanks a lot!!
    Regards,
    Claire

    To Kunjal and Uwe,
    My AVL tree is declared like this:
    Data: tree TYPE REF TO cl_gui_simple_tree.
    The class is not  "cl_gui_alv_tree" , so I can not use the code.
    The code I create the node is the follwing:
    CALL METHOD tree->add_nodes
             EXPORTING table_structure_name = 'ABDEMONODE'
                       node_table = node_table.
    And I looked the program that Uwe wrote, the tree is declared in class cl_gui_alv_tree, too.
    I want to double click the node and appear a field that can be inputed text.
    Is there any other way to do this with the class cl_gui_simple_tree?
    Thanks for the advence help.
    Claire

  • How to make field editable in ALV tree in OOPs?

    Hi Gems,
    Again I need help from you all.
    I am writing a program using OOPs and the uotput will be in ALV tree. I need to make a field editable in a perticular row.
    I am doing it using layout but the program is giving error during
    CALL METHOD CL_GUI_CFW=>FLUSH
          EXCEPTIONS
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
    This method is returning sy-subrc = 2 and I am unable to get the output.
    I am using below code to make the field editable:
    DATA: LT_LAYOUT_ITEM TYPE LVC_T_LAYI,
                LS_LAYOUT_ITEM TYPE LVC_S_LAYI.
      LS_LAYOUT_ITEM-FIELDNAME = 'ACPCKTWRT'.     "ACPCKTWRT is the field name in the Internal table
      LS_LAYOUT_ITEM-EDITABLE = 'X'.
      APPEND LS_LAYOUT_ITEM TO LT_LAYOUT_ITEM.
    CALL METHOD G_ALV_TREE->ADD_NODE
        EXPORTING
          I_RELAT_NODE_KEY     = FP_RELAT_KEY
          I_RELATIONSHIP       = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          IS_OUTTAB_LINE       = LS_TMP_FINFCNO                                                "structure of the internal table
         IS_NODE_LAYOUT       =
          IT_ITEM_LAYOUT       = LT_LAYOUT_ITEM                                                "Added layout to make the field editable
          I_NODE_TEXT          = LV_NODE_TEXT                                                      "Node text
        IMPORTING
          E_NEW_NODE_KEY       = FP_NODE_KEY
        EXCEPTIONS
          RELAT_NODE_NOT_FOUND = 1
          NODE_NOT_FOUND       = 2
          OTHERS               = 3
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Please help me and let me know how to get the solution.

    Hello
    The ALV tree control is not intended for making values editable (e.g. see
    [How to make ALV tree columns editable|http://sap.ittoolbox.com/groups/technical-functional/sap-abap/how-to-make-alv-tree-columns-editable-2052414])
    However, if you need an editable tree control then you have to use a different class (e.g. CL_ITEM_TREE_MODEL or CL_COLUMN_TREE_MODEL) but you will not have the ALV functionality of the ALV tree control.
    Regards
      Uwe

  • 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

  • Refresh problem in CL_GUI_ALV_TREE

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

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

Maybe you are looking for

  • IPod touch error message

    When I typed in my password, why does the error message pop up when I typed it in correctly?  Is there someways I can get some more help?

  • LaserJet Pro 300 color MFP automatic document feeder - page stops feeding with 1" to go

    Scan page won't finish feeding when using the automatic document feeder.  Leaves approximately the last 1 to 2 inches of paper in the scanner. The Scan ADF Paper Jam error message pops up.  Seems like the page hangs/gets stuck  once the page passes t

  • Hiding fields with same name

    Hi, I have a form built in ADOBE LC Designer ES. The form has multiple pages. I have some fields with the same name and distributed across subforms. Is there a way I can hide the fields using the common name or do I have to refernece each and every f

  • Indesign trouble printing a gradient shadow

    Hello, I'm fairly new to production in Indesign and I've been having a lot more trouble than I thought I would trying to get this particular graphic to print properly - I know it must be something really simple that I'm not doing. So the attachment "

  • Why is my updater not working?

    Why is my updater not working.  I receive the following error message " no internet connection please check your internet settings and or firewall waiting for connection"  I have checked my internet connection and it is in fact connected.  What can I