cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering data transfer when leaving a page

Martin-S
Employee
Employee
0 Kudos

Hi,

I want to control a bsp-application (running in a browser in the GUI) from the program which started the application.

1) The control information can be transferred to the bsp via parameters in an url to the same bsp (or is there a better way?)

2) When an new 'control-url' is sent to the bsp the data in the view is not transferred to the corresponding fields in the model. How can I force the data transfer? Do I need an 'onUnLoad'-event which triggers the 'normal' methods of the controller? And if so, in which bsp-extension tag can I register this handler?

Regards, Martin

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181879
Active Contributor
0 Kudos

Hallo Martin,

First, allow me to answer with an ALL UPPERCASE WARNING: the SAPGUI keeps one session on the backend. If you should now run a BSP application inside the HTML control in the SAPGUI, this BSP application will ALWAYS run in another session. This means that you will have two sessions open on the backend. (If the BSP application is stateless, it is not so bad.) It is not easy to exchange information between the two sessions. You can either do it at the front-end, or at the backend via shared memory. (In WebAS 640 you could consider ABAP shared objects.)

You write: "I want to control a bsp-application (running in a browser in the GUI) from the program which started the application.". I would like to reformulate this sentence: "I want to control a web application (running in a browser in the GUI) from the program which started it." This is not because I would like to remove responsibility away from BSP. But more, I suspect that some documentation reading work is required. Once you understand how the HTML control in the SAP GUI works, and have a working example, we can at what it would take to do the same in BSP.

Some things you can look at:

(*) Transaction SE38, program SAPHTML_EVENTS_DEMO.

(*) Transaction SE80, menu Environment --> Reuse Library. In the tree on the left, look at Controls --> HTML Viewer.

From your append, points (1) and (2) I don't really understand. The reason is probably that I have never before worked with the HTML control.

Nevertheless, allow me to write a few comments. You write that you wish the SAPGUI application and the BSP application to interact. I suspect that this will not really be possible. When we look at the above listed examples, we can see that it is easily possible for the browser application to fire information into the SAPGUI program. How is this done? We look at the source (right mouse, View Source), and see this interesting piece of code:

  


    

First Name
    

Last Name
    


  

The interesting part here is the "action" for the form. This defines a new type of URI, that seems to be picked up by the SAPGUI.

Why I think BSP will not work here? The BSP runtime is 100% build on top of the HTTP framework provided by the ICM and ICF. It expects an incoming HTTP request to process, and expects to be running in the HTTP context. However, with the above action, the data is transfered to the SAPGUI, and lands at the backend via the DIAG channel. No HTTP context :(.

(Of course, you could consider to make a HTTP client request on the backend with these form data back into BSP runtime, but I don't even want to hear about this.)

So what is still possible? Probably could write you SAPGUI application standalone, and BSP application standalone. If you wish to communicate from BSP application to SAPGUI, just add a second form. Use some clever JavaScript to place all information into hidden input fields in this form, and set the action to SAPEVENT. Submit the form against the SAPGUI.

Important: I have never done this before, and am moving here on slightly thin ice. If you should build a small test program, we could consider to look at it once more.

bye, brian

Martin-S
Employee
Employee
0 Kudos

Hi Brian,

in the application to develop the interaction between the bsp and the SAPGUI-program is restricted to special cases - so no general interaction has to be considered.

The data transfer from bsp to the SAPGUI-program is done with the SAPEVENT - and it's working fine (e.g. via a called page that gets the data from the bsp in a page attribute build up like SAPEVENT:<parameter>=<value>. In that page the attribute is used in the meta-tag to get a refresh with this 'SAPEVENT-url'. The event is captured in the SAPGUI-application and can now use the transferred information to do some processing.

It's the other case that is not quite clear to me.

Let me show the interaction with an example:

1. A SAPGUI-program is called and displays a GUI-window which contains some fields and the HTML-browser.

2. In the SAPGUI-part an object is selected and the information about this object (object key) is used as a parameter in the url to a bsp. This url is passed to the HTML-viewer which now shows the data to this object.

3. Some data in the bsp is changed now. If an event is raise in the html-page, the data is transferred to the model via data binding.

4. Again some data in the bsp is changed. But now the user selects another object in the screen of the SAPGUI-program. This new object is sent to the bsp (like step 2.) which now shows the data to this object.

5. The user press the SAVE-button in the SAPGUI. This information is sent to the bsp via a parameter (like step 2) causing the bsp-model to save the changed data of all objects dealed with so far.

The problem with step 4 is the missing data transfer: the changed data is not transferred to the model. To trigger the transfer I need something like an onunload-event (like that in the <body>-tag).

So my questions:

- How can I do this (where should I place the 'onunload' and how can I then trigger the data transfer in the controller like it is done in the 'normal' event processing.

- And why do I have to care about this? Shouldn't it be the default behaviour, that the data in a page is always transferred to the model irrespective of the way a page is left.

Regards, Martin

PS: If we need an example to discuss this further, I will send you a link and the login data via mail.

former_member181879
Active Contributor
0 Kudos

A summary for the exchanges behind the scenes, in case someone would wish to do this later.

The question was, how to tie a save button in the SAPGUI to submit the page in the browser.

When running in a normal browser, it is very easy to execute JavaScript via URL. Just enter in URL field something such as javascrpt:code;

However, this is not supported by the HTML viewer control in SAPGUI.

But there are interesting methods SET_SCRIPT and EXECUTE_SCRIPT on the class CL_GUI_HTML_VIEWER. These allow one to define dynamically a script and execute it in the browser. The script will be something to submit the form.

Example program: SAPHTML_SCRIPT_DEMO.

One small hurdle. These methods are protected (don't ask me!), and can not be directly used. You must first define a new class that derive from this class, and then you have access to these methods.

brian