Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7184914
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-11-29 22:05:05

REPORT z_barry_tree .

DATA: mycontainer TYPE REF TO cl_gui_custom_container.
DATA: node_itab LIKE node_str OCCURS 0 ,
      node LIKE node_str.
DATA: g_tree TYPE REF TO cl_gui_simple_tree.
TYPES: node_table_type LIKE STANDARD
         TABLE OF mtreesnode WITH DEFAULT KEY .
DATA: node_table TYPE node_table_type,
      events TYPE cntl_simple_events,
      event TYPE cntl_simple_event.
DATA ok_code TYPE sy-ucomm.

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS: node_double_click
               FOR EVENT node_double_click
               OF cl_gui_simple_tree
               IMPORTING node_key.
ENDCLASS.                    "lcl_event_receiver DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD node_double_click.
    PERFORM dclik USING node_key .
  ENDMETHOD.
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION

DATA: event_receiver TYPE REF TO lcl_event_receiver.

START-OF-SELECTION.
  PERFORM getdata .
  CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Form  fill_tree
*&---------------------------------------------------------------------*
FORM getdata .
  PERFORM fill_node USING 'Root1' '' 'X' '' 'Root1' ''.
  PERFORM fill_node USING 'Lay1' 'Root1' 'X' '6' 'Lay1' '' .
  PERFORM fill_node USING 'Item' 'Lay1' '' '6' 'Item' .
  PERFORM fill_node USING 'Lay2' 'Root1' '' '6' 'Item2' .
  PERFORM fill_node USING 'Root2' '' 'X' '' 'Root2' '' .
ENDFORM.                    " fill_tree

*---------------------------------------------------------------------*
*       FORM fill_node                                                *
*---------------------------------------------------------------------*
FORM fill_node USING  node_key
                      relatkey
                      isfolder
                      relatship
                      text
                      n_image  .
  DATA: node LIKE mtreesnode.

  CLEAR node.
  node-node_key  = node_key.
  node-relatkey  = relatkey.
  node-isfolder  = isfolder.
  node-relatship = relatship.
  node-text      = text.
  node-n_image   = n_image.
  APPEND node TO node_table.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN100'.

  IF mycontainer IS INITIAL.
    CREATE OBJECT mycontainer
        EXPORTING container_name = 'TREE1'.

    CREATE OBJECT g_tree
      EXPORTING parent = mycontainer
                node_selection_mode = g_tree->node_sel_mode_single.

    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->node_double_click FOR g_tree.
    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 g_tree->set_registered_events
         EXPORTING events = events.

    CALL METHOD g_tree->add_nodes
      EXPORTING
        node_table                     = node_table
        table_structure_name           = 'MTREESNODE'
      EXCEPTIONS
        failed                         = 1
        error_in_node_table            = 2
        dp_error                       = 3
        table_structure_name_not_found = 4
        OTHERS                         = 5.
    IF sy-subrc <> 0.
      MESSAGE e000(z900) WITH 'error'.
    ENDIF.

    CALL METHOD g_tree->expand_root_nodes
      EXPORTING
        expand_subtree      = 'X'
      EXCEPTIONS
        failed              = 1
        illegal_level_count = 2
        cntl_system_error   = 3
        OTHERS              = 4.
  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE ok_code.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  dclik
*&---------------------------------------------------------------------*
FORM dclik USING    p_node_key.
  MESSAGE s000(z900) WITH p_node_key.
ENDFORM.                    " dclik

阅读(5338) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-07-12 11:12:51

100屏幕是怎么建的呢?能不能写一下详细的介绍呢? 谢谢