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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值