Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7184675
  • 博文数量: 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-07-09 17:30:07

REPORT z_barry_object_control .
 
*---------------------------------------------------------------------*
*       CLASS SCREEN_INIT DEFINITION
*---------------------------------------------------------------------*
CLASS screen_init DEFINITION CREATE PRIVATE.
  PUBLIC SECTION.
    CLASS-METHODS init_screen.
    METHODS constructor.
  PRIVATE SECTION.
    DATA: container1 TYPE REF TO cl_gui_custom_container,
          container2 TYPE REF TO cl_gui_custom_container,
          container3 TYPE REF TO cl_gui_custom_container,
          picture TYPE REF TO cl_gui_picture,
          tree TYPE REF TO cl_gui_simple_tree.
    METHODS: fill_tree,
             fill_picture.
ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS screen_handler DEFINITION
*---------------------------------------------------------------------*
CLASS screen_handler DEFINITION.
  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.
    DATA: html_viewer TYPE REF TO cl_gui_html_viewer,
          list_viewer TYPE REF TO cl_gui_alv_grid.
    METHODS: fill_html IMPORTING carrid TYPE spfli-carrid,
             fill_list IMPORTING carrid TYPE spfli-carrid
                                 connid TYPE spfli-connid.
ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS screen_init IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS screen_init IMPLEMENTATION.
  METHOD init_screen.
    DATA screen TYPE REF TO screen_init.
    CREATE OBJECT screen.
  ENDMETHOD.
  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',
                   picture EXPORTING parent = container1.
    CREATE OBJECT: container2 EXPORTING container_name = 'CUSTOM_2',
                   tree EXPORTING parent = container2
                     node_selection_mode =
                            cl_gui_simple_tree=>node_sel_mode_single.
    CREATE OBJECT: container3 EXPORTING container_name = 'CUSTOM_3',
                   event_handler EXPORTING container = container3.
    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_picture,
                 me->fill_tree.
  ENDMETHOD.
  METHOD fill_picture.
    TYPES pict_line(256) TYPE c.
    DATA  pict_tab TYPE TABLE OF pict_line.
    DATA  url(255) TYPE c.
    IMPORT pict_tab = pict_tab FROM DATABASE abtree(pi) ID 'FLIGHTS'.
    CALL FUNCTION 'DP_CREATE_URL'
         EXPORTING
              type    = 'IMAGE'
              subtype = 'GIF'
         TABLES
              data    = pict_tab
         CHANGING
              url     = url.
    CALL METHOD picture->load_picture_from_url EXPORTING url = url.
    CALL METHOD picture->set_display_mode
         EXPORTING display_mode = picture->display_mode_fit_center.
  ENDMETHOD.
  METHOD fill_tree.
    DATA: node_table TYPE TABLE OF abdemonode,
          node TYPE abdemonode,
          spfli_wa TYPE spfli,
          spfli_tab TYPE SORTED TABLE OF spfli
                    WITH UNIQUE KEY carrid connid.
    SELECT carrid connid
      FROM spfli
      INTO CORRESPONDING FIELDS OF TABLE spfli_tab.
    node-hidden = ' '.                 " All nodes are visible,
    node-disabled = ' '.               " selectable,
    node-isfolder = 'X'.                                    " a folder,
    node-expander = ' '.               " have no '+' sign for expansion.
    LOOP AT spfli_tab INTO spfli_wa.
      AT NEW carrid.
        node-node_key = spfli_wa-carrid.
        CLEAR node-relatkey.
        CLEAR node-relatship.
        node-text = spfli_wa-carrid.
        node-n_image =   ' '.
        node-exp_image = ' '.
        APPEND node TO node_table.
      ENDAT.
      AT NEW connid.
        CONCATENATE spfli_wa-carrid spfli_wa-connid INTO node-node_key.
        node-relatkey = spfli_wa-carrid.
        node-relatship = cl_gui_simple_tree=>relat_last_child.
        node-text = spfli_wa-connid.
        node-n_image =  
.       "AV is the internal code
        node-exp_image =
.       "for an airplane icon
      ENDAT.
      APPEND node TO node_table.
    ENDLOOP.
    CALL METHOD tree->add_nodes
         EXPORTING table_structure_name = 'ABDEMONODE'
                   node_table = node_table.
  ENDMETHOD.
ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS screen_handler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS screen_handler IMPLEMENTATION.
  METHOD constructor.
    CREATE OBJECT: html_viewer EXPORTING parent = container,
                   list_viewer EXPORTING i_parent = container.
  ENDMETHOD.
  METHOD handle_node_double_click.
    DATA: carrid TYPE spfli-carrid,
          connid TYPE spfli-connid.
    carrid = node_key(2).
    connid = node_key+2(4).
    IF connid IS INITIAL.
      CALL METHOD: fill_html EXPORTING carrid = carrid,
                   html_viewer->set_visible EXPORTING visible = 'X',
                   list_viewer->set_visible EXPORTING visible = ' '.
    ELSE.
      CALL METHOD: fill_list EXPORTING carrid = carrid
                                       connid = connid,
                   list_viewer->set_visible EXPORTING visible = 'X',
                   html_viewer->set_visible EXPORTING visible = ' '.
    ENDIF.
    CALL METHOD cl_gui_cfw=>flush.
  ENDMETHOD.
  METHOD fill_html.
    DATA url TYPE scarr-url.
    SELECT SINGLE url
    FROM   scarr
    INTO   url
    WHERE  carrid = carrid.
    CALL METHOD html_viewer->show_url EXPORTING url = url.
  ENDMETHOD.
  METHOD fill_list.
    DATA: flight_tab TYPE TABLE OF demofli,
          BEGIN OF flight_title,
            carrname TYPE scarr-carrname,
            cityfrom TYPE spfli-cityfrom,
            cityto   TYPE spfli-cityto,
          END OF flight_title,
          list_layout TYPE lvc_s_layo.
    SELECT   SINGLE c~carrname p~cityfrom p~cityto
    INTO     CORRESPONDING FIELDS OF flight_title
    FROM     ( scarr AS c
               INNER JOIN spfli   AS p ON c~carrid = p~carrid )
    WHERE    p~carrid = carrid AND
             p~connid = connid.
    SELECT   fldate seatsmax seatsocc
    INTO     CORRESPONDING FIELDS OF TABLE flight_tab
    FROM     sflight
    WHERE    carrid = carrid AND connid = connid
    ORDER BY fldate.
    CONCATENATE flight_title-carrname
                connid
                flight_title-cityfrom
                flight_title-cityto
                INTO list_layout-grid_title SEPARATED BY space.
    list_layout-smalltitle = 'X'.      "The list title has small fonts,
    list_layout-cwidth_opt = 'X'.      "the column width is adjusted,
    list_layout-no_toolbar = 'X'.      "the toolbar is suppressed.
    CALL METHOD list_viewer->set_table_for_first_display
         EXPORTING i_structure_name = 'DEMOFLI'
                   is_layout = list_layout
         CHANGING  it_outtab         = flight_tab.
  ENDMETHOD.
ENDCLASS.
LOAD-OF-PROGRAM.
  CALL SCREEN 100.
*---------------------------------------------------------------------*
*       MODULE status_0100 OUTPUT                                     *
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  SET TITLEBAR 'TIT_100'.
  CALL METHOD screen_init=>init_screen.
ENDMODULE.
*---------------------------------------------------------------------*
*       MODULE cancel INPUT                                           *
*---------------------------------------------------------------------*
MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.
 
****************
PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
 MODULE cancel AT EXIT-COMMAND.
 
 
阅读(8081) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

chinaunix网友2009-11-18 14:00:47

简单易懂就是程序