Call RFC synchronize and asychronize examples

Source: Internet
Author: User

Synchronous call RFC example
*&---------------------------------------------------------------------*
* & Report sapbc1__rfcsync_s1 *
*&*
*&---------------------------------------------------------------------*

Report sapbc1__rfcsync_s1 message-ID bc1.

Tables spfli.

Parameters: icarr like SFLIGHT-CARRID default 'lh ',
Iconn like SFLIGHT-CONNID default '20140901 ',
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.

Example of asynchronous call to RFC
*&---------------------------------------------------------------------*
*&*
* & Report sapbc1__rfcasync_s1 *
*&*
*&---------------------------------------------------------------------*

Report sapbc1__rfcasync_s1 message-ID bc1.

Tables spfli.

Parameters: icarr like SFLIGHT-CARRID default 'lh ',
Iconn like SFLIGHT-CONNID default '20140901 ',
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'
Asynchronous 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 prototype
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.
Related connection: http://blog.csdn.net/CompassButton/archive/2006/11/15/1385387.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.