ALV式的弹出窗口

原文:http://blog.csdn.net/lijunhai/article/details/1968814


在系统标准程序下,有不少屏幕在检查或过帐时会弹出一个小型的ALV窗口,上面记录着错误信息,这种ALV弹出式窗口可通过以下方法做成:
(1)定义ALVBOX
data:box_container type ref to cl_gui_dialogbox_container,
     box_alv type ref to cl_gui_alv_grid.
class lcl_event_handler definition.
 public section.
 class-methods:
on_close for event close of cl_gui_dialogbox_container importing sender.
endclass.
class lcl_event_handler implementation.
 method on_close.
   call method sender->free.
    free: box_container, box_alv.
 endmethod.
endclass.
data: ls_fcat type lvc_s_fcat., "ALV的fieldcat属性行
lt_fieldcat type lvc_t_fcat. "ALV的fieldcat属性内表
data: ls_layout type lvc_s_layo. " ALV的layout属性内表
可双击父类lvc_t_fcat、lvc_s_layo来查看所包含的属性
(2)建立ALV对象
    create object box_container
      exporting
        width   = 600      "窗口大小
        height = 200
        top     = 120
        left    = 120
        caption = '提示信息' "弹出窗口标题
      exceptions
        others = 1.
set handler lcl_event_handler=>on_close for box_container.
 create object box_alv
    exporting
      i_parent         box_container
    exceptions
      others           = 1.
(3)输出ALV的fieldcat属性和layout属性
call function 'LVC_FIELDCATALOG_MERGE'
 exporting
   i_structure_name          = 'ZSTAB'   "输出格式对应的结构
 changing
   ct_fieldcat                = lt_fieldcat "ALV的fieldcat属性内表
 exceptions
   inconsistent_interface       = 1
   program_error             = 2
   others                    = 3.
注:要事先在se11创建一个和ALV输出字段一致的结构ZSTAB;
      "写入fieldcat的属性
loop at lt_fieldcat into ls_fcat.
 ls_fcat-icon = 'X'.
 ...
  modify lt_fieldcat from ls_fcat.
endloop.
"写入layout属性
ls_layout-cwidth_opt = 'X'.
...
(4)调用方法显示ALV窗口
call method box_alv->set_table_for_first_display
 exporting
   i_structure_name              = 'ZBGER' "输出格式对应的结构
   is_layout                   = ls_layout "layout属性
   i_default                   = 'X'
 changing
   it_outtab                   = itab "内表
   it_fieldcatalog               = lt_fieldcat "fieldcat属性
 exceptions
   others                        = 1.

 

弹出式窗口另外做法:可使用write到屏幕的办法,如下:

(1)在程序中创建一个screen type 为“方式对话框”的屏幕;
(2)在屏幕输出前,write要输出的数据:
process before output.
 modiule frm_write_out.
(3)在module里写输出到屏幕的代码
module frm_write_out output.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
NEW-PAGE NO-TITLE.
write ...
LEAVE SCREEN.
endmodule.
http://blog.sina.com.cn/sapliumeng
原文地址:https://www.cnblogs.com/senlinmu110/p/3802245.html