Search on this Website

Monday, December 3, 2007

Learn BSP ( Busines Server Pages ) Online

BSP Concepts

Application Class


The application class, is a regular ABAP Objects class, that can be assigned to the BSP application, to ebcapsulate the BSP logic ans store data and make it available across BSP pages. This data is stored as attributes.




The only requirement for an application is that the constructor is parameter-less. If not, the application class cannot be generically instantiated by the BSP runtime environment.


The global object application can be used in the BSP application to access the attributes and methods of the application class.


You do not have to use an application class in your BSP application. It is an optional way for you to structure your BSP application .

The application class is assigned to the properties of the BSP application:



Application Basis Class CL_BSP_APPLICATION

If an application class does not already have a super class, it can be derived from the predefined base class CL_BSP_APPLICATION. This class provides methods that are typically required by a BSP application for embedding in a Web environment. This is how information about the current BSP application (such as session timeout, current URL of BSP application, state mode, and so on) can be called or set.

As the application object is an application attribute in every BSP event handler, the methods of the CL_BSP_APPLICATION class are also available with the corresponding inheritance. This makes it easy to provide the relevant functionality to lower application levels using a single object reference


Using the application class in an event

The application class is used just as an ordinary class
CALL METHOD application->kunde_gettable
IMPORTING
kunde_table = i_zkunder.


Statefull/Stateless

Statefull
A stateful BSP application is executed like a normal SAP transaction, – independent of all user interactions - in one single context (roll area). This means that data specified by the user during the application execution or data determined by the application itself is available potentially throughout the entire execution duration of the session.

Stateless
Stateless BSP applications only block resources on the SAP Web Application Server during the time one single request is being processed. When the request has been processed, all resources in particular the application context are returned to the system for use in other requests.
Statefull or Stateless ?
As a rule of thumb, it is recommended that Internet scenarios used at the same time by a large number of users operate in stateless mode. Stateful programming is recommended for more complex applications that are used by a limited number of users in parallel and that operate with data that is expensive to determine.


BSP Tips and Tricks


How to use form fields in the event handler
This examples shows how to read the value of a form field, and use it in an event handler.

The user keys in the field zzkunnavn in the form nand presses then Save button.
Layout

<%@page language="abap"%>


 <%@extension name="htmlb" prefix="htmlb"%>


<html>


<title>Use form field</title>


<h1>Use form field</h1>


<body> <form method = "post" name="x">


<input type="text" size="50" maxlength="50"
name="zzkunnavn">


<input type=submit name="onInputProcessing(save)"
value="Save">


 </form>


</body>


 </html>



Page attributes
The field zzkunnavn must be defined in the Page attributes of the screen

Event handler OnInputProcessing

CASE event_id.
data: l_kunnavn type string.
WHEN 'save'.
* Sets value of parameters, i.e. gets value from screen
navigation->set_parameter( name = 'zzkunnavn').

* Gets value of parameter, so can be moved into abap field
* Note: zzkunnavn declared in page attributes
l_kunnavn = navigation->get_parameter( name = 'zzkunnavn').


No comments: