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.
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
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.
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.
<%@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
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’).