IT干货网

ABAP-System Function Call

leader 2022年03月09日 SAP 150 0

函数组:THFB

1.函数TH_WPINFO:当前进程处理清单,可用于判断当前程序或是函数是否重复执行。

 

 直接调用 'ThWpInfo' 与上面TH_WPINFO有些差异,可用下面代码进行测试。

  "是否作业正在执行 
  data: lv_line type i, 
        lv_name type uname. 
  data: lv_opcode(1) type x, 
        lv_with_cpu type x value 0. 
  constants: 
        lc_opcode_wp_list like lv_opcode value 1. 
 
  call 'ThWpInfo' id 'OPCODE' field lc_opcode_wp_list 
                  id 'TAB'    field lt_wpinfo-*sys* 
                  id 'CPU'    field lv_with_cpu. 
  loop at lt_wpinfo assigning field-symbol(<fs_wpinfo>) 
  where wp_mandt  = sy-mandt 
    and wp_report = sy-repid. 
    lv_line = lv_line + 1. 
    if lv_line = 1. 
      lv_name = <fs_wpinfo>-wp_bname. 
    endif. 
  endloop. 
  if lv_line >= 2. 
    message e001(00) with text-113 lv_name. 
  endif.
View Code

 2.函数TH_LONG_USR_INFO:用户信息

 

 3.函数TH_PLUGINS_ACTIVE

 4.函数TH_POPUP:弹出框

 5.函数TH_QRFC_REQUESTS:QRFC队列

 6.函数TH_REQUEST_QUEUE

 

 7.函数TH_USER_INFO

8.获取当前运行的函数名

form frm_private_get_funcname using fv_funam. 
  data: 
    lt_callstack   type abap_callstack, 
    lt_e_callstack type sys_callst. 
  field-symbols: 
    <fs_stack>     type sys_calls. 
 
  call function 'SYSTEM_CALLSTACK' 
    exporting 
      max_level          = 30 
    importing 
      callstack          = lt_callstack 
      et_callstack       = lt_e_callstack . 
 
  loop at lt_e_callstack assigning <fs_stack> 
  where eventtype = 'FUNC'. 
    fv_funam = <fs_stack>-eventname. 
    exit. 
  endloop. 
endform.
form frm_public_program_name using fv_tcode type sy-tcode 
                                   fv_repid type sy-repid. 
  data: 
    lv_fchar       type c, 
    lv_pchar       type c. 
  data: 
    lt_callstack   type abap_callstack, 
    lt_e_callstack type sys_callst. 
  field-symbols: 
    <fs_stack>     type sys_calls. 
 
  call function 'SYSTEM_CALLSTACK' 
    exporting 
      max_level          = 30 
    importing 
      callstack          = lt_callstack 
      et_callstack       = lt_e_callstack . 
 
  "事务代码首字符 
  lv_fchar = sy-tcode+0(1). 
  lv_pchar = sy-repid+0(1). 
 
  if lv_fchar = 'Z' or lv_pchar = 'Z'. 
    fv_tcode = sy-tcode. 
 
    loop at lt_e_callstack assigning <fs_stack>. 
      clear:lv_fchar. 
      lv_fchar = <fs_stack>-progname+0(1). 
      if lv_fchar = 'Z'. 
        fv_repid = <fs_stack>-progname. 
      endif. 
    endloop. 
  else. 
    loop at lt_e_callstack assigning <fs_stack> 
    where eventtype = 'FUNC'. 
      fv_tcode = sy-tcode. 
      fv_repid = <fs_stack>-eventname. 
      exit. 
    endloop. 
  endif. 
endform.
View Code

评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

ABAP-Background Job