Skip to Content
Introduction
There has been some recent discussion on the ABAP forum about Calling a BSP application from a report. I thought I might share a solution we have used at our company. Please note that is weblog was updated on 9/14/2004 with a suggestion from Brian McKellar.

We developed a simple RFC that can be called locally on our WebAS or remotely from our R/3 or BW systems. This RFC will display a screen that has a HTML View control in it. You might be thinking – What’s so special about that. Well good question. There are two advantages to doing it this way.

Single Sign On
First you get Single Sign On with very little effort. This is new functionality that is available only with a combination of certain support packages, kernels, and SAPGui patches. The details and profile parameter changes necessary can all be found in OSS note 612670. However if you are already at the required patch levels, it should only take a few minutes to make the necessary configuration changes.

State Management
Second if your have stateful bsp applications, there is way to have simple state management without any popup windows. Many people copy the session_buffered_frame.htm or session_single_frame.htm from the system BSP application and use one of these template pages as their start page. These templates load your BSP application with a small piece of JavaScript that fires when you navigate away from the page or close the browser (at least in Internet Explorer). Currently this JavaScript uses a popup window to close out your session for a stateful application. The code sample I have here accomplishes the same thing, but without the need for the template page or the popup window.

We accomplish this simple state management with a combination of two things. First we add a simple exit.htm page to any application that we want to load into this RFC. This exit page has no coding in its layout. All we want is to have the following code in the OnInitialization event.

This will close out our session and clean up after our stateful application. Updated!: Brian McKellar has suggested an even better approach. He suggests the following: For a more simplified approach, we do not create an extra dummy page inside the application. Instead we use two interesting features from ICM and BSP together. The ICM supports a sap-sessioncmd=CANCEL mode. With this, the session is killed by ICM, and then the incoming URL is still processed inside a new session. We just require an URL that looks exactly like the application URL in the part up to the name of the application, so that the session id cookie will be send with it. After ICM has cancelled the session, the URL will still be processed. So we require an URL that will be processed by the BSP runtime without any problems (and without opening a new session!). For this, we just use a special 1×1 URL. The BSP runtime has a performance improvement that will always reply with a 1×1.gif for an incoming URL of the format “…/1×1”. However, this 1×1 image is cached, and the trick will only work once. So we just add one timestamp to make the URL unique for the browser, and have it trigger the loading of the 1×1 image.

Now all we need is a trigger to call this page. That trigger comes from the fact that we are running in an ABAP screen. Just short of the user shutting down their SAPGui without exiting the program, we should get a PAI event for any request to close the screen that holds our BSP application. That way we can force the HTML control to navigate to the exit page before we release it. It all happens so fast that the end user never sees anything.

Function Interface
Let’s take a look at the code for this function module in detail. First we look at the function interface with the high level code. You can see that we accept the name of the BSP application and the start page. We also have the option to display fullscreen or in a modal dialog box.

The screen we have is really quite simple. Just define a screen as large as possible. Place a single custom container on this screen and set it to allow resizing vertically and horizontally. This will allow our HTML control to resize itself to fill the total screen area.

PBO
Next lets look at the code in the PBO (process before output). We will start off with same basic initialization.

The create_controls forms is where all the fun stuff is going on. In addition to creating our Custom Container and the HTML control, we will need to tell the HTML control that we want SSO. Then we will generate the URL to our BSP application and navigate to it.

PAI
Now we are ready to move on to the PAI (Process After Input) and respond to our only event – the request to exit. The PAI is really quite simple we take the only two OKCodes and funnel them both to an exit and free controls form.

Finally in our free_controls form we force the HTML control to log off the applicatin. The following is the original code from this weblog.

This is the new code following the suggestion from Brian McKellar:

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Brian McKellar
    Hallo Thomas,

    Very impressive solution. It beats anything we have thought about. Simple and ellegant. A weblog that we will have to recommend to many people as required reading!

    brian

    (0) 
  2. Hi Thomas,
    great Blog! I just trying a few things out, and got a questions concerning the handling of the BSP-Events:
    I just implemented that logic, to show a BSP via an html-control in an ABAP-Dynpro. Now i want to react on the BSP-Events not only in that BSP itseld, but also on my own dynpro (e.g. when i chosse one entry from an listtable, i want to get some infos about the choosen entry also in the pai of my dynpro). Do you know if it is possible to react on that BSP-Event in that way?

    Kind regrads

    Christian

    (0) 
    1. Thomas Jung
      The answer would be yes, but be careful.  The ABAP HTML control has some special functionality to capture browser events (sapevent) and pass that back to the hosting ABAP program for event handeling there.  This can be done from static HTML or from BSP (but there is nothing specific to BSP here).  If you are interested in this, I would suggest that you read up on CL_GUI_HTML_VIEWER, the SAPGui HTML control, and SAPEVENT. 

      http://help.sap.com/saphelp_nw04/helpdata/en/7d/fe9f788af411d3805e00c04f99fbf0/frameset.htm

      http://help.sap.com/saphelp_nw04/helpdata/en/84/4a1c86a93311d2bd6e080009b4534c/frameset.htm

      Now to the be careful part.  Keep in mind that your BSP application and ABAP PAI are in completely different memory areas.  So if you want to get data from your PAI event handler back into the BSP, that might be a little trickier (but not impossible – Export to Memory or Database record exchange comes to mind). 

      (0) 

Leave a Reply