Professional Documents
Culture Documents
by Neeraja
This document describes how the Custom RFC client application in SAP R/3 System invokes a free
Web service (that is hosted over the internet) using SAP XI. For our demo purpose, we have used a
free web service available on the Internet. Details for the same are provided in the next section.
About the web service:
In this example scenario we will be using GetQuote method of Web service DelayedStockQuote.
This method retrieves the Stock quote for the given Stock symbol. The method GetQuote has an
input that takes in two parameters Stock Symbol and License Key and returns the following
information.
StockSymbol,
LastTradeAmount,
LastTradeDateTime,
StockChange,
OpenAmount,
DayHigh,
DayLow,
StockVolume,
PrevCls,
ChangePercent,
FiftyTwoWeekRange,
EarnPerShare,
PE,
CompanyName.
Link to webservice:
http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?op=GetQuote
WSDL of the webservice:
http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?WSDL
Download WSDL from the above link.
1.
1.1 Create
RFC
destination:
To
create
the
RFC
go
to
TCODE:
SM59
Create
new
destination
of
type
T
(TCP/IP)
Make sure you select Registered Server Program option before writing your program ID
Write
your
program
ID
(remember
it's
case-sensitive)
In the gateway host and gateway service write the values of your "Application system" business
system (R/3
System)
Export:
Source
code:
Create a report program in the R/3 system which makes Synchronous call of a remote-enabled
function module ZN_GET_QUOTE.
Code snippet
REPORT ZTEST_WEBSERVICE.
parameters: p_stsym(30).
data:
StockSymbol type char30,
LastTradeAmount type char30,
LastTradeDateTime type char30,
StockChange type char30,
OpenAmount type char30,
DayHigh type char30,
DayLow type char30,
StockVolume type char30,
PrevCls type char30,
EarnPerShare type char30,
companyname type char30,
QuoteError type char30.
CALL FUNCTION 'ZN_GET_QUOTE' destination 'RFC'
EXPORTING ST_SYM = p_stsym LKEY = '0' IMPORTING
StockSymbol = StockSymbol
LastTradeAmount = LastTradeAmount
StockChange = StockChange
OpenAmount = OpenAmount
DayHigh = DayHigh
DayLow = DayLow
StockVolume = StockVolume
PrevCls = PrevCls
EarnPerShare = EarnPerShare
companyname = companyname
QUOTEERROR = QuoteError.
if quoteerror NE 'true' and quoteerror NE 'TRUE'.
write:
/'StockSymbol:',StockSymbol,
/'LastTradeAmount:',LastTradeAmount,
/'LastTradeDateTime:',LastTradeDateTime,
/'StockChange:',StockChange,
/'OpenAmount:',OpenAmount,
/'DayHigh:',DayHigh,
/'DayLow:',DayLow,
/'StockVolume:',StockVolume ,
/'PrevCls:',PrevCls,
/'EarnPerShare:',EarnPerShare,
/'companyname:',companyname,
/'QuoteError:',QuoteError.
else.
write:/ 'Invalid Stock symbol'.
endif.
2.
Import the WSDL of the webservice as an External Definition; these structures are needed as we
need to accomplish the mapping between the RFC.Request to SOAP.Request and SOAP Response
to RFC Response.
Note: Usually when we import the WSDL as an External Definition, we get the relevant messages for
the request and response structures along with it.
Import
the
RFC
ZN_GET_QUOTE
created
in
the
previous
step
from
R/3
system.
Note: Usually when we import the RFC from R/3 system, we get the relevant messages for the
request and response structures along with it.
2.3 Define Message Interface
As imported WSDL and RFC messages can be used as Data types, Message types and outbound
message interface we dont require creating those.
Define inbound synchronous message Interface
Here we need to create two mappings, first between RFC Request (ZN_GET_QUOTE.Request) to
SOAP Request (GetQuoteSoapIn) and second between SOAP Response (GetQuoteSoapOut) to
RFC Response (ZN_GET_QUOTE.Response).
Request mapping
Response mapping
Continued...
3.
Create Sender Communication channel (RFC adapter) under the Sender Business system
Make sure the Program id specified here and the Program id specified in the RFC destination created
above are same.
3.2 Create receiver communication channel
Create Receiver communication channel (SOAP adapter) under the Receiver business service.
We
need
to
specify
the
following
in
the
SOAP
adapter;
4.
In the Sender R/3 system Execute the Report program we have created earlier. When the program is
executed with Stock symbol it should get the details of that stock symbol from the Webservice.
Below is the screenshot of the output we got when the program is executed with the StockSymbol R