示例程序
REPORT ztest_hj.
DATA:t1 TYPE i,
t2 TYPE i,
t3 TYPE i.
GET RUN TIME FIELD t1.
TYPES:BEGIN OF ty_matnr,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
END OF ty_matnr.
DATA:lt_out TYPE TABLE OF ty_matnr,
ls_out TYPE ty_matnr.
*lt_out = VALUE #( ( matnr = '000000000000002020' )
* ( matnr = '000000000000090412' )
* ( matnr = '000000000000095271' ) ).
CLEAR:lt_out.
SELECT matnr mtart
INTO TABLE lt_out UP TO 100 ROWS
FROM mara.
DATA(lv_lines) = lines( lt_out ).
DATA:ls_mara TYPE mara,
lt_mara TYPE TABLE OF mara.
DATA:lv_num TYPE i.
DATA:lv_index TYPE sy-index,
lv_taskid TYPE c LENGTH 8.
DO lv_lines TIMES.
lv_index = sy-index.
lv_taskid = 'Task' && lv_index.
READ TABLE lt_out INTO ls_out INDEX sy-index.
CALL FUNCTION 'ZFMMMTEST'
STARTING NEW TASK lv_taskid
PERFORMING frm_read_result ON END OF TASK
EXPORTING
iv_matnr = ls_out-matnr.
ENDDO.
"等待执行完之后的结果
WAIT UNTIL lv_lines = lv_num.
GET RUN TIME FIELD t2.
*WAIT UP TO 3 SECONDS.
IF lt_mara IS NOT INITIAL.
WRITE: / 'Yes'.
ELSE.
WRITE: / 'No'.
ENDIF.
t3 = t2 - t1.
WRITE: / '执行时间:',t3,'微秒'.
t3 = t3 / 100 / 10000.
WRITE: / '执行时间:',t3,'秒'.
FORM frm_read_result USING taskname.
"获取返回的结果
ADD 1 TO lv_num.
RECEIVE RESULTS FROM FUNCTION 'ZFMMMTEST'
IMPORTING
ev_mara = ls_mara.
APPEND ls_mara TO lt_mara.
CLEAR ls_mara.
ENDFORM.
其中函数ZFMMMTEST