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. |