码迷,mamicode.com
首页 > 其他好文 > 详细

Receiving Results from an Asynchronous RFC

时间:2019-06-14 21:44:00      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:block   replace   out   fresh   failure   must   ica   you   sse   

REPORT  ZTEST_RFC.

DATA: INFO LIKE RFCSI,
* Result of RFC_SYSTEM_INFO function
      SYSTEM_MSG(80) VALUE SPACE.
* Exception handling

CALL FUNCTION 'RFC_SYSTEM_INFO'
     STARTING NEW TASK 'INFO'
     PERFORMING RETURN_INFO ON END OF TASK.
WRITE: 'Wait for reply'.
...
AT USER-COMMAND.
* Return from FORM routine RETURN_INFO
   IF SYSTEM_MSG = SPACE.
     WRITE: 'Destination =', INFO-RFCDEST.
   ELSE.
     WRITE SYSTEM_MSG.
   ENDIF.
...
FORM RETURN_INFO USING TASKNAME.

  RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'
      IMPORTING  RFCSI_EXPORT = INFO
      EXCEPTIONS SYSTEM_FAILURE MESSAGE SYSTEM_MSG.

*  REFRESH SCREEN. "Simulate command field = return key"this is obsolete
  SET USER-COMMAND 'OKCD'.
ENDFORM.

The SET USER-COMMAND ‘OKCD’ statement replaces the REFRESH SCREEN command. REFRESH SCREEN is no longer maintained and should therefore not be used.if the user had entered the function in the command field and pressed ENTER. The current positioning of the list and the cursor are thus taken into account.

CALL FUNCTION 'XXXXXXX'
      STARTING NEW TASK 'AAA'
      DESTINATION 'NONE'
      PERFORMING RETURN_INFO ON END OF TASK
      EXPORTING
        I_VBELN               = L_VBELN
      TABLES
        E_RETURN              = L_IT_RETURN[]
      EXCEPTIONS
        COMMUNICATION_FAILURE = 1  MESSAGE MSG
        SYSTEM_FAILURE        = 2  MESSAGE MSG.

    IF SY-SUBRC = 0.
      WAIT UNTIL SEMAPHORE = 'X'.
    ELSE.
      WRITE MSG.
      MESSAGE 'Synchronize Failed' TYPE 'A'.
    ENDIF.


FORM RETURN_INFO USING TASKNAME.
  RECEIVE RESULTS FROM FUNCTION 'XXXXXXX'
      IMPORTING  RFCSI_EXPORT = AAA
        TABLES E_RETURN  = GV_IT_RETURN[]
      EXCEPTIONS
         COMMUNICATION_FAILURE = 1 MESSAGE MSG
         SYSTEM_FAILURE        = 2 MESSAGE MSG.
  RET_SUBRC = SY-SUBRC. "Set RET_SUBRC
  SEMAPHORE = 'X'. "Reset semaphore
ENDFORM.     

You can use the WAIT statement with PERFORMING form ON END OF TASK to wait for the reply to a previously started asynchronous call. In this case, WAIT must be in the same program context.

Receiving Results from an Asynchronous RFC

标签:block   replace   out   fresh   failure   must   ica   you   sse   

原文地址:https://www.cnblogs.com/aurora-cj/p/11025467.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!