ABAP常用小技巧-知识点积累

7.29 多节点或多SERVER中取在线用户列表数据 注意使用DESTINATION
FUNCTION zgateway_get_sm04_user.
*”———————————————————————-
*”*”Local interface:
*”  EXPORTING
*”     VALUE(RETURN) LIKE  BAPIRETURN STRUCTURE  BAPIRETURN
*”  TABLES
*”      RESULT_TAB STRUCTURE  UINFO
*”———————————————————————-
  DATA:
    td_system TYPE TABLE OF msxxlist,
    th_system TYPE msxxlist,
    td_uinfo  TYPE TABLE OF uinfo,
    th_uinfo  TYPE uinfo,
    flag      TYPE c.
  CLEAR flag.
  CALL FUNCTION ‘TH_SERVER_LIST’
    TABLES
      list           = td_system
    EXCEPTIONS
      no_server_list = 1
      OTHERS         = 2.
  IF sy-subrc <> 0.
    return-type    = ‘E’.
    return-message = ‘得到服务器列表出错!ZGATEWAY_GET_SM04_USER’.
    RETURN.
  ENDIF.
  LOOP AT td_system INTO th_system.
    CALL FUNCTION ‘THUSRINFO’ DESTINATION th_system-name
      TABLES
        usr_tabl = td_uinfo
      EXCEPTIONS
        OTHERS   = 1.
    IF sy-subrc <> 0.
      flag = ‘X’.
      EXIT.
    ENDIF.
    LOOP AT td_uinfo INTO th_uinfo.
      APPEND th_uinfo TO result_tab.
      CLEAR th_uinfo.
    ENDLOOP.
  ENDLOOP.
  SORT result_tab BY mandt bname.
  delete ADJACENT DUPLICATES FROM result_tab COMPARING mandt bname.
  IF sy-subrc = 0.
    return-type = ‘S’.
    return-message = ‘读取表USR10数据成功!’.
  ENDIF.
ENDFUNCTION.

相关新闻

联系我们

联系我们

130-0752-1773

在线咨询:点击这里给我发消息

邮件:info@sapzx.com

工作时间:周一至周五9:00-18:00,节假日正常休息

关注微信
关注微信
分享本页
返回顶部