您的位置:首页 > 其它

ABAP--如何限制自己开发的耗时报表在sap系统中运行的个数,以保证正常业务的进行

2006-09-05 14:25 721 查看
在SAP系统中经常有许多用户自行开发的报表,有些报表运行很 耗时。如果这种报表被多个用户同时执行,通常会把服务器工作进程资源占用,导致业务操作无法正常进行。这里提去一个变通的做法,限制自行开发的耗时报表的运行个数,保证服务器工作进程资源对业务操作的响应。具体做法如下:

1、建立耗时报表登记表(zauth0003),结构如下
MANDT   集团
REPORT  耗时程序名

2、建立允许运行耗时报表的同时个数表( zauth0002),结构如下
MANDT   集团
ZNUM      个数

3、建立检查函数
function z_auth_cpu.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  EXPORTING
*"     REFERENCE(Z_RETURN_ERROR) TYPE  SY-SUBRC
*"----------------------------------------------------------------------
  data: begin of wp_tabl occurs 10.
          include structure wpinfo.
  data: end of wp_tabl.
  data: with_cpu type x value 0,
        inum type i.
  z_return_error = 0.
  inum = 0.
  refresh wp_tabl.
  select single  * from zauth0002.
  if sy-subrc <> 0 or zauth0002-znum = 0.
    zauth0002-znum = 5.
  endif.
  select single  * from zauth0003 where report = sy-cprog.
  if sy-subrc = 0.
    call function 'TH_WPINFO'
      exporting
        with_cpu = with_cpu
      tables
        wplist   = wp_tabl
      exceptions
        others   = 0.
    loop at wp_tabl.
      select single  * from zauth0003
        where report = wp_tabl-wp_report.
      if sy-subrc = 0.
        inum = inum + 1.
      endif.
    endloop.
  endif.
  if inum > zauth0002-znum.
    z_return_error = 4.
  endif.
endfunction.

4、在程序中写入以下代码,检查是否可运行。

  data:t_return_code like sy-subrc.

*判断用否可以运算
  data:t_return_error like sy-subrc.
  call function 'Z_AUTH_CPU'
    importing
      z_return_error = t_return_error.
  if t_return_error > 0.
    message e100 with '服务器达到最大会话数,请稍后再试'.
    exit.
  endif.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐