1.1 Introduction
Features of the Web Application Builder
· Creating BSP applications and their pages (BSPs)
· Editing the layout of BSPs using HTML and the scripting languages ABAP and JavaScript
· Declaring page parameters for page-based data storage
· Implementing event handlers using ABAP
· Defining the page flow using navigation requests
· Integration of the MIME Repository for storing MIME objects
· Creating and defining themes for adjusting the layout
· Provision of an interface for using external tools for layout implementation using the WebDAV protocol
Prerequisites
§ Any external Web development environments that you want to use for implementing the page layout must support the WebDAV protocol.
External HTML editors function as the WebDAV client, while the mySAP.com application server is the WebDAV server. WebDAV is an
extension of the HTTP protocol and provides an infrastructure for editing documents across distributed Web development environments. To be able
to function as the WebDAV server, the mySAP.com application server includes a WebDAV service.
See also:
Structure of a BSP Application
Event Handlers
Page Attributes
Global Objects
1.1.2 Event Handler
Event handlers allow the separation of static and dynamic code in a page. The layout processing deals with the static data, while the event handlers deal with the
dynamic data.
The following predefined event handlers are available in the SAP system:
Event Handler Description
OnCreate OnCreate
is called once when the page is first created (stateful mode), and performs a once-off data
initialization or object creation.
OnRequest OnRequest
is called whenever a request is made for a particular page and is used to restore the
internal data structures from the request. This is important when working in stateless
mode.
OnInitialization This event handler is mainly used for data retrieval. For example, it allows data
required for displaying the BSP to be read from the database. It can also
execute any program.
OnInputProcessing This event handler checks and processes user input. It can also define
navigation, that is, whether the user should be taken to the same page or
another when the BSP is called.
OnManipulation You can use this event handler to manipulate the HTTP data stream later.
OnDestroy This event handler is available for special functions.
The ABAP syntax checks that apply in the context of ABAP Objects also apply to event handlers.
Read and modify access to page attributes is available in all handlers. Global objects are also available.
Global objects and their signatures for individual event handlers are displayed if you choose in the Web Application Builder.
The use of the individual event handlers is explained in more detail in the individual sections of the documentation.
See also:
Control Flow of BSPs
navigation -> set_parameter(name = 'FLIGHT' value = 'LH' )
Let us assume that you have defined
FLIGHT as an automatic page attribute and assigned it a value from the navigation process.
If you then use a parameter of the same name on another page, this parameter will automatically get the value ' LH' (Lufthansa) at runtime.
Possible Types for Automatic Page Attributes
Before SAP Web Application Server 6.10, auto page attributes could only have the type
STRING.
Now, other types are available:
Elementary types except for
XSTRING
Structures
Tables
Lifetime of attributes with navigation to the same page
The navigation object is used (
navigation->goto_page(samepage.htm)) to navigate to the same page.
Attribute Type Value in Request (Example
Value)
Value in
OnInputProcessing
Explicit Transfer Value in OnInitialization
automatic SAP SAP No
automatic SAP SAP Yes SAP
Non-automatic SAP No
Non-automatic SAP Yes
Lifetime of attributes with navigation to a different page
The navigation object is used (
navigation->goto_page(otherpage.htm)) to navigate to a different page.
Attribute Type Value in Request (Example
Value)
Value in
OnInputProcessing
Explicit Transfer Value in OnInitialization
automatic SAP SAP No
automatic SAP SAP Yes SAP
Non-automatic SAP No
Non-automatic SAP Yes
1.1.4 Global Objects
Certain global objects can be accessed from all parts of a BSP (initialization, layout, input processing). For example, the request and response object, the
application object (if an application class was defined for the BSP application), the navigation object, and the runtime object, can be accessed.
The following global objects are available:
Object application
Object navigation
Object messages
Object runtime
Object request
Object response
Object page
Object page context
This is described in more detail below.
The objects and their signatures for the individual
event handlers are displayed if you choose in the Web Application Builder.
Example:
1.2.1 Creating BSP Applications
You can create BSP applications only with the Web Application Builder but not with external Web development environments.
Prerequisites
If you wish to create the BSP application in another namespace that differs from the standard namespace, you may only use the values provided by the system
as namespace identifiers.
Procedure
Like all Repository objects, a BSP application can be created by copying it. Note that the corresponding MIMEs are not copied to the target object
when you copy BSP applications. For each new BSP application, the system creates an identically named directory in the MIME Repository, but
it is empty.
To create a new BSP application:
1. Open the Object Navigator (SE80).
2. Choose the BSP Application category from the object list selection and enter the name of the application you want to create.
If you wish to assign the new BSP application to a valid namespace XYZ that differs from the standard namespace, you must place the namespace as a
prefix in front of the actual name of the BSP application. The complete name must then be written in this form: /XYZ/BSPApplication.
3. Click or choose ENTER to confirm your entry.
The system checks to see whether or not a BSP application with that name already exists in the SAP System. If it does not exist already, the Create Object
dialog box appears.
4. Choose Yes to create the BSP application.
The dialog box Web Application Builder: Create BSP Application is displayed.
5. Enter a meaningful Short Description .
6. Choose Create .
The system then displays the Create Object Catalog Entry dialog box.
8. Assign a package to the service.
The system displays the BSP application you have created in the object list tree structure.
Result
The BSP application has been created in the Repository as a development object.
With the new BSP application, a service node with the same name is automatically generated in the HTTP service maintenance (transaction
SICF). As a rule, no such entry exists for BSP applications that were created in earlier releases. In such cases, you must create this node
manually in the service maintenance transaction. You call up the corresponding display through the menu function Goto → HTTP Service
Maintenance . Execute the steps as they are described in the section Creating an ICF Service.
Afterwards, you can assign further attributes for the BSP applications at this point:
Property Description
Initial BSP Here you enter the name of a page that is to be used to start the BSP application. This
entry is important whenever you test the BSP application from within the workbench.
Activate this checkbox whenever the BSP application should be implemented as stateful.
For an explanation of this, refer to the section Stateful BSP Applications.
See also:
Creating Pages
Creating a Controller
1.2.2 Creating Pages
Use
You can implement the layout for each page (often called BSP) using the script languages ABAP and JavaScript.
BSPs can have different attributes: Therefore, when you create a page, we distinguish formally between 3 page types:
You can implement a page with flow logic or a view (or even a controller) as an error page. See also: Creating Error Page
Prerequisites
You have already created the BSP application.
Procedure
To create a page for your BSP application from within the object list (SE80):
1. Right-click the BSP application.
2. From the context menu, choose Create → Page .
The system displays the Create Page dialog box.
3. Provide further specifications on the page by enter the name of the page and a short page description . Afterwards, select the required option for the page
type ( view / page with flow logic / page fragment ).
4. Choose Enter to confirm your entries.
The system displays the layout editor for the new page in the tool area.
5. Choose Save to save your page.
Result
The created page is assigned as subobject to the BSP application and stored in the Repository. Besides the basic HTML structure, the page directive is pre-
generated:
<%@ page language="abap" %> bzw. <%@ page language="javascript" %>
The page directive determines the script language. The script languages supported are currently ABAP and JavaScript.
If you have chosen the page type View , both tab pages Event handler and Type definitions are suppressed – in contrast to a page with flow
logic .
If you have chosen Page fragment as the page type, the tab pages Event handler , Page attributes , and Type definitions are suppressed.
See also
Page with flow logic A page defined this way can implement the entire flow logic itself (event handler-based model). The page can have event handler and page parameters (including automatic attributes) in addition to the layout.
Such a page is executable and can be addressed through a URL or through navigation from other pages.
View Views are used solely for displaying application data. They have page parameters in addition to the layout section. In contrast to the page with flow logic, views have neither event handlers nor automatic page attributes.
A controller class is generally assigned to a view. This class controls the view calls and is responsible for communication with the model.
Views are based on the MVC Programming Model and allow you to clearly separate the application logic from the presentation logic in BSP applications.
Page fragment Page fragments are special parts. You cannot use them as stand-alone pages in an application.
<%@ include file=' /fragment.htm' %>.
A page fragment cannot define event handlers or parameters.
1.3.11.1 Creating a Controller
Use
You create a controller to use a
Model View Controller design pattern in your BSP application. You can use a controller for the initial access (see also Testing Controllers).
Prerequisites
You are in a system from SAP Web AS 6.20.
Procedure
Use the Web Application Builder in the ABAP Workbench (Transaction
SE80) to create a controller object as a sub-object of your BSP application.
In doing so, you determine the controller name and the class name of the controller. The URL is automatically inserted from the name of the BSP application and
the controller name.
In the Class Builder (Transaction
SE24), create the class that is derived from CL_BSP_CONTROLLER2.
If you create your class directly from the Web Application Builder by double-clicking on the class names, then the inheritance of
CL_BSP_CONTROLLER2 has already been configured.
Overwrite some of the methods of your class, especially
DO_REQUEST.
You can find additional information about these methods in
CL_BSP_CONTROLLER2 and Process Flow.
4. Save and activate your class and your controller.
Example
You can find examples of controllers in BSP application
ITMVC2.
1.2.5 Determining the Page Flow
Use
After creating the pages of your BSP application, you can determine the page flow, that is the transitions between the pages. To do this, you assign a navigation
request to each page transition. Assigning the pages using a navigation request provides you with a purely formal ("static") description of the navigation scheme
within the BSP application. The exact point at which a page is exited is defined through the navigation object:
navigation -> next_page('<Navigation request>')
However, this is not the only way to trigger a navigation step. For example, you do not need a navigation request if you determine the page transitions by
specifying the URL.
Procedure
To determine the page transitions, select the respective BSP application and enter the First Page , the Target Page and the Navigation Request manually on
the Navigation tab.
1.2.6 Creating References to MIMEs
To create a reference to MIME Repositorys objects on a page of your BSP application, you insert the object URL directly from the browser using Drag and Drop.
Depending on the MIME type, you can then use the URL as the source in the appropriate HTML tag.
It is recommended that you create a reference to MIMEs from the application-specific folder or from the /SAP/BC/BSP/[namespace]/PUBLIC
folder of the MIME Repository only. References to other MIMEs not specific to the application should be avoided since these objects may be
moved or even deleted at any time. You cannot create a where-used list for MIMEs.
Prerequisites
The editor displays the source code of the BSP layout in change mode.
Procedure
1. Start the browser of the MIME Repository.
2. Select the MIME object you want to insert in the tree display and drag it to the position in the editor where you want to insert the URL.
Result
The object URL is inserted at the mouse position indicated. Insert a corresponding HTML tag depending on the MIME type and usage.
1.2.8 Executing BSP Applications
Prerequisites
You have successfully activated the BSP application and the BSPs to be tested.
Procedure
Double-click the respective BSP application in the object list.
Click the pushbutton in the toolbar.
Select the page you want to execute.
The system starts the Web browser and, if necessary, displays a logon dialog box.
Log on to the system if required.
Result
The selected page is started through the following HTTP address:
http://<Application Server:Port>/<Service>/<BSP Application>/<Page.htm>
If you do not specify a service under Utilities → Settings → Business Server Pages , the system uses a standard service for executing your
application.
See also
Activating BSP Applications
1.3.1 MVC Design Pattern
The Model View Controller (MVC) design pattern contains a clear distinction between processing control, data model and displaying the data in the interface.
These three areas are formally distinguished from each other by three objects: model, view and controller. As a result, you can easily split Web applications
into logical units.
The model is used as an application object of the application data administration. It responds to information requests about its status, which usually come from
the view, as well as to statements for status changes, which are usually sent by the controller. In this way, only the model is used to process data internally,
without making reference to the application and its user interface.
There can be different views for a model, which can be implemented using different view pages.
The view handles the graphical and textual output at the interface and therefore represents the input and output data in each interface element, such as
pushbuttons, menus, dialog boxes and so on. The view takes of visualization. To visualize the status, the view queries the model, or the model informs the view
about possible status changes.
The controller interprets and monitors the data that is input by the user using the mouse and the keyboard, causing the model or the view later to change if
necessary. Input data is forwarded and changes to the model data are initiated. The controller uses the model methods to change the internal status and then
informs the view about this. This is how the controller determines reactions to the user input and controls processing.
The view and the controller together form the user interface.
Since the model does not recognize either views or the controller, internal data processing is detached from the user interface. As a result, changes to the user
interface have no effect on internal data processing and the data structure. You also have the option, however, of displaying the data in different formats; you can
display election results as a table, a bar chart or as a pie chart.
You can find additional information about the MVC design pattern on the Internet and in current specialist literature.
1.3.11.1 Creating a Controller
Use
You create a controller to use a
Model View Controller design pattern in your BSP application. You can use a controller for the initial access (see also Testing Controllers).
Prerequisites
You are in a system from SAP Web AS 6.20.
Procedure
Use the Web Application Builder in the ABAP Workbench (Transaction
SE80) to create a controller object as a sub-object of your BSP application.
In doing so, you determine the controller name and the class name of the controller. The URL is automatically inserted from the name of the BSP application and
the controller name.
In the Class Builder (Transaction
SE24), create the class that is derived from CL_BSP_CONTROLLER2.
If you create your class directly from the Web Application Builder by double-clicking on the class names, then the inheritance of
CL_BSP_CONTROLLER2 has already been configured.
Overwrite some of the methods of your class, especially
DO_REQUEST.
You can find additional information about these methods in
CL_BSP_CONTROLLER2 and Process Flow.
4. Save and activate your class and your controller.
Example
You can find examples of controllers in BSP application
ITMVC2.
1.3.2.6 Creating Error Pages
Use
In case that on a page that contains flow logic, a view, or a controller, a runtime error occurs, you can assign an error page to it. When a runtime error occurs
during execution of this (other) page or this controller, the system automatically processes the assigned error page and sends it to the browser. If no error page is
assigned to a page/a controller, in case of a runtime error, the system displays a standard page. If runtime errors occur in a called controller or view and there is
no error page, this section remains empty.
If different types of exception occur, you can use the ERROR_OBJECT error object from class CX_ROOT in your error page. You can implement this object
using dynamic ABAP and use GET_TEXT or GET_LONGTEXT methods to output an appropriate error text for your application (message short or long text).
Use the functionality in the HTTP service tree (Transaction SICF) to create error pages if short dumps occur. See also Error Pages.
Prerequisites
· You created the page (the controller) you want to use as error page. See also: Creating Pages or Creating Controllers.
· You cannot assign an error page to a page or a controller that itself is marked as error page.
· With views you must not assign a controller class, because an error page is always called implicitly by the BSP runtime.
Procedure
To identify a page / a controller as an error page:
1. Go to the properties display and switch to Change mode if necessary.
2. In section Error Handling , mark the checkbox Is Error Page .
3. Save your entries and activate the page or controller.
Result
You can now assign this page or controller as Assigned Error Page to another page or another controller.
Example
The BSP application BSP_MODEL in the system contains an example of how to implement and use an error page.
1.3.4 Call Options of BSP Components
In general, views can only be called from controllers. The only exceptions are error pages.
Controllers can be called from controllers, or from the layout methods of pages and views.
The calls can be considered as "forwarding a request" or as "adding a page fragment".
Calls that are made from a controller are identical. Only the environment is different, particularly depending on whether or not data was already written in the HTTP
response, and whether additional data is subsequently added in the HTTP response.
The calls are different from views or pages. You can use the following elements of BSP extension
bsp to branch from a view or a page to a controller:
<bsp:goto>
Forward
<bsp:call>
Insert
These two elements are based on the same technology as when a controller is called by a controller. As inner elements, both can only have elements of type
<bsp:parameter>. You hereby determine the parameters that are passed to the controller.
Naming convention for getter methods:
GET_<attribute> for a field
GET_S_<attribute> for a structure
GET_T_<attribute> for a table
An example of implementing a getter method for structure fields/structure attributes:
method GET_S_FLIGHT .
field-symbols: <l_comp> type any.
assign component of structure flight to <l_comp>.
value = <l_comp>.
if component eq 'CARRID'.
translate value to lower case.
endif.
if component eq 'CONNID'.
shift value left deleting leading '0'.
endif.
endmethod.
The ABAP keyword assign component assigns the structure component component for the structured field flight (with reference type sflight)
to the field symbol <l_comp>. The value of <l_comp> is output as follows: If the structure component component points to an airline (CARRID),
the name of the airline is translated in lowercase. If the structure component component points to a single flight connection (CONNID), then some
of the introductory zeros may be deleted.
As soon as a setter or a getter method is set, it is used automatically.
Data binding is automatically available because the name is the same. In method DO_HANDLE_DATA (see also Process Flow) of class
CL_BSP_CONTROLLER2 all controllers automatically fill the form fields with data.
The path specifications for the model data have the following syntax:
· Simple field attribute
value=”//<field name>”
· Structure attribute
value=”//<structure name>.<field name>”
· Table attribute
value=”//<table name>[<line index].<field name>”
1.3.8 Components
Use
Complex BSP applications that are based on the MVC Design Pattern have many extensive components. Each individual part, consisting of a complex BSP
application, contains precise application logic and well thought out presentation logic. It makes sense to create the individual BSP components as reusable
modules. These reusable modules are:
· Controllers
· One or more views
· A Model
Together they form a component.
Components are only available for stateful BSP applications.
Integration
The use of components is integrated in the MVC design pattern.
Prerequisites
You are in SAP Web AS 6.20.
Functions
A component consists of a controller, whose class is derived from CL_BSP_CONTROLLER2, as well as one or more views, which can result in regular nesting.
This is outlines in the following graphic:
1.3.8.2.1 Creating the Top-Level Controller
Procedure
Create a BSP application and declare it as stateful.
You can find the checkbox for stateful on the Properties tab page as the ID Stateful .
2. Save your BSP application.
3. Create a controller within this BSP application.
1. Enter a unique class name for the controller.
2. Set the lifetime in the Status field to Session .
4. Save your controller.
5. Double-click on the controller class name.
6. The following dialog box asks if you want to create the class. Answer it with Yes .
You branch to the Class Builder.
7. Save your class.
8. On the Properties tab page, check that your class inherits properties from
CL_BSP_CONTROLLER2. If this is not the case, for example if your class inherits properties from CL_BSP_CONTROLLER, then change the data for the class
that passes on the properties.
Branch to the Methods tab page.
1. In change mode, overwrite method
DO_REQUEST using the icon (Redefine):
method DO_REQUEST .
data: main_view type ref to if_bsp_page.
* if input is available, dispatch this input to subcomponent.
* this call is only necessary for top-level controllers.
* ( if this is not a top-level controller or no input is present,
* this call returns without any action)
dispatch_input( ).
* if any of the controllers has requested a navigation,
* do not try to display, but leave current processing
if is_navigation_requested( ) is not initial.
return.
endif.
* output current view
main_view = create_view( view_name = 'main.htm' ).
call_view( main_view ).
endmethod.
If necessary, overwrite method
DO_INIT.
In order to react to user input, overwrite methods
DO_HANDLE_DATA and DO_HANDLE_EVENT.
10. Activate your class.
11. Create a view within your BSP application.
1. In the following example, the view is called
main.htm.
Fill the view layout with HTML coding or HTMLB coding.
Save the view.
12. Activate and test your finished BSP application.
Continue by
Calling the Components.
1.3.8.2.3 Calling Components
Use
You can call a main controller, sub-controller in two ways:
1. By creating the sub-controller in a method of the main controller
2. By creating the sub-controller from a view
Option A is more flexible than Option B, especially if the sub-controller should be initialized once only in method
DO_INIT.
Procedure
Option A
In method
DO_INIT or DO_REQUEST, for example, add the following coding:
...
data: addresscontroller type ref to CL_C_MYPROJ_ADDRESS.
* create the controller
addresscontroller ?= create_controller(
controller_name = 'address.do'
component_id = 'ad'
).
* set some attributes with a self defined method
addresscontroller->Init_data( ... ).
...
Call the controller in the view.
Two components are called in the above example: the address component (
address.do) and the flight component (flights.do).
COMPONENT_ID
identifies the controller. In method CREATE_CONTROLLER this is the parameter COMPONENT_ID, and in <bsp:call>-element this is the attribute COMP_ID:
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<%@extension name="bsp" prefix="bsp"%>
<htmlb:content id="ComponentTest" >
<htmlb:page title = "Component Test">
<H1>Component Test</H1>
<htmlb:form id="myFormId" method="post">
<htmlb:tray id = "tray1"
title = "Address"
design = "form"
width = "350"
isCollapsed = "false" >
<bsp:call url="address.do" comp_id="ad">
</bsp:call>
</htmlb:tray>
<htmlb:tray id = "tray2"
title = "Flights"
design = "form"
width = "350"
isCollapsed = "false" >
<bsp:call url="flights.do" comp_id="fl">
</bsp:call>
</htmlb:tray>
<p>
<htmlb:button id="SAVE" text="SAVE DATA" onClick="SAVE" />
<htmlb:button id="CANCEL" text="CANCEL" onClick="CANCEL" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
Option B
In this option, you do not need to create the sub-controller in the coding of the main controller. Instead you should only add the parameters to the view call, which
then creates and calls the controller. In the following example,
ship_address is an attribute of the view and is set by the controller:
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<%@extension name="bsp" prefix="bsp"%>
<htmlb:content id="ComponentTest" >
<htmlb:page title = "Component Test">
<H1>Component Test</H1>
<htmlb:form id="myFormId" method="post">
<htmlb:tray id = "tray1"
title = "Address"
design = "form"
width = "350"
isCollapsed = "false" >
<bsp:call url="address.do" comp_id="ad">
<bsp:parameter name="address" value="<%=ship_address%>"/>
</bsp:call>
</htmlb:tray>
<htmlb:tray id = "tray2"
title = "Flights"
design = "form"
width = "350"
isCollapsed = "false" >
<bsp:call url="flights.do" comp_id="fl">
</bsp:call>
</htmlb:tray>
<p>
<htmlb:button id="SAVE" text="SAVE DATA" onClick="SAVE" />
<htmlb:button id="CANCEL" text="CANCEL" onClick="CANCEL" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
Framework functions
These methods are provided as part of the framework and are only included here for the sake of completeness. They are not usually relevant for application
development.
Method Description
IF_BSP_DISPATCHER~REGISTER Registers a sub-components
IF_BSP_CONTROLLER~FINISH_INPUT_PROCESSING Processes or dispatches: end of input processing.
IF_BSP_CONTROLLER~FILL_VALUES Processes or dispatches: handling values
IF_BSP_CONTROLLER~HANDLE_EVENT Processes or dispatches: Handle event
GET_FIELD_COMPONENT Finds components for a field name
GET_FIELD_MODEL Finds model for a field name
Methods DO_DESTROY and SUBSCRIBE are not relevant.
1.3.10 Examples of Architecture
Previous BSP Application
With SAP Web AS 6.10, normal BSP applications usually consisted of an application class and several BSPs. Navigation between the pages was controlled
using redirects.
This is how it looks with SAP Web AS 6.20:
BSP Application with Controllers and Views
1.3.11 Model View Controller Tutorial
Purpose
In this tutorial, you can use a simple example to run through the first steps with the Model View Controller design pattern for BSP.
Prerequisites
● You are in an SAP Web AS 6.20 system
● You know how to use MVC for BSPs.
Features
Create Controller
Create View
Call Controller
1.4.1 BSP Extension Framework
In the following example, a BSP page uses the elements of the BSP extension myExtension . All the BSP elements in this extension are identified, in this case,
by the prefix ext .
The BSP elements are defined within the Workbench using the BSP extension editor. Here, the BSP extension was created as a container for the corresponding
elements. In addition, specific attributes can be assigned to each element.
The specific functions of a BSP element are implemented with the help of a global element handler class myElementClass in the Class Builder.
</ui:treeNode>
</ui:tree>
BSP Elements and Static HTML
This element can include both further BSP elements as well as any HTML part.
Example:
Form element from HTMLB
<ui:form id="myFormID" method="POST">
<ui:inputField id="myID" value="" size="24"/>
<br> <br>
Some Text ...
<a HREF="" ...> ...</a>
</ui:form>
Element Interprets the Content Itself
With this selection, you define that the content of the element is to be passed on
unchanged, without previous parsing, to the element handler class. This is
appropriate whenever an interpretation of the element content is not required by
the runtime environment.
Example:
The BSP element executes an SQL statement that must be specified in the
element content.
<sql:selectStatement>
SELECT * from SFLIGHT into table myFlights
</sql:selectStatement >
Example: Validation at Runtime
In the example below, the system is to check at runtime whether the value of the attribute
visible is a correct Boolean value and whether the two attributes axisMinVal and axisMaxVal contain values of the type Float .
In this case, the interface method
RUNTIME_IS_VALID is overwritten. The parameter list m_visible, m_axisMinVal, m_axisMaxVal is passed to this method. The corresponding result of the
attribute check is written into this list. The attributes are identified using the methods of the validation object m_validator. The method RUNTIME_IS_VALID does
not return any return value. If one of the checked attribute values is invalid, a corresponding exception is triggered at runtime.
method IF_BSP_ELEMENT~RUNTIME_IS_VALID .
m_visible = m_validator->to_boolean( name = 'visible'
value = me->visible ).
m_axisMinVal = m_validator->to_float( name = 'axisMinVal'
value = me->axisMinVal ).
m_axisMaxVal = m_validator->to_float( name = 'axisMaxVal'
value = me->axisMaxVal ).
endmethod.
1.4.3.3 Iteration Through Element Content
Use
Activate this option in the Attributes display for the BSP element if this element is to run through its own content repeatedly, that is, it should implement a loop.
Activities
In addition to activating this option, you must also redefine the interface method
DO_AT_ITERATION of the element handler class.
This method is called each time at the end of an iteration. Using the return parameter , you control whether the loop is ended
(RC=CO_ELEMENT_DONE) or run through once again (RC=CO_ELEMENT_CONTINUE).
Example
Let us assume that you wish to have a repeated text call with a simple <do>-Element. The number of iterations is set through the corresponding attribute
howOften.
Example:
<loops:do howOften = "10">
Hello World !
</loops:do>
The value of the attribute
howOften is used at the beginning of the element call in the method DO_AT_BEGINNING in order to initialize the loop counter count:
method IF_BSP_ELEMENT~DO_AT_BEGINNING .
rc = CO_ELEMENT_DONE.
endmethod.
The method
DO_AT_BEGINNING should have already checked whether the element content is to be evaluated at all. If this not the case, DO_AT_ITERATION is skipped
and afterwards the method DO_AT_END is called.
The implementation of
DO_AT_ITERATION could look like this:
method IF_BSP_ELEMENT~DO_AT_ITERATION .
if count <> 0.
count = count - 1.
rc = CO_ELEMENT_CONTINUE.
else.
rc = CO_ELEMENT_DONE.
endif.
endmethod.
Note that the method
DO_AT_ITERATION is only called if the operation Iteration Through Element Content has been explicitly assigned as element attribute. See also Defining BSP
Elements.
DO_AT_ITERATION
is called as soon as the element content has been processed. The method DO_AT_END, on the other hand, is called whatever the case, but only once; in this
case, the call takes place after the iteration has closed
1.4.3.4 Manipulation of the Element Content
Use
Activate this option in the Attributes display for the BSP element if it is necessary that this element can manipulate its own content.
Activities
After activation of this option, a so-called BodyWriter becomes available in the interface attribute
M_OUT for the element handler class. This manages the content of the BSP element. Using the BodyWriter methods, you can manipulate the content accordingly.
To change the element content, you must also redefine the interface method
DO_AT_END for the element handler class as well as activate the option Manipulation of the Element Content .
This method is accessed in any case at the end of the element call. You can use them especially for manipulating the content in order to explicitly pass the
BodyWriter content to the BodyWriter of a surrounding BSP element. If no pass takes place in this case, the element content is discarded.
Example
In the following example, a BSP element is to convert its entire text content into upper-case letters. The method DO_AT_END is overwritten as follows:
First, the element content from the current BodyWriter
m_out is written to the local variable content. A new content is then assigned to this variable. Afterwards, the method call me->get_previous_out() returns the
BodyWriter of the surrounding element previous_out. The new content, however, is not automatically copied to this BodyWriter. The assignment of the new content
finally takes place with the method print_string().
method IF_BSP_ELEMENT~DO_AT_END.
data: content type string.
1.4.3.5 Pass by Reference for Attributes
Passing by reference is always appropriate if the BSP element is to have access to larger data quantities in the BSP page and passing "by value" would be too
costly. This is the case if you have access to internal tables.
In addition, the pass by reference is used whenever the BSP element is to change the content of a variable defined in the BSP page.
Note that in this case you must also select the typing kind
TYPE REF TO for the corresponding attribute.
Example
The BSP element is to increase the content of a passed variable by 1. The attribute
value is required for passing the value. Calling this increment element into the BSP page could then take place as follows:
<xyz:increment value = "<%=my_var%>"/>
The variable
my_var is declared in the BSP application as a page attribute of the type I.
For the
value attribute, the indicator Dynamic Value Allowed was activated and TYPE REF TO was selected as Typing Kind in the attribute display.
To execute this pass by reference at the beginning of the element call, you need to overwrite the method DO_AT_BEGINNING:
method IF_BSP_ELEMENT~DO_AT_BEGINNING .
...
add 1 to value->*.
rc = CO_ELEMENT_DONE.
endmethod.
Note that there is a reference to data in this example within a BSP element. To access data, the reference operator
->* must be used in ABAP in this case.
1.4.5 Implementing Element Handler Classes
Use
The element handler class is the central class of a BSP element. It implements the specific functions of an element and thus influences the flow logic of the BSP
page that uses this element. Through the type of implementation of certain methods belonging to this class, you can control whether data is updated in the HTML
data stream and whether the content of a BSP element is processed or discarded.
Element handler classes are instantiated during the processing of a BSP page and called at defined points in time using certain class methods.
Prerequisites
A valid element handler class must implement the interface IF_BSP_ELEMENT. We therefore recommend that you derive this class from the
generated superclass (Z)CLG_<EXTENSION>_<ELEMENT> because it already contains the standard implementations for the interface methods.
Process Flow
The flow during implementation of the specific functions of a BSP element is divided up into the following three steps:
1. Creating the attributes for the BSP element See also Defining BSP Elements.
In this way, you make sure that the new attributes are added as attributes of the element handler classes after activation of the BSP extension.
2. Overwriting certain
interface methods of the element handler class
Creating further methods or attributes that enhance the element functions
1.4.6 Entering Documentation
Use
You can create a long text documentation both for a BSP extension as well as for each BSP element in the system that is contained in this extension. This
document is of particular importance for the productive usage of the extension in BSP pages because you can include special aspects of the individual BSP
elements here.
If you store the documentation in the system, it is then available to users through the context menu in the Tag Browser and also through insertion of the tag into a
BSP page – also by pressing F1 in the layout editor.
Prerequisites
The BSP extension and the elements to be documented have already been created.
There are two different templates available for the BSP extension and the BSP elements. The procedure for creating the documentation is the same,
however.
Procedure
To create documentation for a BSP element in SE80:
1. Select the BSP extension in the Repository Browser.
2. Double-click the required BSP element in the object list.
The system displays the element editor.
3. Go to Change mode.
4. Click the Documentation pushbutton in the toolbar.
The SAPScript Editor is called up and displays an empty template with predefined paragraphs.
5. Write your text into the predefined paragraphs.
6. Save the SAPScript document as a raw version first.
7. Test the documentation and make whatever corrections are necessary.
8. Save the document as active version .
Result
You have created a SAPScript document for the long text documentation of a BSP element and have assigned a transport request to it.
If you have saved the document as an active version as well, this will be transported to the translation worklist.
Example
The documentation for all BSP elements is available for the BSP extension
HTMLB.
1.4.7.1 Example: Using Extensions in BSP Pages
The following example shows the realization of a simple Web user interface for a BSP application using the HTMLB library
HTMLB. This library is available in each SAP Web Application Server System and can be imported within the workbench from the Tag Browser into any BSP
page.
This example contains a label, input, and pushbutton element – in addition to the content, page, and form elements - for simple selection of flight data. The flight
data is displayed using a TableView element.
1.5 Implementing External Tools with WebDAV
Prerequisites
You can use external tools, that is, all standard Web development and design environments, to implement the page layout of your BSP application.
This requires, however, that the external tools support the WebDAV protocol and are able to function as a WebDAV client.
WebDAV is an extension of the HTTP protocol and generally provides an infrastructure for editing documents (such as HTML pages) across distributed Web
development environments.
In this connection, the mySAP.com application server plays the role of a WebDAV server. It is equipped with an appropriate WebDAV service.
A WebDAV service is a special HTTP request handler that establishes a remote connection based on the WebDAV protocol. The WebDAV service is
implemented through a global ABAP class.
Usage Scenarios
Implementing the Page Layout Using External Tools
Mass Import of MIMEs Using WebDAV.
1.5.1 Implementing the Page Layout Using External Tools
You create the basic structure of a BSP application in the Web Application Builder (SE80).
Afterwards, you can edit the pages of that application using external tools. This is made possible by a check-out/check-in mechanism. You use external tools
primarily for implementing the page layout. It is not possible to edit page parameters and event handlers.
You can use a WebDAV client to perform the following tasks:
Implement the page layout
Import MIMEs
Create new pages
Check in the pages
1.6.2 Mass Import for MIMEs Using WebDAV
As an alternative to the import function of the MIME Repository, you can perform a mass transfer of MIMEs by using the WebDAV interface.
In this scenario, you do not need to check out your pages. You merely establish a connection to the application server through WebDAV and transfer the MIME
objects from the file directory of your hard disk to the desired directory in the MIME Repository.
Process Flow
1. Logging on to the application server through WebDAV (for example, using Web folders or My Network Places in Windows environments).
To do this, you must specify the address of the SAP application server and the WebDAV service in the following form:
HTTP://<Application server>:<Port>/<Namespace>/<WebDAV service>
Example:
HTTP://xyzmain.wdf.sap-ag.de:1080/sap/bc/bsp_dev
To find out the namespace (in the above example: sap/bc/) and the name of the WebDAV services (in the above example: bsp_dev), call
up the transaction SICF. All services are listed as ICF objects in Maintenance of Services .
The address named above is valid for system standard clients only. If you want to access MIME objects via WebDAV using a different
client, you have to expand the address appropriately. Call the BSP page encode.htm from the decode_url BSP application to create an
appropriate address.
How to Copy Page Attributes
How to Implement a Mass Import for MIMEs to the MIME Repository
1.6.1 Copying Page Attributes
Use
You might need the same set of page attributes on several pages of your BSP application. This is the case if you want to pass data from one page to the following
pages using automatic page attributes. You need not edit page parameters having the same name for each page; you can simply copy the page attributes.
Prerequisites
You are on the Page Attributes screen of the BSP from which you want to copy a selection of page attributes.
Procedure
To copy the page attributes:
1. Select the rows for the selected page attributes using the selection column.
2. Click on the icon in the toolbar to copy the selected rows.
3. Go to the Page Attributes display for the target page and switch to Change mode if necessary.
4. Place the cursor on an empty row within the Attribute column.
5. Click on the icon in the toolbar to insert the rows with the page attributes.
The selected page attributes are included in the target page with the same names.
1.6.2 Mass Import for MIMEs Using WebDAV
As an alternative to the import function of the MIME Repository, you can perform a mass transfer of MIMEs by using the WebDAV interface.
In this scenario, you do not need to check out your pages. You merely establish a connection to the application server through WebDAV and transfer the MIME
objects from the file directory of your hard disk to the desired directory in the MIME Repository.
Process Flow
1. Logging on to the application server through WebDAV (for example, using Web folders or My Network Places in Windows environments).
To do this, you must specify the address of the SAP application server and the WebDAV service in the following form:
HTTP://<Application server>:<Port>/<Namespace>/<WebDAV service>
Example:
HTTP://xyzmain.wdf.sap-ag.de:1080/sap/bc/bsp_dev
To find out the namespace (in the above example: sap/bc/) and the name of the WebDAV services (in the above example: bsp_dev), call
up the transaction SICF. All services are listed as ICF objects in Maintenance of Services .
This completes the input of logon data for your logon to the SAP System.
2. Selecting the target directory in the MIME Repository.
3. Importing MIMEs from the file directory of the hard disk into the selected directory of the MIME Repository (using Drag and Drop, for example).
All MIMEs imported are then part of the MIME Repository. By default, they are assigned to the package of the BSP application.
See also
Importing and Deleting MIMEs