!--a11y-->
WebRFC ProgrammingTo program WebRFCs, you use the WebRFC Gateway Interface, a programming interface that supports the development of HTML-based World Wide Web applications.
The WebRFC Gateway Interface:
· Provides a basis for applications that enable Web users to access business information in the SAP system via the Internet or Intranet
· Enables developers to write their own applications that present business information from the SAP system in an Internet-like style
Based on Remote Function Call (RFC) technology, the WebRFC Gateway Interface allows you to generate HTML pages dynamically with function modules.
Each WebRFC application consists of at least one Web-enabled function module. All Web-enabled function modules have a standardized interface and can be called from the Web using Uniform Resource Locators (URLs).
The technology behind the World Wide Web 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:
· HyperText Transfer Protocol (HTTP) servers, which facilitate the transmission of data between the server and the browser client
· Uniform Resource Locators (URLs), which address the data
HTTP servers are designed to transmit documents, but they cannot themselves retrieve or process data. For this reason, 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:
· Common Gateway Interface (CGI)
· Microsoft Information Server API (ISAPI)
· Netscape Server API (NSAPI)
The CGI is one of the current technical standards for interfacing external applications with information servers. It defines the interface between the HTTP 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:
· Specifies how a client request is passed to the CGI script by the HTTP server and how the resulting data is returned
· Defines the syntax that governs how parameters of client requests are packed into URLs
· Returns the results to the client program in the form of a data stream, which can be an HTML page or any kind of binary data (image, sound or video) that can be viewed in a Web browser
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).
The WebRFC Gateway Interface allows ABAP developers to write WebRFC applications using function modules instead of CGI scripts.
The link between the HTTP server and SAP system 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 the Internet Server API (ISAPI) and the Netscape API (NSAPI), illustrates this process:
Accessing SAP System via the Internet Transaction Server (ITS)

If you set up Web pages containing URLs, which link to the SAP system, and a Web user makes a request by selecting one of these links, the request is processed as follows:
...
1. The HTTP server forwards the request to the ITS
2. The ITS communicates with the SAP system by Remote Function Call (RFC)
3. In SAP system, a dispatcher program receives and handles the request
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 World Wide Web.
4. The called function module evaluates the parameters, retrieves and processes the data, and returns the results as an HTML page.
Interaction Between ITS and SAP System

In WebRFC technology, any call from the Web to a function module from the Web 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.
All function modules used in WebRFC applications have the same standardized interface.
Interface of Web-enabled Function Modules
TABLES parameters |
Function |
QUERY_STRING |
This table contains all URL parameters passed from the Web 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 |
Function |
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 the function returns an HTML table, CONTENT_TYPE must contain the value text/html. If the function returns a MIME table, CONTENT_TYPE must contain the correct value from the File type column, for example, image/gif or application/postscript. If, for instance, CONTENT_TYPE contains the value application/winword, the Web browser calls Microsoft Word for Windows to display the data. 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 SAP system is closed after a call and whether the ITS session is closed. Possible values are: 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.
For a comprehensive description of RFC technology and detailed information about RFC programming, see RFC Programming in ABAP.
WebRFC Application
Development
WebRFC Service File
Administration
This documentation describes the WebRFC programming model. For information about other programming models for implementing IACs, see:
