欢迎来到萧静默的博客

书山有路勤为径,学海无涯苦作舟。

RFC的远程调用-异步

接上篇RFC的远程调用-同步(https://www.cnblogs.com/BruceKing/p/11169930.html)。

TABLES:USR21.
DATA:A  TYPE USR21-PERSNUMBER,
     B  TYPE SY-SYSID,
     C1 LIKE TABLE OF USR21 WITH HEADER LINE.
DATA:MSG_TEXT(100) TYPE C.
CALL FUNCTION 'ZTESTRFCKING001' DESTINATION 'QAS600'
STARTING NEW TASK 'B1' "使用call function starting new task destination&&单独调试这一步时会进入目标系统的函数调式界面
  PERFORMING RETURN_USER ON END OF TASK"当目标系统调试完后会进入此子例程,子例程里不能有subimt,commit work等
  EXPORTING
    ZBNAME                = '0201010001'
  EXCEPTIONS
    COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT
    SYSTEM_FAILURE        = 2 MESSAGE MSG_TEXT.
IF SY-SUBRC = 0.
  WRITE:'wait'.
ELSE.
  WRITE MSG_TEXT.
ENDIF.
IF C1 IS INITIAL.
  WRITE:'请等待'.
ELSE.
  WRITE:'CONNECTION IS READY'.
ENDIF.

AT USER-COMMAND."由于回调子程序不会自动运行,设置对话步骤让其进入
  IF SY-UCOMM = 'OKCD'.
    IF MSG_TEXT IS INITIAL.
      WRITE:A, B.
      LOOP AT C1.
        WRITE:C1-PERSNUMBER.
      ENDLOOP.
    ELSE.
      WRITE:MSG_TEXT.
    ENDIF.
  ENDIF.
FORM RETURN_USER USING TASKNAME.
  RECEIVE RESULTS FROM FUNCTION ' ZTESTRFCKING001'
  IMPORTING
   ZPERSON_NUMBER        = A
   SYSTEMID              = B
    TABLES
      OUTPUT                = C1
    EXCEPTIONS
    COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT
    SYSTEM_FAILURE        = 2 MESSAGE MSG_TEXT.
  SET USER-COMMAND 'OKCD'.
ENDFORM.     "返还消息

点击后退显示主程序的

 

posted @ 2019-07-11 16:20  萧静默  阅读(765)  评论(0编辑  收藏  举报