!--a11y-->
BSP Extensions 
The BSP programming model, which is based on the server pages technology, provides developers with additional scope regarding the HTML coding that they can create, from an empty page right up to complex applications. However, repeatedly creating complex HTML coding is often a lengthy process that can easily result in errors. As an example, a simple HTML pushbutton can be implemented very easily: <input id=btn type=submit>. If you now start to use additional styles and other attributes for the size and the status of the button, the original simple HTML coding becomes considerably more complex and unclear. Here an abstraction technology can be used to express both the syntax and the semantics of a specific section of HTML coding simply. This mechanism is structured so that it can also be used by other types of BSPs, XML, WML and so on. With this technology you call them BSP extensions.
A BSP extension contains a collection of BSP elements. In the BSP context, each element is assigned to an ABAP class to represent the element functionality, which the generation of the HTML coding usually contains. Defining the elements and mapping them to the ABAP classes is so flexible that you can use this technology to solve many additional problems and difficulties.
SAP provides an infrastructure that developers can use to implement BSP extensions within BSP applications. SAP delivers a set of predefined extensions such as HTML Business for BSP (HTMLB), XHTMLB and PHTMLB which are available and can be used in every SAP Web Application Server 6.20 system. In addition you can define your own extensions to meet specific requirements. You can create these using an editor that is integrated in the development environment (Transaction SE80).
You include an extension in a BSP using the extension directive.
For more information see Creating Your Own BSP Extensions.

You can also create composite elements to facilitate layout changes with complicated BSP applications.
Each BSP extension consists of a collection of BSP elements. Each element has specific attributes and is assigned to an ABAP class. The usual notation for XML elements is used when elements are written to BSPs. The attributes available in the element are used as input parameters for the ABAP class that is assigned to the element.

You can define a simple pushbutton on a BSP as follows, for example:
<htmlb:button id=”btn1” text=“Hit Me!” />
Here “htmlb” is the XML namespace, “button” is the element and “id” and “text” are attributes. If the BSP compiler sees the element, it generates the following pseudocode.
data: btn1 type ref to CL_HTMLBL_BUTTON.
create object btn1.
btn1->writer = current_output_writer.
btn1->id = ‘btn1’.
btn1->text = ‘Hit Me!’.
btn1->begin_tag( ).
btn1->end_tag( ).
The element class writes the HTML to the HTML output stream based on the functionality that the element provides. This is based on the assumption that all elements in an extension support a common output style.

In the sample pushbutton above, the start tag is followed immediately by the end tag. No body components whatsoever are available or required (by the pushbutton). For other examples, it may be useful to manipulate the body or to process more detailed input.

A typical element, for example, could be an HTML link for creating a small text segment. In this case, the element has a body, which is first rendered in a string and then passed as a parameter to the element for further processing.
<htmlb:link id=”link1”
reference=“http://www.sap.com”>
Homepage of the e-company!
</htmlb:link>
This results in:

The link element takes the Internet address as the reference. Furthermore, the link element provides formatting based on the style that is provided by the BSP extension. The body is used as input for the element.
Even if using elements and their resulting ABAP class calls seems to be fairly complex for this type of simple HTML element, using and supporting BSP extensions provides several advantages that should not be underestimated:
· The standard XML syntax that is used can be parsed and checked during the BSP compile time.
· The returned HTML coding need only be generated once (by an expert) in the ABAP element class, thereby ensuring that the coding is correct.
· The element class can contain additional logic for generating browser-dependent HTML code.
· The HTML coding that is generated contains correct references to the style sheets that are available.
In addition to a BSP extension for standard HTML elements such as pushbuttons, input fields, dropdown lists and so on, you can also implement highly specialized extensions.

For example, you could develop an extension to map a company’s corporate identity to an HTML page. In this case, the user’s coding for this extension, for example, could be as follows:
<%@extension name=”SAP_Corporate_Identity_Extension”
prefix=”corp” %>
<corp:logo/>
<corp:stock_ticker/>
This could look as follows on the HTML page:

Different examples of BSP applications that use BSP extensions are available in the system. You can find simple examples of using BSP extensions HTMLB, XHTMLB and PHTMLB in the BSP applications SBSPEXT_HTMLB, SBSPEXT_XHTMLB and SBSPEXT_PHTMLB, and further examples in BSP extension HTMLB_SAMPLES.

As part of the tutorials for creating Web applications with BSP, a Tutorial for a Small Online Bookshop is also available, whose layout is implemented using HTMLB.
The following sections provide two simple examples of the HTMLB elements button and tableView: