SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Sales Order Flow – Tree Report



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Nov 24, 2007 12:17 am    Post subject: Sales Order Flow – Tree Report Reply with quote

Code:
report z_sales_tree_rpt .

*******************************************************************
*  Create a tree report of sales orders to deliveries to invoices *
*******************************************************************
include z_sales_tree_rpt_top.
include z_sales_tree_class_def.

selection-screen begin of block a0 with frame title text-001.

*selection-screen comment 5(60) text-c00 modif id sc1.

selection-screen begin of block b5 with frame title text-s05.
select-options:
  s_erdat for vbak-erdat,
  s_ernam for vbak-ernam.
parameters: s_vbtyp like vbfa-vbtyp_n default 'C'.
selection-screen end of block b5.

selection-screen end of block a0.

*----------------------------------------------------------------------*
* Initialization
*----------------------------------------------------------------------*
*at selection-screen output.
*  perform update_sel_screen_attributes.

*----------------------------------------------------------------------*
* Start of Selection
*----------------------------------------------------------------------*
start-of-selection.

  refresh: itab_data, itab_selection.
  perform update_selection_table tables itab_selection.
  perform create_input_table tables itab_data
                                    itab_selection.

  if not itab_data is initial.
* create the application object
* this object is needed to handle the ABAP Objects Events of Controls
    create object g_application.
    call screen 2000.
  else.
    message i043(z1).
  endif.

end-of-selection.

*----------------------------------------------------------------------*
* Includes
*----------------------------------------------------------------------*
  include z_sales_tree_forms.

  include z_sales_tree_pbo.

  include z_sale_tree_pai.
 
*----------------------------------------------------------------------*
*   INCLUDE Z_SALES_TREE_CLASS_DEF                                     *
*----------------------------------------------------------------------*
 class lcl_application definition.
  public section.
    methods:
      handle_node_double_click
        for event node_double_click
        of cl_gui_list_tree
        importing node_key,
      handle_expand_no_children
        for event expand_no_children
        of cl_gui_list_tree
        importing node_key,
      handle_item_double_click
        for event item_double_click
        of cl_gui_list_tree
        importing node_key item_name,
      handle_button_click
        for event button_click
        of cl_gui_list_tree
        importing node_key item_name,
      handle_link_click
        for event link_click
        of cl_gui_list_tree
        importing node_key item_name,
      handle_checkbox_change
        for event checkbox_change
        of cl_gui_list_tree
        importing node_key item_name checked.
endclass.

*---------------------------------------------------------------------*
*       CLASS lcl_application IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_application implementation.

  method  handle_node_double_click.
    " this method handles the node double click event of the tree
    " control instance

    " show the key of the double clicked node in a dynpro field
    read table itab_data with key node_key = node_key into wa_data.
    if sy-subrc = 0.
      select single rfmng rfwrt matnr
        into (vbfa-rfmng, vbfa-rfwrt, vbfa-matnr)
        from vbfa
        where vbelv = wa_data-vbeln
        and   posnv = wa_data-posnn.
    endif.
  endmethod.

  method  handle_item_double_click.
    " this method handles the item double click event of the tree
    " control instance. You have variables node_key and item_name

    " show the key of the node and the name of the item
    " of the double clicked item in a dynpro field
    read table itab_data with key node_key = node_key into wa_data.
    if sy-subrc = 0.
      select single rfmng rfwrt matnr
        into (vbfa-rfmng, vbfa-rfwrt, vbfa-matnr)
        from vbfa
        where vbelv = wa_data-vbeln
        and   posnv = wa_data-posnn.
    endif.

  endmethod.

  method  handle_link_click.
    " this method handles the link click event of the tree
    " control instance

    " show the key of the node and the name of the item
    " of the clicked link in a dynpro field
*    g_event = 'LINK_CLICK'.
*    g_node_key = node_key.
*    g_item_name = item_name.
  endmethod.

  method  handle_button_click.
    " this method handles the button click event of the tree
    " control instance

    " show the key of the node and the name of the item
    " of the clicked button in a dynpro field
*    g_event = 'BUTTON_CLICK'.
*    g_node_key = node_key.
*    g_item_name = item_name.
  endmethod.

  method  handle_checkbox_change.
    " this method handles the checkbox_change event of the tree
    " control instance

    " show the key of the node and the name of the item
    " of the clicked checkbox in a dynpro field
*    g_event = 'CHECKBOX_CHANGE'.
*    g_node_key = node_key.
*    g_item_name = item_name.
  endmethod.


  method handle_expand_no_children.
    data: node_table type treev_ntab,
          node type treev_node,
          item_table type item_table_type,
          item type mtreeitm.

* show the key of the expanded node in a dynpro field
*    g_event = 'EXPAND_NO_CHILDREN'.
*    g_node_key = node_key.

    if node_key = 'Child2'.                                 "#EC NOTEXT
* add the children for node with key 'Child2'
* Node with key 'New3'
      clear node.
      node-node_key = 'New3'.                               "#EC NOTEXT
      node-relatkey = 'Child2'.
      node-relatship = cl_gui_list_tree=>relat_last_child.
      append node to node_table.

* Node with key 'New4'
      clear node.
      node-node_key = 'New4'.                               "#EC NOTEXT
      node-relatkey = 'Child2'.
      node-relatship = cl_gui_list_tree=>relat_last_child.
      append node to node_table.

* Items of node with key 'New3'
      clear item.
      item-node_key = 'New3'.
      item-item_name = '1'.
      item-class = cl_gui_list_tree=>item_class_text.
      item-length = 11.
      item-usebgcolor = 'X'. "
      item-text = 'SAPTROX1'.
      append item to item_table.

      clear item.
      item-node_key = 'New3'.
      item-item_name = '2'.
      item-class = cl_gui_list_tree=>item_class_text.
      item-alignment = cl_gui_list_tree=>align_auto.
      item-font = cl_gui_list_tree=>item_font_prop.
      item-text = 'Comment to SAPTROX1'.                    "#EC NOTEXT
      append item to item_table.

* Items of node with key 'New4'
      clear item.
      item-node_key = 'New4'.
      item-item_name = '1'.
      item-class = cl_gui_list_tree=>item_class_text.
      item-length = 11.
      item-usebgcolor = 'X'. "
      item-text = 'SAPTRIXTROX'.
      append item to item_table.

      clear item.
      item-node_key = 'New4'.
      item-item_name = '2'.
      item-class = cl_gui_list_tree=>item_class_text.
      item-alignment = cl_gui_list_tree=>align_auto.
      item-font = cl_gui_list_tree=>item_font_prop.
      item-text = 'Comment to SAPTRIXTROX'.                 "#EC NOTEXT
      append item to item_table.
    endif.

    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(tree_control_msg).
    endif.
  endmethod.

endclass.
 
*----------------------------------------------------------------------*
*   INCLUDE Z_SALES_TREE_FORMS                                         *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*&      Form  update_sel_screen_attributes
*&---------------------------------------------------------------------*
form update_sel_screen_attributes.
  loop at screen.

    if screen-group1 = 'SC1'.
      screen-intensified = '1'.
      modify screen.
    endif.
    if screen-group1 = 'ECR' and sy-tcode <> 'ZCMR'.
      if not sy-tcode = 'ZCM'.
        screen-invisible = '1'.
        screen-active = '0'.
        modify screen.
      endif.
    endif.
    if screen-group1 = 'ECN' and sy-tcode <> 'ZCMN'.
      if not sy-tcode = 'ZCM'.
        screen-invisible = '1'.
        screen-active = '0'.
        modify screen.
      endif.
    endif.
    if screen-group1 = 'ECO' and sy-tcode <> 'ZCMO'.
      if not sy-tcode = 'ZCM'.
        screen-invisible = '1'.
        screen-active = '0'.
        modify screen.
      endif.
    endif.

  endloop.
endform.                    " update_sel_screen_attributes

*&---------------------------------------------------------------------*
*&      Form  create_and_init_tree
*&---------------------------------------------------------------------*
form create_and_init_tree.
  data: node_table type treev_ntab,
        item_table type item_table_type,
        events type cntl_simple_events,
        event type cntl_simple_event.

* create a container for the tree control
  create object g_custom_container
    exporting
      " the container is linked to the custom control with the
      " name 'TREE_CONTROL' on the dynpro
      container_name = 'TREE_CONTROL'
    exceptions
      cntl_error = 1
      cntl_system_error = 2
      create_error = 3
      lifetime_error = 4
      lifetime_dynpro_dynpro_link = 5.
  if sy-subrc <> 0.
    message a000(tree_control_msg).
  endif.


* create a list tree control
  create object g_tree
    exporting
      parent              = g_custom_container
      node_selection_mode = cl_gui_list_tree=>node_sel_mode_single
      item_selection     = 'X'
      with_headers       = ' '
    exceptions
      cntl_system_error           = 1
      create_error                = 2
      failed                      = 3
      illegal_node_selection_mode = 4
      lifetime_error              = 5.
  if sy-subrc <> 0.
    message a000(tree_control_msg).
  endif.

* define the events which will be passed to the backend
  " node double click
  event-eventid = cl_gui_list_tree=>eventid_node_double_click.
  event-appl_event = 'X'.                                   "
  append event to events.

  " item double click
  event-eventid = cl_gui_list_tree=>eventid_item_double_click.
  event-appl_event = 'X'.
  append event to events.

  " expand no children
  event-eventid = cl_gui_list_tree=>eventid_expand_no_children.
  event-appl_event = 'X'.
  append event to events.

  " link click
  event-eventid = cl_gui_list_tree=>eventid_link_click.
  event-appl_event = 'X'.
  append event to events.

  " button click
  event-eventid = cl_gui_list_tree=>eventid_button_click.
  event-appl_event = 'X'.
  append event to events.

  " checkbox change
  event-eventid = cl_gui_list_tree=>eventid_checkbox_change.
  event-appl_event = 'X'.
  append event to events.

  call method g_tree->set_registered_events
    exporting
      events = events
    exceptions
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.
  if sy-subrc <> 0.
    message a000(tree_control_msg).
  endif.

* assign event handlers in the application class to each desired event
  set handler g_application->handle_node_double_click for g_tree.
  set handler g_application->handle_item_double_click for g_tree.
  set handler g_application->handle_expand_no_children for g_tree.
  set handler g_application->handle_link_click for g_tree.
  set handler g_application->handle_button_click for g_tree.
  set handler g_application->handle_checkbox_change for g_tree.

* 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(tree_control_msg).
  endif.

endform.                    " create_and_init_tree
*&---------------------------------------------------------------------*
*&      Form  build_node_and_item_table
*&---------------------------------------------------------------------*
form build_node_and_item_table  using
                                       node_table type treev_ntab
                                       item_table type item_table_type.
  data: node type treev_node,
        item type mtreeitm.

* Build the node and item table.
  loop at itab_data into wa_data.
    clear node.

    node-node_key = wa_data-node_key.
    node-relatkey = wa_data-relatkey.
    node-isfolder = wa_data-folder.
    if wa_data-relatkey is initial.
      clear: node-relatship,
             node-exp_image,
             node-expander.
      node-hidden = ' '.
      node-disabled = ' '.
    else.
      node-relatship = cl_gui_list_tree=>relat_last_child.
    endif.
    append node to node_table.

* Update Items
    clear item.
    item-node_key = wa_data-node_key.
    item-item_name = '1'.
    item-length = 10.
    item-class = cl_gui_list_tree=>item_class_text. " Text Item
    item-alignment = cl_gui_list_tree=>align_auto.
    item-font = cl_gui_list_tree=>item_font_prop.
    item-usebgcolor = 'X'.
    case wa_data-type.
      when 'C'.
        item-text = 'ORDER'.
      when 'J'.
        item-text = 'DELIVERY'.
      when 'M'.
        item-text = 'INVOICE'.
      when '+'.
        item-text = 'Payment'.
      when 'Q'.
        item-text = 'Whse Xfer'.
      when 'R'.
        item-text = 'Goods Mvmt'.
      when 'H'.
        item-text = 'Return Gds'.

    endcase.
    append item to item_table.

    clear item.
    item-node_key = wa_data-node_key.
    item-item_name = '2'.
    item-length = 10.
    item-class = cl_gui_list_tree=>item_class_text. " Text Item
    item-alignment = cl_gui_list_tree=>align_auto.
    item-font = cl_gui_list_tree=>item_font_prop.
    item-text = wa_data-vbeln.
    append item to item_table.

*    clear item.
*    item-node_key = wa_data-node_key.
*    item-item_name = '3'.
*    item-t_image = '@01@'.               " icon of the item
*    item-ignoreimag = 'X'.
*    item-length = 4.
*    item-class = cl_gui_list_tree=>item_class_text. " Text Item
*    append item to item_table.
*
    clear item.
    item-node_key = wa_data-node_key.
    item-item_name = '3'.
    item-length = 6.
    item-class = cl_gui_list_tree=>item_class_text. " Text Item
    item-alignment = cl_gui_list_tree=>align_auto.
    item-font = cl_gui_list_tree=>item_font_prop.
    item-text = wa_data-posnn.
    append item to item_table.

    clear item.
    item-node_key = wa_data-node_key.
    item-item_name = '4'.
    item-length = 10.
    item-class = cl_gui_list_tree=>item_class_text. " Text Item
    item-alignment = cl_gui_list_tree=>align_auto.
    item-font = cl_gui_list_tree=>item_font_prop.
    item-text = wa_data-rfmng.
    append item to item_table.

     clear item.
    item-node_key = wa_data-node_key.
    item-item_name = '5'.
    item-length = 10.
    item-class = cl_gui_list_tree=>item_class_text. " Text Item
    item-alignment = cl_gui_list_tree=>align_auto.
    item-font = cl_gui_list_tree=>item_font_prop.
    item-text = wa_data-rfwrt.
    append item to item_table.

  endloop.

endform.                    " build_node_and_item_table
*&---------------------------------------------------------------------*
*&      Form  create_input_table
*&---------------------------------------------------------------------*
form create_input_table tables   p_itab_data like itab_data
                                 p_itab_selection like itab_selection.

  data: l_tabix like sy-tabix,
        lm_tabix like sy-tabix,
        begin of wl_data,
          vbeln   like vbfa-vbeln,
          posnn   like vbfa-posnn,
        end of  wl_data,
        t_counter(4) type n,
        t_parent(4) type c,
        t_parent1(4) type c,
        t_exit type flag,
        is_del_data like line of itab_data,
        it_inv_data type itab_type occurs 0.

  t_counter = 1.
  loop at p_itab_selection.

    clear: t_parent, t_parent1, t_exit.
    refresh it_vbfa.
    is_vbc06-vbeln = p_itab_selection-vbeln.
    call function 'RV_ORDER_FLOW_INFORMATION'
      exporting
        aufbereitung        = '2'
*       BELEGTYP            = ' '
        comwa               = is_vbc06
        nachfolger          = 'X'
        n_stufen            = '50'
        vorgaenger          = 'X'
        v_stufen            = '50'
*     IMPORTING
*       BELEGTYP_BACK       =
      tables
        vbfa_tab            =  it_vbfa
      exceptions
        no_vbfa             = 1
        no_vbuk_found       = 2
        others              = 3
              .

    clear: wa_data.
    wa_data-folder = 'X'.
    wa_data-node_key = t_counter.
    wa_data-relatkey = t_parent.
    wa_data-type     = p_itab_selection-vbtyp.
    wa_data-vbeln    = p_itab_selection-vbeln.
    wa_data-posnn    = '0'.
    append wa_data to p_itab_data.
    t_parent = t_counter.
    add 1 to t_counter.

* Find any deliveries for this order
    loop at it_vbfa where vbtyp_n = 'J'.      " Delivery

      clear: wa_data.
      wa_data-folder = 'X'.
      wa_data-node_key = t_counter.
      wa_data-relatkey = t_parent.
      wa_data-type     = it_vbfa-vbtyp_n.
      wa_data-vbeln    = it_vbfa-vbeln.
      wa_data-posnn    = it_vbfa-posnn.
      wa_data-rfmng    = it_vbfa-rfmng.
      is_del_data      = wa_data.
*
      t_parent1 = t_counter.
      add 1 to t_counter.
      wa_vbelv  = it_vbfa-vbeln.
      wa_posnv  = it_vbfa-posnn.
      l_tabix   = sy-tabix.
* Find any invoices Warehouse xfers or Goods Movements for this delivery
      refresh: it_inv_data.
      loop at it_vbfa where vbelv = wa_vbelv
                      and   posnv = wa_posnv.

        case it_vbfa-vbtyp_n.
        when 'M'.    "Invoice
          clear: wa_data.
          wa_data-folder = ' '.
          wa_data-node_key = t_counter.
          wa_data-relatkey = t_parent1.
          wa_data-type     = it_vbfa-vbtyp_n.
          wa_data-vbeln    = it_vbfa-vbeln.
          wa_data-posnn    = it_vbfa-posnn.
          wa_data-rfmng    = it_vbfa-rfmng.
          wa_data-rfwrt    = it_vbfa-rfwrt.
          append wa_data to it_inv_data.
          wj_vbelv         = it_vbfa-vbeln.
          wj_posnv         = it_vbfa-posnn.
          wa_nodekey       = wa_data-node_key.
          describe table it_inv_data lines lm_tabix.
          add 1 to t_counter.
          perform get_payment  tables it_inv_data using t_counter.
          perform get_returns  tables it_inv_data using t_counter.
          describe table it_inv_data lines l_tabix.
          if l_tabix > lm_tabix.
            read table it_inv_data index lm_tabix into wa_data.
            wa_data-folder = 'X'.
            modify it_inv_data index lm_tabix from wa_data.
          endif.

        when 'Q' or 'R'.    " WMS transfer, or Goods Mvmt
          clear: wa_data.
          wa_data-folder = ' '.
          wa_data-node_key = t_counter.
          wa_data-relatkey = t_parent1.
          wa_data-type     = it_vbfa-vbtyp_n.
          wa_data-vbeln    = it_vbfa-vbeln.
          wa_data-posnn    = it_vbfa-posnn.
          wa_data-rfmng    = it_vbfa-rfmng.
          append wa_data to it_inv_data.
          add 1 to t_counter.
        when others.
        endcase.

      endloop.              " finding any matching invoices
      if it_inv_data is initial.
        is_del_data-folder = ' '.
      endif.
      append is_del_data to p_itab_data.
      append lines of it_inv_data to p_itab_data.
      refresh: it_inv_data.
    endloop.                " finding any deliveries

  endloop.
  clear: t_parent, t_parent1, t_exit.

endform.                    " create_input_table
*&---------------------------------------------------------------------*
*&      Form  update_selection_table
*&---------------------------------------------------------------------*
form update_selection_table tables  itab_selection.


  if not s_ernam is initial or
     not s_erdat is initial or
     not s_vbtyp is initial.

    select: vbeln vbtyp into corresponding fields of
    table  itab_selection
    from   vbak
    where erdat in s_erdat and
          ernam in s_ernam and
          vbtyp =  s_vbtyp.

  endif.

endform.                    " update_selection_table
*&---------------------------------------------------------------------*
*&      Form  get_payment
*&---------------------------------------------------------------------*
form get_payment  tables it_inv_data using pt_counter .

  loop at it_vbfa where vbelv = wj_vbelv
                  and   posnv = wj_posnv
                  and   vbtyp_n = '+'.
    wa_data-folder = ' '.
    wa_data-relatkey = wa_nodekey.
    wa_data-node_key = pt_counter.
    wa_data-type     = it_vbfa-vbtyp_n.
    wa_data-vbeln    = it_vbfa-vbeln.
    wa_data-posnn    = it_vbfa-posnn.
    wa_data-rfmng    = it_vbfa-rfmng.
    wa_data-rfwrt    = it_vbfa-rfwrt.
    append wa_data to it_inv_data.
    add 1 to pt_counter.
  endloop.

endform.                    " get_payment
*&---------------------------------------------------------------------*
*&      Form  get_returns
*&---------------------------------------------------------------------*
form get_returns   tables it_inv_data using pt_counter .
  data: ld_rfwrt(11) type c,
        ld_tabix like sy-tabix.

  loop at it_vbfa where vbelv = wj_vbelv
                  and   posnv = wj_posnv
                  and   vbtyp_n = 'H'.
    ld_tabix         = sy-tabix.
    wa_data-folder   = ' '.
    wa_data-relatkey = wa_nodekey.
    wa_data-node_key = pt_counter.
    wa_data-type     = it_vbfa-vbtyp_n.
    wa_data-vbeln    = it_vbfa-vbeln.
    wa_data-posnn    = it_vbfa-posnn.
    wa_data-rfmng    = it_vbfa-rfmng.
    ld_rfwrt         = it_vbfa-rfwrt.
    concatenate ld_rfwrt '-' into  ld_rfwrt.
    wa_data-rfwrt    = ld_rfwrt.
    append wa_data to it_inv_data.
    add 1 to pt_counter.
  endloop.


endform.
 
*----------------------------------------------------------------------*
*   INCLUDE Z_SALES_TREE_PBO                                           *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_2000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_2000 output.
  set pf-status 'Z_SALES_TREE_2000'.
  set titlebar 'Z_SALES_TREE_2000'.

endmodule.                 " STATUS_2000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  init_data_2000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module init_data_2000 output.
   if g_tree is initial.
    " The Tree Control has not been created yet.
    " Create a Tree Control and insert nodes into it.
    perform create_and_init_tree.
  endif.

endmodule.
 
*----------------------------------------------------------------------*
*   INCLUDE Z_SALES_TREE_RPT_TOP                                       *
*----------------------------------------------------------------------*
* Table Definitions
tables: vbak,            "Sales Document: Header Data
        vbfa.            "Sales Document Flow

* Type definitions
types: begin of itab_type,
         folder   type flag,
         node_key type mtreeitm,
         relatkey type tv_nodekey,
         type     like vbak-vbtyp,
         vbeln    like vbak-vbeln,
         posnn    like vbfa-posnn,
         rfmng(10) type c,
         rfwrt(12) type c,
       end of itab_type.

types: begin of sel_type,
         vbeln    like vbak-vbeln,
         vbtyp    like vbak-vbtyp,
       end of sel_type.

* Data Definitions
data: okcode    like sy-ucomm,
      itab_data type itab_type occurs 0,
      itab_selection type sel_type occurs 0.
data: begin of it_vbfa occurs 0.
        include structure vbfa.
data: end of it_vbfa,
      is_vbfa   like line of it_vbfa,
      is_vbc06  like vbco6,
      wa_vbelv  like vbfa-vbelv,
      wj_vbelv  like vbfa-vbelv,
      wa_posnv  like vbfa-posnv,
      wj_posnv  like vbfa-posnv,
      wa_nodekey type tv_nodekey,
      t_screen(3) type c,
      t_dynnr like sy-dynnr,
      l_transcode  like sy-tcode,
      l_ok_zpcr(4) type c  value 'MM01',
      wa_data   type itab_type.

* Tree list definitions
class lcl_application definition deferred.
class cl_gui_cfw      definition load.

* CAUTION: MTREEITM is the name of the item structure which must
* be defined by the programmer. DO NOT USE MTREEITM!
types: item_table_type like standard table of mtreeitm
       with default key.

data: g_application      type ref to lcl_application,
      g_custom_container type ref to cl_gui_custom_container,
      g_tree             type ref to cl_gui_list_tree,
      g_ok_code          type sy-ucomm.
 
*----------------------------------------------------------------------*
*   INCLUDE Z_SALE_TREE_PAI                                            *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_2000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_2000 input.
  data: return_code type i.
* CL_GUI_CFW=>DISPATCH must be called if events are registered
* that trigger PAI
* this method calls the event handler method of an event
  call method cl_gui_cfw=>dispatch
    importing return_code = return_code.
  if return_code <> cl_gui_cfw=>rc_noevent.
    " a control event occured => exit PAI
    clear okcode.
    exit.
  endif.

  case okcode.
    when 'EXIT' or 'RETURN'. " Finish program
      if not g_custom_container is initial.
        " destroy tree container (detroys contained tree control, too)
        call method g_custom_container->free
          exceptions
            cntl_system_error = 1
            cntl_error        = 2.
        if sy-subrc <> 0.
          message a000(tree_control_msg).
        endif.
        clear g_custom_container.
        clear g_tree.
      endif.
      leave to screen 0.
  endcase.

  clear okcode.


endmodule.                 " USER_COMMAND_2000  INPUT
 
* Screen 2000
process before output.
 module status_2000.
 module init_data_2000.
process after input.
 module user_command_2000.
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.