ABAP-多线程处理详解编程语言

  1 *&---------------------------------------------------------------------* 
  2 *& Report  ZRICO_TEST26 
  3 *& 
  4 *&---------------------------------------------------------------------* 
  5 *& 
  6 *& 
  7 *&---------------------------------------------------------------------* 
  8 report zrico_test26. 
  9 data:gv_taskname(12) type c, "task name(同时运行的任务名称必须保持唯一) 
 10      gv_classname    type rzlli_apcl,   "Server Group Name 
 11      gv_applserver   type rzllitab-applserver. "RFC Serve Group 
 12 data:gv_lin      type char10, 
 13      gv_job      type i, 
 14      gv_end      type c, 
 15      gv_mess(40) type c.        "并发执行出错信息 
 16 data:begin of wa_tab, 
 17        num1     type vbap-kwmeng, 
 18        num2     type vbap-kwmeng, 
 19        num3     type vbap-kwmeng, 
 20        flg      type c, 
 21        exflg    type c, 
 22        taskname type string, 
 23      end of wa_tab. 
 24 data:gt_tab like table of wa_tab. 
 25 field-symbols: 
 26     <fs_tab> like wa_tab. 
 27  
 28 start-of-selection. 
 29  
 30   call 'C_SAPGPARAM'                                      "#EC CI_CCALL 
 31     id 'NAME'  field 'rdisp/myname' 
 32     id 'VALUE' field gv_applserver. 
 33  
 34   select single classname 
 35      from rzllitab 
 36      into gv_classname   "Server Group Name 
 37     where applserver = gv_applserver 
 38       and grouptype = 'S'.   "S:服务器组,空:登陆组 
 39  
 40   "shift gv_classname left deleting leading space. 
 41  
 42   do 200 times. 
 43     gv_lin = gv_lin + 1. 
 44     call function 'CONVERSION_EXIT_ALPHA_INPUT' 
 45       exporting 
 46         input  = gv_lin 
 47       importing 
 48         output = gv_lin. 
 49  
 50     append initial line to gt_tab assigning <fs_tab>. 
 51     <fs_tab>-num1 = sy-index. 
 52     concatenate 'TASK' gv_lin into <fs_tab>-taskname. 
 53     condense <fs_tab>-taskname no-gaps. 
 54     unassign <fs_tab>. 
 55   enddo. 
 56  
 57  
 58   loop at gt_tab assigning <fs_tab>. 
 59     clear:gv_end. 
 60  
 61     write:/10 <fs_tab>-taskname,'BEGIN'. 
 62  
 63     call function 'ZRICO_NEW_TARK' 
 64       starting new task <fs_tab>-taskname 
 65       destination in group gv_classname 
 66       performing frm_subroutine_done on end of task 
 67       exporting 
 68         i_num                 = <fs_tab>-num1 
 69       exceptions 
 70         communication_failure = 1 message gv_mess 
 71         system_failure        = 2 message gv_mess 
 72         resource_failure      = 3. 
 73     if sy-subrc = 0. 
 74       <fs_tab>-exflg = 'Y'. 
 75       gv_job = gv_job + 1. 
 76     else. 
 77       <fs_tab>-exflg = 'N'. 
 78     endif. 
 79  
 80     write:/10 <fs_tab>-taskname,'END'. 
 81  
 82   endloop. 
 83  
 84   loop at gt_tab assigning <fs_tab>. 
 85     write:/10 <fs_tab>-num1,<fs_tab>-num2,<fs_tab>-flg,<fs_tab>-exflg,<fs_tab>-taskname. 
 86   endloop. 
 87  
 88 form frm_subroutine_done using gv_taskname. 
 89   data:lv_num type vbap-kwmeng. 
 90   field-symbols: 
 91     <fs_tab> like line of gt_tab. 
 92  
 93   receive results from function 'ZRICO_NEW_TARK' 
 94     importing 
 95       e_num          = lv_num. 
 96  
 97   loop at gt_tab assigning <fs_tab> 
 98   where taskname = gv_taskname. 
 99     <fs_tab>-num2 = lv_num. 
100     <fs_tab>-flg  = 'X'. 
101   endloop. 
102  
103   gv_end = 'X'. 
104 endform.

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/17960.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论