保持SAP Session一直在线

*&---------------------------------------------------------------------*
*& Report zonline
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*


report zonline.

data: text type string,
      time type i.

time = 0.
parameters  s_time  type p  default 3800.

initialization.

start-of-selection.

  if sy-langu = '1'.
    concatenate '此程序是为了使SAP保持在线,请使用其他会话进行工作' '!' into text.
  else.
    concatenate 'Please use another session for working' '!' into text.
  endif.

  data:gt_info type table of uinfo2,
       gv_num  type i.

  "获取当前用户的会话数
  call function 'TH_LONG_USR_INFO'
    exporting
      user      = sy-uname
    tables
      user_info = gt_info.

  describe table gt_info lines gv_num.

  "对当前打开的会话数进行判断,如果只打开了一个,那么再另外打开一个新的会话供用户使用
  if gv_num = 1.
    call function 'TH_CREATE_FOREIGN_MODE'
      exporting
        client           = sy-mandt
        user             = sy-uname
*       TCODE            =
*       RETURN_ERROR     = 1
*       CREATE_EXCLUSIVE = 0
      exceptions
        user_not_found   = 1
        cant_create_mode = 2
        others           = 3.
    if sy-subrc <> 0.
* Implement suitable error handling here
    endif.
  endif.

  data k type i.

  do.
    k = k + 1.
    if k >= s_time and s_time > 0.
      message  '对话框停留时间结束'type 'S'.
      exit.
    endif.

    call function 'SAPGUI_PROGRESS_INDICATOR'
      exporting
        percentage = time
        text       = text
      exceptions
        others     = 1.
    time = time + 1.
    if time = 101.
      time = 0.
    endif.

    wait up to 60 seconds.

  enddo.


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值