SAP 跟踪记录用户 UINFO

来源:互联网 发布:节拍器软件电脑版 编辑:程序博客网 时间:2024/06/05 11:49
  1. TYPE-POOLS: slis.                      " ALV Global Types  
  2.   
  3. DATA :  
  4.   gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04  
  5.   
  6. *---------------------------------------------------------------------*  
  7. START-OF-SELECTION.  
  8.   
  9.   PERFORM f_read_data.  
  10.   
  11.   PERFORM f_display_data.  
  12.   
  13. *---------------------------------------------------------------------*  
  14. *       Form  F_LIRE_DATA  
  15. *---------------------------------------------------------------------*  
  16. FORM f_read_data.  
  17.   
  18.   REFRESH gt_user.  
  19.   
  20. * Get User's info  
  21.   CALL FUNCTION 'THUSRINFO'  
  22.        TABLES  
  23.             usr_tabl = gt_user.  
  24.   
  25. * Wait in a task  
  26.   PERFORM f_call_rfc_wait.  
  27.   
  28. ENDFORM.                               " F_READ_DATA  
  29. *---------------------------------------------------------------------*  
  30. *      Form  F_DISPLAY_DATA  
  31. *---------------------------------------------------------------------*  
  32. FORM f_display_data.  
  33.   
  34.   DEFINE m_sort.  
  35.     add 1 to ls_sort-spos.  
  36.     ls_sort-fieldname = &1.  
  37.     append ls_sort to lt_sort.  
  38.   END-OF-DEFINITION.  
  39.   
  40.   DEFINE m_event_exit.  
  41.     clear ls_event_exit.  
  42.     ls_event_exit-ucomm = &1.  
  43.     ls_event_exit-after = 'X'.  
  44.     append ls_event_exit to lt_event_exit.  
  45.   END-OF-DEFINITION.  
  46.   
  47.   DATA :  
  48.     ls_layout     TYPE slis_layout_alv,  
  49.     lt_sort       TYPE slis_t_sortinfo_alv,  
  50.     ls_sort       TYPE slis_sortinfo_alv,  
  51.     lt_event_exit TYPE slis_t_event_exit,  
  52.     ls_event_exit TYPE slis_event_exit.  
  53.   
  54. * Build Sort Table  
  55.   m_sort 'ZEIT'.  
  56.   
  57. * Build Event Exit Table  
  58.   m_event_exit '&NTE'.                 " Refresh  
  59.   
  60.   ls_layout-zebra = 'X'.  
  61.   ls_layout-colwidth_optimize = 'X'.  
  62.   
  63.   CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'  
  64.        EXPORTING  
  65.             i_callback_program      = sy-cprog  
  66.             i_callback_user_command = 'USER_COMMAND'  
  67.             is_layout               = ls_layout  
  68.             i_structure_name        = 'UINFO'  
  69.             it_sort                 = lt_sort  
  70.             it_event_exit           = lt_event_exit  
  71.        TABLES  
  72.             t_outtab                = gt_user.  
  73.   
  74. ENDFORM.                               " F_DISPLAY_DATA  
  75. *---------------------------------------------------------------------*  
  76. *       FORM USER_COMMAND                                             *  
  77. *---------------------------------------------------------------------*  
  78. FORM user_command USING i_ucomm     TYPE syucomm  
  79.                         is_selfield TYPE slis_selfield.     "#EC CALLED  
  80.   
  81.   CASE i_ucomm.  
  82.     WHEN '&NTE'.  
  83.       PERFORM f_read_data.  
  84.       is_selfield-refresh = 'X'.  
  85.       SET USER-COMMAND '&OPT'.         " Optimize columns width  
  86.   ENDCASE.  
  87.   
  88. ENDFORM.                               " USER_COMMAND  
  89. *---------------------------------------------------------------------*  
  90. *      Form  F_CALL_RFC_WAIT  
  91. *---------------------------------------------------------------------*  
  92. FORM f_call_rfc_wait.  
  93.   
  94.   DATA lv_mssg(80).                                         "#EC NEEDED  
  95.   
  96. * Wait in a task  
  97.   CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'  
  98.     PERFORMING f_task_end ON END OF TASK  
  99.     EXPORTING  
  100.       seconds               = 5        " Refresh time  
  101.       busy_waiting          = space  
  102.     EXCEPTIONS  
  103.       RESOURCE_FAILURE      = 1  
  104.       communication_failure = 2  MESSAGE lv_mssg  
  105.       system_failure        = 3  MESSAGE lv_mssg  
  106.       OTHERS                = 4.  
  107.   
  108. ENDFORM.                               " F_CALL_RFC_WAIT  
  109. *---------------------------------------------------------------------*  
  110. *      Form  F_TASK_END  
  111. *---------------------------------------------------------------------*  
  112. FORM f_task_end USING u_taskname.  
  113.   
  114.   DATA lv_mssg(80).                                         "#EC NEEDED  
  115.   
  116. * Receiving task results  
  117.   RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'  
  118.     EXCEPTIONS  
  119.       RESOURCE_FAILURE      = 1  
  120.       communication_failure = 2  MESSAGE lv_mssg  
  121.       system_failure        = 3  MESSAGE lv_mssg  
  122.       OTHERS                = 4.  
  123.   
  124.   CHECK sy-subrc EQ 0.  
  125.   SET USER-COMMAND '&NTE'.             " Refresh  
  126.   
  127. ENDFORM.                               " F_TASK_END  

0 0
原创粉丝点击