ITPub博客

首页 > IT基础架构 > 网络安全 > RFC 同步异步调用实例

RFC 同步异步调用实例

原创 网络安全 作者:qiujun 时间:2007-10-23 16:51:23 0 删除 编辑
CALL RFC synchronize and asychronize Examples

同步调用RFC 示例
*&---------------------------------------------------------------------*
*& Report sapbc415_rfcsync_s1 *
*& *
*&---------------------------------------------------------------------*

REPORT SAPBC415_RFCSYNC_S1 MESSAGE-ID BC415.

TABLES SPFLI.

PARAMETERS: ICARR LIKE SFLIGHT-CARRID DEFAULT 'LH',
ICONN LIKE SFLIGHT-CONNID DEFAULT '0400',
DEST LIKE RFCDES-RFCDEST DEFAULT 'NONE'.

DATA: SYSID LIKE SY-SYSID,
MESS(80).

CALL FUNCTION 'BC415_RFC_READ_SPFLI'
DESTINATION DEST
EXPORTING
CARRID = ICARR
CONNID = ICONN
IMPORTING
EX_SPFLI = SPFLI
SYS = SYSID
EXCEPTIONS
INVALID_DATA = 1
COMMUNICATION_FAILURE = 2 MESSAGE MESS
SYSTEM_FAILURE = 3 MESSAGE MESS.

CASE SY-SUBRC.
WHEN 1.
WRITE: / TEXT-001.
EXIT.
WHEN 2.
WRITE: / MESS.
EXIT.
WHEN 3.
WRITE: / MESS.
EXIT.
ENDCASE.

WRITE: / TEXT-004, SYSID COLOR 5.
SKIP.
WRITE: SPFLI-CARRID, SPFLI-CONNID, SPFLI-CITYFROM, SPFLI-CITYTO.

异步调用RFC示例
*&---------------------------------------------------------------------*
*& *
*& Report sapbc415_rfcasync_s1 *
*& *
*&---------------------------------------------------------------------*

REPORT SAPBC415_RFCASYNC_S1 MESSAGE-ID BC415.

TABLES SPFLI.

PARAMETERS: ICARR LIKE SFLIGHT-CARRID DEFAULT 'LH',
ICONN LIKE SFLIGHT-CONNID DEFAULT '0400',
DEST LIKE RFCDES-RFCDEST DEFAULT 'NONE'.

DATA: SYSID LIKE SY-SYSID,
MESS(80),
FLAG,
RETCODE LIKE SY-SUBRC.

CALL FUNCTION 'BC415_RFC_READ_SPFLI'
DESTINATION DEST
STARTING NEW TASK 'T1'
PERFORMING BACK ON END OF TASK
EXPORTING
CARRID = ICARR
CONNID = ICONN
EXCEPTIONS
COMMUNICATION_FAILURE = 2 MESSAGE MESS
SYSTEM_FAILURE = 3 MESSAGE MESS.

CASE SY-SUBRC.
WHEN 2.
WRITE: / MESS.
EXIT.
WHEN 3.
WRITE: / MESS.
EXIT.
ENDCASE.

WAIT UNTIL FLAG = 'X'.

CASE RETCODE.
WHEN 0.
WRITE: / TEXT-004, SYSID COLOR 5.
SKIP.
WRITE: SPFLI-CARRID, SPFLI-CONNID, SPFLI-CITYFROM, SPFLI-CITYTO.
WHEN 1.
WRITE: / TEXT-001, / TEXT-002.
WHEN 2 OR 3.
WRITE MESS.
ENDCASE.


*---------------------------------------------------------------------*
* FORM BACK *
*---------------------------------------------------------------------*
* --> T *
*---------------------------------------------------------------------*
FORM BACK USING T.

RECEIVE RESULTS FROM FUNCTION 'BC415_RFC_READ_SPFLI'
IMPORTING
EX_SPFLI = SPFLI
SYS = SYSID
EXCEPTIONS
INVALID_DATA = 1
COMMUNICATION_FAILURE = 2 MESSAGE MESS
SYSTEM_FAILURE = 3 MESSAGE MESS.

RETCODE = SY-SUBRC.

FLAG = 'X'.

ENDFORM.

RFC函数原型
FUNCTION BC415_RFC_READ_SPFLI.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(CARRID) LIKE SFLIGHT-CARRID OPTIONAL
*" VALUE(CONNID) LIKE SFLIGHT-CONNID OPTIONAL
*" EXPORTING
*" VALUE(EX_SPFLI) LIKE SPFLI STRUCTURE SPFLI
*" VALUE(SYS) LIKE SY-SYSID
*" EXCEPTIONS
*" INVALID_DATA
*"----------------------------------------------------------------------
SELECT SINGLE * FROM SPFLI INTO SPFLI_WORKAREA
WHERE CARRID = CARRID
AND CONNID = CONNID.
IF SY-SUBRC EQ 0.
EX_SPFLI = SPFLI_WORKAREA.
ELSE.
MESSAGE E007 RAISING INVALID_DATA.
ENDIF.
SYS = SY-SYSID.
ENDFUNCTION.

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/90072/viewspace-978180/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    107
  • 访问量
    849712