Hosting BSP and Web Dynpro Applications

RFC Connector offers a simple and straightforward way of integrating SAP web applications like Web Dynpro and BSP.

Using the BSPApplication object offers several advantages in comparison to launching the application in the web browser:

  • You can preset user and password; SSO is also supported
  • You have complete control about the window size, title and position
  • BSPApplication windows are modal (blocking the UI of the host application)
  • BSPApplication windows have no back buttons or address bar, so the user cannot navigate away
  • BSPApplication can return parameters from the web app to the host application
  • The web app can close itself, and you can (optionally) warn the user if he uses the close button

Creating a BSPApplication object

Before calling the web application, you must create the BSPApplication object, and set its HttpSystemData, LogonData and Window properties:

The port number is normally Sysnr+8000. You can look it up in the system with transaction SMICM (use „GoTo“ -> „Services“)

 Dim bsp As New BSPApplication

 bsp.HttpSystemData.Host = "myhost"
 bsp.HttpSystemData.Port = "myport"

 bsp.Window.Left = 100
 bsp.Window.Top = 100
 bsp.Window.Height = 800
 bsp.Window.Width = 600
 bsp.Window.Title = "My BSP Window"

 bsp.LogonData.Client = "000"
 bsp.LogonData.User = "myuser"
 bsp.LogonData.Password = "mypassword"
 bsp.LogonData.Language = "en"

Optionally, you can define a warning message which is displayed when the user clicks on the close button:

 bsp.Window.CloseWarning = "Do you really want to close this window?" & vbCrLf & "Data loss may occur"

Calling the Application

Before you can use a BSP Application, you need to activate it in the SAP System using transaction SICF
To launch a BSP Application, we call the ShowApplication method:

bsp.ShowApplication "/sap/bc/bsp/sap/htmlb_samples/default.htm"

Exit Pages

Sometimes it is useful for a web application to return values to the caller, and/or to close itself when the user has finished working with it. With RFC Connector, these functionality can be implemented by using exit pages.

The idea behind exit pages is that a web application contains links or buttons which link to a special page (the exit page). If the user navigates to that page, the BSPApplication object intercepts that navigation, closes the window and returns the parameters submitted.

In the following section, we implement a simple BSP application which contains an input field and a button. If the user presses the button, the value entered in the input field is transmitted to the calling program.

Source Code for the BSP Application

The following code must be entered in the SAP system. To create the web application in SAP, use transaction SE80. In SE80, choose „Workbench“ -> „Edit Object“ -> „Web Objects“ -> „BSP Application“ and enter Z_EXITPAGE as name. After the application is created, create a page named index.htm by right-clicking the Z_EXITPAGE node on the left and choosing „Create“ -> „Page“ from the context menu. Select „Page with Flow Logic“ as page type, then paste the following source code

Source Code (Plain HTML)

  <form action="ExitPage.htm">
   <input type="text" name="input1" />
   <input type="submit" value="Exit Application" />

Alternative Source Code (HTMLB)

If you are using HTMLB, the code is slightly more complicated, because you need to call the exit page in an event handler. Here‘s the sample page source in HTMLB:

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>

 <htmlb:page title = "Exit Page Example">
   <htmlb:inputField   id            = "Input1" />
    <htmlb:button      text          = "ExitApplication"
                       onClick       = "ExitButtonClick" />

Note that we do not navigate to the exit page here, because that happens in the OnInputProcessing event handler:

  • event handler for checking and processing user input and
  • for defining navigation
DATA: event TYPE REF TO cl_htmlb_event,
      value TYPE string.

event = cl_htmlb_manager=>get_event( runtime->server->request ).
IF event->name = 'button' AND event->event_type = 'click'.
  value = request->get_form_field( 'input1' ).

  navigation->set_parameter( name = 'input1' value = value ).
  navigation->goto_page( 'ExitPage.htm' ).

Source Code for the calling program

Regardless of whether you went for the plain HTML or HTMLB solution above, the coding on the client side is the same: Call ShowApplication with the name of your exit page as the second parameter, and read out the Parameters property after the method has returned:

bsp.ShowApplication "/bc/bsp/sap/z_exitpage/index.htm", "ExitPage.htm"

 MsgBox "You have entered " & bsp.Parameters("input1").Value