
WebRFC Programming
Purpose
The WebRFC Gateway Interface is an implementation model of the Internet Transaction Server (ITS) for developing screen-independent applications that access data in the SAP System by calling remote-enabled function modules (RFCs) or Business APIs (BAPIs). Users can start these applications from a Web browser.
Accessing Data From the Internet
Internet technology provides a means of retrieving all kinds of information in a unified way and presenting it to the user in a Web browser. Two components in this process are:
Web servers facilitate the transmission of data from and to the Web browser client. The method of communication used in most cases is HyperText Transfer Protocol (HTTP).
URLs address the data.
Although Web servers are designed to transmit documents, they cannot themselves retrieve or process data, so another mechanism is required to process client requests, generate HyperText Markup Language (HTML) pages dynamically, and display information in a Web browser. This role is fulfilled by various support interfaces such as:
The CGI is one of the current technical standards for interfacing external applications with information servers. It defines the interface between the Web server and the server-side gateway programs, which are known as CGI scripts. These programs can process user input, retrieve data from a database or other data source, and generate HTML pages from the data at runtime.
The CGI:
In the case of binary data, the CGI script sends an identification string to inform the browser about the data format. There is a standard list of format identification strings for most binary data formats. This is known as Multiple Internet Mail Extension (MIME).
Accessing R/3 From the Internet
The WebRFC Gateway Interface allows ABAP developers to write WebRFC applications using function modules instead of CGI scripts.
The link between the Web server and R/3 is provided by the SAP Internet Transaction Server (ITS), which acts as a generic CGI program for the WebRFC. The following graphic, which also shows other support interfaces such as Microsoft Internet Server API (ISAPI) and Netscape API (NSAPI), illustrates this process:
Accessing R/3 via the Internet Transaction Server (ITS)

Interaction Between the ITS and R/3
If you set up Web pages containing URLs, which link to the R/3 System, and a user makes a request by selecting one of these links in a Web browser, the request is processed as follows:
All the parameters in the URL are passed to an internal table. One of these parameters contains the name of the function module to be called and is therefore mandatory.
Although one function module normally acts as the entry point, other functions can be accessed using links in generated HTML pages. These HTML pages may themselves contain links to other destinations in the Internet.
Interaction Between ITS and R/3

In WebRFC technology, any call from the Internet to a function module is embedded in a URL.

http://<mymachine:myport>/scripts/wgate/xgwfc/!?_FUNCTION=WWW_GET_REPORT&_REPORT=RDTEST01
This URL contains a call to the standard function module WWW_GET_REPORT which gets and executes report RDTEST01.
You can specify parameter values for the function module in the URL. Alternatively, the Web browser can gather parameter values from user input on an HTML form.
Web-enabled Function Modules
All function modules used in WebRFC applications have the same standardized interface. xxxxxx
Interface of Web-enabled Function Modules
TABLES parameters |
QUERY_STRING |
This table contains all URL parameters passed from the Web browser to a function module. | |
HTML |
This table contains an HTML page generated by the called function module and returned to the Web browser. You can return either HTML data or MIME data (see below), but not both at the same time. You can also use the CONTENT_TYPE parameter (see below) to tell the Web browser the format of the data. | ||
MIME |
This table contains binary data (such as an image) sent by the called function module and returned to the Web browser. You can return either MIME data or HTML data (see above), but not both at the same time. You can also use the CONTENT_TYPE parameter (see below) to tell the Web browser the format of the data. | ||
CHANGING parameters |
CONTENT_TYPE |
This parameter specifies the type of data returned in the HTML or MIME table. The value of CONTENT_TYPE must be one of the file types known to your Web browser:
If, for example, The default value for this parameter is text/html . | |
CONTENT_LENGTH |
This parameter specifies the length of the data returned in the HTML or MIME table. You must set a value for binary data. | ||
RETURN_CODE |
This parameter specifies whether the RFC connection to an R/3 System is closed after a call and whether the ITS session is closed. Possible values are as specified below: | ||
0 |
Close RFC connection after this call (default). | ||
1 |
Keep RFC connection open after this call. | ||
2 |
Close RFC connection and close ITS session. | ||

If you want to link to an existing function module that is not Web-enabled, you must write a caller module to convert from the standardized Web-enabled interface to the existing interface.
You can use the function module WWW_MODEL_MODULE as a template for writing Web-enabled function modules.
Further Information
WebRFC Application Development WebRFC Logon Administration WebRFC Service File Administration Web ReportingFor a comprehensive description of RFC technology and detailed information about RFC programming, see:
RFC Programming in ABAP