Chinaunix首页 | 论坛 | 博客
  • 博客访问: 235018
  • 博文数量: 90
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 970
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-04 15:21
文章分类

全部博文(90)

文章存档

2010年(7)

2009年(83)

我的朋友

分类:

2009-09-08 16:06:03

*&---------------------------------------------------------------------*
*& Report  Z520_7
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report  z520_7.
**********************************Class
definition*****************************************
*&---------------------------------------------------------------------*
*&       Class LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
*        Text
*----------------------------------------------------------------------*
class lcl_event_handler definition.
 public section.
    events:
    top_of_page_x.
    methods:
    top_of_page
      for event print_top_of_page of cl_gui_alv_grid,
    call_top_of_page,
    call_top_of_page_handle for event top_of_page_x of lcl_event_handler.

endclass.               "LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
*&       Class (Implementation)  LCL_EVENT_HANDLER
*&---------------------------------------------------------------------*
*        Text
*----------------------------------------------------------------------*
class lcl_event_handler implementation.
 method top_of_page.
  write: / text-003  , ':'  , sy-datum.       "Date
  write: / text-004  , ':'  , sy-uzeit.       "Time
 endmethod.
 method
   call_top_of_page.
   raise event top_of_page_x.
 endmethod.
 method
   call_top_of_page_handle.
   message i000(z0) with 'Hello'.
endmethod.
endclass.               "LCL_EVENT_HANDLER
***********************************Data
definition*****************************************
types:begin of ty_out,
      matnr type matnr,
      end of ty_out,
      ty_t_out type standard table of ty_out.
types: begin of ty_stream_text,                     "table for Stream text
       noteline(160) type c,
       end of ty_stream_text.
data : v_matnr            type mara-matnr,
       i_out              type ty_t_out,
       i_layout           type lvc_s_layo,                        "Layout of
the grid
       i_fieldcat         type lvc_t_fcat ,                       "Field
Catalog Table
       i_alv              type ref to cl_gui_alv_grid,
       i_container        type ref to cl_gui_custom_container,
       i_header_container type ref to cl_gui_custom_container,
       i_header_text      type ref to cl_gui_textedit,
       i_text_table       type standard table of tline,
       i_stream_text      type standard table of ty_stream_text.
data  wa_fieldcat type lvc_s_fcat.
data : l_event_receiver type ref to lcl_event_handler.
*******************************Selection Screen**************************
selection-screen begin of block b1.
  select-options: s_matnr for  v_matnr.
selection-screen end of block b1.
initialization.
*************************Start of
selection************************************
start-of-selection.
select matnr
from mara
into table i_out
where matnr in s_matnr.
*************************End of
selection************************************
end-of-selection.
set screen '1001'.
*CALL SCREEN '1001'.
**************************Module Pool***********************************
*&---------------------------------------------------------------------*
*&  Include           Z520_7_FORMS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_1001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_1001 output.
  set pf-status 'ZALV'.
*  SET TITLEBAR 'xxx'.
data :l_tline type tdline,
      l_date type char10,
      wa_text_table type tline.
 
clear wa_text_table.
  wa_text_table-tdformat = '*'.
  write sy-datum to l_date.
  concatenate text-003 '  :' l_date into l_tline.    "Date
  wa_text_table-tdline = l_tline.
  append wa_text_table to i_text_table.
if i_container is initial .
    create object i_container
      exporting
        container_name = text-001.
* Create an instance of alv control
    create object i_alv
      exporting
        i_parent = i_container.
* Get Field Catalog
    perform f_alv_fieldcat changing i_fieldcat.
* Get Layout
    perform f_alv_layout changing i_layout.
* Create an instance to the local class lcl_events_handler
    create object l_event_receiver.
* Events call (Event Handler) for local class lcl_events_9000
    set handler l_event_receiver->top_of_page for i_alv.
    set handler l_event_receiver->call_top_of_page_handle for
l_event_receiver.

data :l_wa_variant type disvariant .
  l_wa_variant-report = sy-repid .
 call method i_alv->set_table_for_first_display
    exporting
      is_layout                     = i_layout
*to give parameter from selection screen as variant
      is_variant                    = l_wa_variant
      i_save                        = 'A'
    changing
      it_outtab                     = i_out
      it_fieldcatalog               = i_fieldcat
    exceptions
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      others                        = 4.
                  " f_alv_first_display
 
* Create an instance of the custom container for the top_of_page
    if i_header_container is initial .
      create object i_header_container
        exporting
          container_name = text-002.

* Create an instance i_header_text for the header container
      create object i_header_text
        exporting
          parent = i_header_container.
* Switch toolbar off
      call method i_header_text->set_toolbar_mode
        exporting
          toolbar_mode = 0.

* Convert Normal text to Stream text.
      call function 'CONVERT_ITF_TO_STREAM_TEXT'
        tables
          itf_text    = i_text_table
          text_stream = i_stream_text.
* Show the text on the Screen.
      call method i_header_text->set_text_as_stream
        exporting
          text = i_stream_text.
* Only in READ-ONLY mode.
      call method i_header_text->set_readonly_mode
        exporting
          readonly_mode = 1.
*  Set the status bar mode
      call method i_header_text->set_statusbar_mode
        exporting
          statusbar_mode = 1.
    endif.
endif.
endmodule.                 " STATUS_1001  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  F_ALV_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_FIELDCAT  text
*----------------------------------------------------------------------*
form f_alv_fieldcat  changing fp_i_fieldcat type lvc_t_fcat.
*  Material as First column
  clear wa_fieldcat.
  wa_fieldcat-row_pos   = 1.
  wa_fieldcat-col_pos   = 1.
  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-tabname   = 'I_OUT' .
  wa_fieldcat-coltext   = 'Material'.
  wa_fieldcat-outputlen = 18.
  append wa_fieldcat to fp_i_fieldcat.
endform.                    " F_ALV_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  F_ALV_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_I_LAYOUT  text
*----------------------------------------------------------------------*
form f_alv_layout  changing fp_i_layout type lvc_s_layo.
* Defining the layout of the screen.
  fp_i_layout-zebra             = 'X'.
  fp_i_layout-cwidth_opt        = 'X'.
endform.                    " F_ALV_LAYOUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_1001 input.
  if sy-ucomm = 'EXIT'.
*     CALL SELECTION-SCREEN '1000'.
     leave to transaction 'Z_TRN_ALV'.
  elseif sy-ucomm = 'T1'.
      call method l_event_receiver->call_top_of_page.
  endif.
endmodule.                 " USER_COMMAND_1001  INPUT
阅读(1114) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~