You are on page 1of 267

Programming Model

The following documentation describes the BSP programming model: BSP Applications BSPs BSP Directives Central Classes and Interfaces Important Global Objects BSP Extensions Model View Controller (MVC) Stateful and Stateless Control Flow and Lifetime Caching Page Design Accessibility For SAP Web AS 6.20, the BSP programming model was enhanced with the MVC design pattern as well as the paradigm of the BSP extensions.

What is a BSP Application?
Overview
A Business Server Page (BSP) application is a complete functional application as is a classic SAP R/3 transaction. Instead of being displayed using SAP GUI, these applications are displayed in a Web browser or a mobile device browser, such as a WAP cell phone. HTTP or HTTPS is used to access the application across the network, which means that standard products like firewalls and proxy servers can be used. The Business Server Pages programming model is similar to the server page technology. The focus of the BSP programming model are points that ensure optimum structure in interfaces and business logic. For more information about BSP applications, see:
The components of a BSP application and how they interact, How to call an existing BSP application from a Web browser, see Accessing a BSP Application How to start and end a BSP application, see Starting and Ending a BSP Application How a BSP application is processed, see Processing a BSP Application How to create a BSP application, see Creating a BSP Application The URL parameters you can use to access the BSP runtime environment and BSP applications, see System-Specific URL Parameters The concept of an application class for encapsulating the business logic of a BSP application, see Application Class of a BSP Application

Tutorials
The following tutorials are available: 1. First tutorial: Getting Started with Business Server Pages 2. Second tutorial: A Simple BSP Application and A Sample BSP Application with HTMLB 3. Third tutorial: Online Bookshop 4. Fourth tutorial: Further Developing the Online Bookshop 5. A small tutorial is also available for getting started with the Model View Controller (MVC) Design Pattern. 6. A more comprehensive MVC tutorial based on the third tutorial: Our Online Bookshop Using MVC and HTMLB

Structure of a BSP Application
A Business Server Page (BSP) application is an independent development project that is created and edited in the SAP development environment (transaction SE80). External design tools, such as Adobe GoLive, Dreamweaver, or Microsoft FrontPage 2000 can be used to design the BSP application, as well as BSP extensions.

Analog to a classic transaction, a BSP application consists of a user interface and business logic that is assigned to a logical unit, in this case the BSP application. The user interface of a BSP applications includes: • • Static Web sites Dynamically generated Web sites, which are BSPs or templates that contain server-side scripting that is executed dynamically at runtime to generate a static Web site BSPs can either be pages with flow logic or views. There can also be controllers if the MVC design pattern is used Various MIME objects, such as pictures, icons, sound files, style sheets, and so on, that are parts of a typical Web application

All of these objects are integrated in the Change and Transport Organizer as parts of the BSP application and are handled as a logical unit. This allows all objects that are part of a BSP application to be fully and consistently transported between all the systems in an SAP system landscape.

The business logic can be accessed from the BSP application using the typical methods, such as BAPIs, function modules, or class libraries. In addition, the BSP programming model provides a structuring tool, the BSP-Application class , that can be used to encapsulate the business logic functionality in the BSP application.

A BSP application consists of the following components: • Controllers Controllers contain business logic and application data. Controllers assess the data of an incoming request based on a model and then select a suitable view for rendering the reponse to the user, see also Model View Controller (MVC). • Business Server Pages (BSPs) BSPs are the Web sites that are displayed in the browser when the application is in use. BSPs can contain static HTML code and dynamic scripting code (ABAP or JavaScript). The scripting code is interpreted on the server. The exact structure of a BSP is described in Building an BSP. A page can have the following versions: o Page with flow logic These are simple pages with event handlers, but without much application logic or visualization elements. It is possible to build a BSP application exclusively out of pages with flow logic and event handlers. o View

Views are used to visualize data, see also Model View Controller (MVC). o Page fragment These are created in the same way as normal BSPs, but are then marked as page fragments. Other BSPs can also include these fragments using the include directive (see Include Directive). • Navigation structure The navigation structure determines which navigation request is used to direct the navigation process from which page to which subsequent page. • Application class The business logic of a BSP application is encapsulated in an application class. The application class is implemented using a global ABAP class. This global class implements access to business data, for example, via BAPI calls. Every page of a BSP application can directly reference the components of this class (attributes, methods, and so on) using the predefined Object application. You can also assign several BSP applications to an application class. For more information, see Applications Class of a BSP Application. • MIME objects In the SAP system, all MIMEs, such as graphics, style sheets (used to define formatting properties of individual HTML tags), audio files, video files, and so on, are stored and administered in a central repository, the MIME repository. For every new BSP application, a directory of the same name is created in the MIME repository. This directory is used as a storage location for all application-specific MIMEs. o Theme A theme is a container for MIME objects. These MIME objects can be used to modify the appearance of one or more BSP applications after the application has been created. You can replace every MIME object in your application with another object from the file system. A theme is created as an independent development object in the Web Application Builder. A theme can be assigned to BSP applications in order to redefine style sheets and MIMEs in the pages of a BSP application after they have been created. The theme concept is a powerful tool for easily changing the layout of your pages in accordance with your needs, without the need for modifying the layout source code. See also: See also: Tailoring Layouts to BSP Applications

you access a BSP application using the HTTP or HTTPS (Secure HTTP) protocol. Ensure that after a SAP Web AS has been installed. SAP applications are delivered in the sap namespace. In the Internet Communication Framework (ICF). The application name is the name of the BSP application as defined in the development environment.sap-ag.de:1080/sap/bc/bsp/sap/it00 . A BSP application is addressed and executed through HTTP using a Uniform Resource Locator (URL).<extension>:<Port>/sap/bc/bsp/<namespace>/<application name> The protocol Prot is http or https (if configured). Host is the name of the application server that should execute the application. that all services are inactive and that they must be activated accordingly.20.Accessing a BSP Application Starting and Ending a BSP Application Building a BSP Accessing a BSP Application As we have already explained.<domain>. If you create your BSP application in a separate namespace. for a BSP application to function smoothly you need a node. The Port number can be omitted if the default port 80 (http) or 443 (https) is used. the node is also activated only in the case of BSP applications that are newly created for SAP Web AS 6. the default port number is 1080 (HTTP) or 1443 (HTTPS). The URL of a BSP application has the following structure (default configuration): <Prot>://<Host>. The BSP runtime environment uses the HTTP framework of the SAP Web Application Server (compare Interaction Model). see Activating and Deactivating an ICF Service and Note 517484. it must be used in the URL (see also Creating BSP Applications). As part of automatically creating the corresponding node in the service tree. The namespace is the namespace ID of the BSP application. For additional information about activating services. that is. For SAP Web Application Server. Here is an example of a URL for BSP test application IT00: http://myServer. Domain and the Extension comprises several hosts under a common name. a service in the service tree (see also Creating a BSP Application). although they can either be made up of an individual host or a network.

then proceed as described in Note 434918. Otherwise. look on the Properties tab at the right side of the SAP GUI screen. the BSP runtime environment returns an error.de). the BSP application is started and the initial page is displayed (by default this is default.htm). If the BSP that you start using Transaction SE80 contains a shortened URL (it does not specify the host name). The full domain must be specified as otherwise there may be problems with HTTP cookies (such as Single Sign On).The full name of the server is specified. To determine the URL of a BSP or BSP application within the SAP development environment. . When this URL is started in the Web browser. including the network domain (here: sapag.

htm of BSP application IT00: .Example of page default.

To be compatible with the Internet Transaction Server (ITS). the following abbreviated format is supported. To be compatible with SAP Internet Transaction Server (ITS) and the SAP Enterprise Portal (SAP EP).corp:1080/sap/bc/bsp/sap/it00?sapsessioncmd=open or http://myServer.corp:1080/sap/bc/bsp/sap/it00/! 1. URL Parameter sap-sessioncmd Value open: Description Restarts the BSP application named in the URL . whereby the page name is replaced by an exclamation mark (“!”): http://myServer.sap. see System-Specific URL Parameters.corp:1080/sap/bc/bsp/sap/it00?sap-sessioncmd=open close: Ends a running BSP application and either tells the system to display a blank page or go to a specific Web site (exit URL). To be compatible with SAP Internet Transaction Server (ITS) and the SAP Enterprise Portal (SAP EP).sap.sap.sap. Ending the application externally: http://myServer.com System-Specific URL Parameters To control the BSP runtime environment and the BSP application. This parameter is calledsap-exiturl. you can also use ~SAPSessionCmd. Procedure The following commands are supported: open: Restarts a BSP application that is running.Starting and Ending a BSP Application Use URL parameters can be used to inform the BSP runtime environment to start or end a BSP application (corresponds to the OK code “/n” in SAP GUI) To do this. The application is started if it is not running already.sap. Example 1.sap. you can use the following URL query string parameters in a request URL. The exit URL is specified using an additional URL parameter. For a list of all system-specific URL parameters that have a special use in the BSP application environment.and must contain a full HTTP URL. you can also use ~exitURL.corp:1080/sap/bc/bsp/sap/it00/! This is the same as the following URL: http://myServer. Restart of BSP test application IT00: http://myServer.corp:1080/sap/bc/bsp/sap/it00?sapsessioncmd=close&sap-exiturl=http%3a%2f%2fwww. the Query String parameter sap-sessioncmd is added to the URL and the HTTP request is sent to the server.

sap-exiturl sap-theme sap-themeRoot * * * sap-client * sap-user sap-password * * sap-language * Specifies the language (ISO language ID. For SAP Enterprise Portal 5. to the Web site defined by sap-exiturl.sap. without using the attribute design of <htmlb: content>. Here is an example of how to restart a BSP application in client 800 with logon language English. Specifies the user for a logon to the SAP Web Application Server.com) Overrides the theme for a BSP application to use other MIME objects. if it is pointed to a case-sensitive server).com:1080/bc/bsp/sap/it00?sapsessioncmd=open&sap-language=en&sap-client=800 . see also Domain Relaxing Specification for the accessibility See also SYSTEM_PUBLIC and Configuration Settings.sap. such as pictures and Stylesheets for visualization. You can combine several parameters in one URL. an activated checkbox is placed on the logon screen for input help. Specifies the password for logon. To activate this indicator. both DESIGN2002 and DESIGN2003 are supported. Specifies the URL to which the browser is directed when the BSP application ends (for example. can be used in the URL or in HTML forms to override the default client. can be used in the URL or in HTML forms to override the default logon language. can be used in the URL or in HTML for forms. Dynamic switching of the different default design variants. Used to handle paths to other locations from where stylesheets are taken. if specified. nor are the parameter values (exception: sapexiturl. even after the browser is closed. http://myServer. DESIGN2002 is supported. For SAP Enterprise Portal 6. Specifies the client for a logon to the SAP Web Application Server. sap-htmlb-design * sap-domainRelax sap-accessibility off | min | max X| Maximum domain relaxing. The parameter names are not case sensitive. such as EN or DE) for a logon to the SAP Web Application Server. Possible values are CLASSIC. If you want the user to be able to end the application. http://www. this option should be available in a BSP application as part of the user interface (as a pushbutton or hyperlink). can be used in HTML forms.close: Ends the BSP application named in the URL and sends the browser. DESIGN2002 and DESIGN2003. Do not enter this directly in the URL as Web browser URLs are stored in a History list and the password would be visible in plain text.

such as table contents or BAPIs. If there are no subsequent changes. Then. the manipulation part is not required. in which the user inputs data. Process If an HTTP request is sent to a BSP. the individual BSPs and their components are run. if a page (in stateless case: for the first time) is called. Data in the SAP system. see Control Flow of BSPs Creating a BSP Application . the first page is reprocessed.Processing a BSP Application Uses When a BSP application is being processed. the layout part (the hidden part of the event handler OnLayout) is processed. no business logic or data retrieval is carried out in the layout part. the first page is built and sent to the user. can be accessed in this phase. OnInputProcessing for HTML input. Next comes the user interaction phase. so that the initialization phase data is assessed. and the corresponding processing steps are executed according to the code. OnInitialization for URL input. If no succeeding page is set. OnRequest is called. Next. that is. HTML) and scripting code. On the basis of all this data. The subsequent page for the navigation request is determined in the navigation part of the application. processing of the initialization part continues. The handler is then run that is most appropriate for the request. The manipulation part becomes important if the HTTP data stream should be modified later. This input triggers an additional HTTP request. The manipulation code should likewise contain no business logic or statements for data retrieval functionality. data can be read from the database. or another individual event handler if controls are used. To ensure clean programming. OnInitialization is run. Then. If it hasn’t already. The user input is sent back to the BSP. For more information. that is. This code consist of static parts (for example. the page in instantiated in OnCreate. and the succeeding page can be determined. incorrect input can be checked. You can specify for every page whether stateful or stateless mode is required. This is done in the input processing part. For example. which determines the design and presentation logic of a page.

For information about creating BSP applications. the application class can include any methods. see the various tutorials (Creating Web Applications with BSPs) and the documentation on Web Application Builder.20. when you create a BSP application in the Web Application Builder. the application class encapsulates BSP application logic in methods. specifically the sections under Basic Functions. There may be conflict with old BSP applications with names that are longer than 15 characters. As such. If necessary. this type of node is created and activated in the appropriate part of the ICF service tree (see also Creating an ICF Service). In addition. This allows several BSP applications to use the same application class and provide . there must be a node that corresponds to each BSP application in the service tree (Transaction SICF) of the Internet Communication Framework (ICF).20 and which therefore do not have any nodes in the ICF service tree. we recommend that you copy all of the old BSP application to a new BSP application with a shorter name. One of these objects is the application class of the BSP application. so that the node is automatically created. From SAP Web AS 6. Application Class of a BSP Application Overview A BSP application can include a multitude of different development objects. attributes. you can add permissions for this node (see also Service Options). The application class is usually used to store data and make it available across BSP pages. Before SAP Web AS 6.20 you could create BSP applications whose names could exceed the length of the service name in Transaction SICF. The application class is a regular ABAP Objects class. and events the developers wants.You create your Web application in the form of a BSP application. Extending Security Aspects with BSP Applications So that a BSP application can function correctly. this node is generated automatically by the system as soon as you branch to the corresponding BSP application in change mode. This data is stored as attributes. For BSP applications that were created before SAP Web AS 6. In this case.

There would also be methods for changing and processing the shopping basket. This also means the global Object application can be used in the BSP application to access the attributes and methods of the application class. In many cases. such as to add. It is an optional way for you to structure your BSP application. Methods for determining prices. You use the Web Application Builder in transaction SE80 to assign an application class to a BSP application. creating offers. and posting orders would also be helpful. This application class would include a shopping basket (internal table or other object) as an attribute. without having to replicate the business or application logic. the application class is only used to encapsulate existing application functions. such as from SAP Customer Relationship Management (SAP CRM). change. If a customer or developer wants to change or adapt a BSP . A simple example of where an application class could be useful would be a class for controlling dialog logic and maintaining data consistency in a BSP application for shopping. or delete articles.one business application that contains different interfaces. and then access the function through BAPI interfaces. see Extending the Online Bookshop. Using an application class to encapsulate the functions ensures that the BSP application functions are stored in a central location (in the application class) and that both implementation and distribution are transparent (local method call but remote BAPI call internally). You do not have to use an application class in your BSP application. For an example of the use of an application class. such as for various devices.

For stateless applications. that the parameter only exists if an application class is defined for a BSP application. This means the lifetime of the application object starts when the request is received and ends when a response is sent.application or use the application for an additional device. you must ensure. This includes the application object. you use a typed object reference that is stored as the parameter application in all event handlers of a BSP. application classes are usually used to store the business logic in methods. Otherwise there are no other restrictions. is generated at the first request sent to the BSP application. the application object. Requirements for an Application Class The only requirement for an application is that the constructor is parameter-less. The lifetime of an application class depends on the state model of the BSP application. A BSP application can be stateful or stateless. In stateful mode. When the application context is released. a class for which there is only one instance per session. the application context (roll area) is only available for the lifetime of a single request and is released at the end of the request. they have the full functions of the original BSP application available in the interface of the application class. You do need to ensure that the internal implementation of methods is chosen correctly. Runtime Behavior Any ABAP Objects class can potentially be used as an application class of a BSP application. The application objects is not available across several pages. Each page and each request interacts with a different instance of the application class. Of course. If not. that is. all data and objects held by the session on the application server are also released. The end lifetime of the application object ends when the session ends. However. Accessing the Application Object To access the application object. The object is then available for the entire lifetime of the session. Stateful BSP Application In Stateful BSP Applications the only instance of the application class. the application object cannot hold data across requests. however. the BSP runtime environment must treat the class as a singleton. the application class provides local buffering for data sets that are difficult to determine. depending on the state mode where the class is implemented. but do not buffer data. Stateless BSP Application In Stateless BSP Applications. In stateless mode. . the application class cannot be generically instantiated by the BSP runtime environment.

The BSP model provides this function for the application class in the predefined interface IF_BSP_APPLICATION_EVENTS.For stateless applications. When an application class implements the optional interface IF_BSP_APPLICATION_EVENTS. Instead. an application often needs centralized control at certain times in the lifetime of the application. just get the exact data you need at that time. this is a good time for cleanup operations such as deleting browser cookies or server-side cookies. Please note that this time point is not available after every request in stateless BSP applications. Consequently. for example. this time point is used to carry out authorization checks that apply to the entire application. in this method it is only possible to execute optional operations that are not critical. it would be useless to implement expensive data gathering routines as these would be lost after every request. if the application generated them. or for preliminary data retrieval (in stateful applications). Application Events: The IF_BSP_APPLICATION_EVENTS Interface In stateless BSP applications. The following describes the methods and times: IF_BSP_APPLICATION_EVENTS~ON_START This method is called by the BSP runtime environment when the corresponding BSP application is first started at the start of the BSP session. In stateful applications. This applies to both stateless and stateful applications. . Typically. the BSP runtime environment calls the interface methods at the relevant times. In addition this time is not evaluated if the session is implicitly terminated by a timeout. This applies to both stateless and stateful applications. IF_BSP_APPLICATION_EVENTS~ON_STOP This method is called by the BSP runtime environment when the corresponding BSP application is explicitly ended. Typically. which can improve performance. IF_BSP_APPLICATION_EVENTS~ON_REQUEST This method is called by the BSP runtime environment for every incoming request to a BSP before the BSP is given control (in the OnRequest event handler). you can implement an initialization phase where you get a large amount of data at one time.

This time can be used by the application class.or server-side cookies in a previous request. current URL of BSP application. to restore attributes that were rescued in client. This makes it easy to provide the relevant functionality to lower application levels using a single object reference. See also: You can find details of basis class CL_BSP_APPLICATION in the reference documentation: Class CL_BSP_APPLICATION BSP Components Business Server Pages (BSPs) are HTML pages that contain the actual application logic and presentation logic. it can be derived from the predefined base class CL_BSP_APPLICATION. This is how information about the current BSP application (such as session timeout. As the application object is an application attribute in every BSP event handler. and so on) can be called or set. the methods of the CL_BSP_APPLICATION class are also available with the corresponding inheritance. BSPs define the Web user interface and determine the elements of user interaction. This class provides methods that are typically required by a BSP application for embedding in a Web environment. state mode. See also: You can find details of interface IF_BSP_APPLICATION_EVENTS in the reference documentation: Interface IF_BSP_APPLICATION_EVENTS Application Basis Class CL_BSP_APPLICATION If an application class does not already have a super class. . This time can be used by a stateless application class for tasks such as rescuing attributes in client-side or server-side cookies. IF_BSP_APPLICATION_EVENTS~ON_RESPONSE This method is called by the BSP runtime for every outgoing response of a BSP after the BSP has been processed (after the OnManipulationevent handler). for example.

For example. BSPs also have different administration attributes. In the preview. The following describes the most important additional properties. and to make this data accessible for the layout processing and the other event handlers. Page attributes are visible in the layout processing as well as in the event handlers of a page. Page Type . You can use type definitions to define local types. without having to call up the browser. Similar to every object in the SAP System. Predefined event handlers are available for the different events. Properties BSPs have a number of general properties or attributes. you can check the appearance of your pages. They can be used to store data obtained in the standard handler OnInitialization. and each BSP has a URL used to call up the BSP in a Web browser.BSPs consist of the following components: Server-side scripting determines the presentation logic as part of layout processing. each BSP is assigned to a package in the SAP system.

all other BSPs of your BSP application are accessed using HTTPS. Status A BSP can be stateful or stateless. The BSP runtime then checks the URL. In the case of http://. provided that the browser supports compression.. Note that it only makes sense to activate compression for large pages. . For more information see Stateful and Stateless. . the page is sent compressed to the browser. Not the following browser-specific feature: As soon as you activate HTTPs. that is. It is considerably more efficient to send small pages uncompressed. a secure connection. you can determine that a BSP should be accessed using HTTPS. • Compressing If you set this flat..You can find additional information about the different features of a page in Structure of a BSP Application. Transmission Options You can set the flags Compression and HTTPS as the transmission options. Caching For more information see Caching BSPs.. it redirects the browser immediately to https://.. It is considerably more efficient to send small pages uncompressed. It is considerably more efficient to send small pages uncompressed. Error Handling For more information see Creating Error Pages. • HTTPS By selecting this flag.

You can create your own stylesheets or use predefined ones. Example BSP only with Layout . Therefore. Page object is defined in interface IF_BSP_PAGE. response object is defined in interface IF_HTTP_RESPONSE.Layout Use You determine the presentation logic for your BSP using server-side scripting in the layout. Functions You can access the following objects in the implementation: Object APPLICATION Reference Type type ref to application class Description Application class refers to the individual application or application class specified in the BSP application. If there is no application class in the BSP application. To ensure clean development. runtime object is defined in interface IF_BSP_RUNTIME . The layout can also be regarded as an internal event handler for the presentation. this means object application is not available. while the dynamic processing steps are set in the different event handlers (see Event Handlers). scripting for the static details of a page is part of layout processing. layout and presentation must be separated from processing logic. RUNTIME REQUEST type ref to IF_BSP_RUNTIME type ref to IF_HTTP_REQUEST RESPONSE type ref to IF_HTTP_RESPONSE PAGE PAGE_CONTEXT type ref to IF_BSP_PAGE type ref to IF_BSP_PAGE_CONTEXT Page context object is defined in interface IF_BSP_PAGE_CONTEXT. request object is defined in interface IF_HTTP_REQUEST.

This event handler is mainly used for data retrieval. This event handler is available for special functions. OnRequest OnInitialization OnInputProcessing OnManipulation OnDestroy The ABAP syntax checks that apply in the context of ABAP Objects also apply to event handlers. that is. This event handler checks and processes user input. whether the user should be taken to the same page or another when the BSP is called. See also: . while the event handlers deal with the dynamic data. Global objects and their signatures for individual event handlers are displayed if you choose in the Web Application Builder. Global objects are also available. and performs a once-off data initialization or object creation. The use of the individual event handlers is explained in more detail in the individual sections of the documentation. The following predefined event handlers are available in the SAP system: Event Handler OnCreate Description OnCreate is called once when the page is first created (stateful mode). You can use this event handler to manipulate the HTTP data stream later. It can also execute any program.Event Handler Event handlers allow the separation of static and dynamic code in a page. OnRequest is called whenever a request is made for a particular page and is used to restore the internal data structures from the request. it allows data required for displaying the BSP to be read from the database. For example. It can also define navigation. This is important when working in stateless mode. Read and modify access to page attributes is available in all handlers. The layout processing deals with the static data.

Integration OnCreate is useful mainly in stateful applications. OnCreate is not run the second time. The data that is used to fill the object is read in the event handler OnInitialization The BSP application is called in the following cases: • • Single call. the the normal ABAP OO constructor. such as the online shopping basket. the page instance remains constant. and performs a once-off data initialization or object creation. See also: Stateful and Stateless BSP Applications Functions You can access the following objects in the implementation: Object APPLICATION Reference Type type ref to application class Description Application class refers to the individual application or application class specified in the . and if you run the page a second time (reuse the page). Call each time if the BSP page class is created in the stateless case.Control Flow of BSPs OnCreate Use OnCreate is used when a page is called for the first time. the page object is reinitialized every time the page is called. if the BSP application is staeful. In this case. In you are working in stateful mode without an explicit navigation path. create object shopbasket. because in stateless mode. this corresponds to the constructor). You can therefore initialize the page object (in object-oriented thought. OnCreate initializes the parts of the object that are created once and then used for the entire lifetime of the object. The opposite of OnCreate is OnDestroy. OnCreate is called each time that the BSP page class is created.

OnRequest Use OnRequest is run when a request comes to access the current page. In this case. this means that the object application is not available. OnInputProcessing is run after OnRequest. Page context object is defined in interface IF_BSP_PAGE_CONTEXT. OnCreate is skipped and OnRequest is called straight away. This request can be made in the following ways: • • The URL is entered in the browser. Page object is defined in interface IF_BSP_PAGE. If there is no application class in the BSP application. In this case.BSP application. this means that the . See also: Event Handlers Integration OnRequest is the second handler (after OnCreate) to be called when a BSP is being processed. In this case. RUNTIME PAGE PAGE_CONTEXT type ref to IF_BSP_RUNTIME type ref to IF_BSP_PAGE type ref to IF_BSP_PAGE_CONTEXT The runtime object is defined in interface IF_BSP_RUNTIME . Functions You can access the following objects in the implementation: Object APPLICATION Reference Type type ref to application class Description Application class refers to the individual application or application class specified in the BSP application. If there is no application class in the BSP application. The user inputs data on a page (current page or other pages). The only exception to this occurs when a page is recalled in stateful mode without explicit navigation. OnInitialization is run after OnRequest.

this would be the catalog ID and the number of objects. the shopping basket object is initialized using OnCreate and then filled with selected products. This handler implements data retrieval. The data is stored in page attributes and is therefore accessible in the layout and in the other event handlers. OnInitialization is used for getting data from database tables. Page context object is defined in interface IF_BSP_PAGE_CONTEXT. Integration While the event handler OnCreate is used to initialize objects needed for entire page.object application is not available. Here. . If you develop a BSP for managing a shopping basket. Page object is defined in interface IF_BSP_PAGE. and so on. calculate the current subtotal. Example Persistency of Data Using Serverside Cookies OnInitialization Use This event handler is processed directly after OnRequest during page processing. RUNTIME REQUEST type ref to IF_BSP_RUNTIME type ref to IF_HTTP_REQUEST The runtime object is defined in interface IF_BSP_RUNTIME . You use OnInitialization to read the short texts from the database. The request object is defined in interface IF_HTTP_REQUEST. EVENT_ID NAVIGATION PAGE PAGE_CONTEX T type STRING type ref to IF_BSP_NAVIGATION type ref to IF_BSP_PAGE type ref to IF_BSP_PAGE_CONTEXT The navigation object is defined in interface IF_BSP_NAVIGATION.

If there is no application class in the BSP application. The request object is defined in interface IF_HTTP_REQUEST. Page object is defined in interface IF_BSP_PAGE. Page context object is defined in interface IF_BSP_PAGE_CONTEXT. The navigation object is defined in interface IF_BSP_NAVIGATION. this means that the object application is not available. The response object is defined in interface IF_HTTP_RESPONSE. . The runtime object is defined in interface IF_BSP_RUNTIME . RUNTIME REQUEST type ref to IF_BSP_RUNTIME type ref to IF_HTTP_REQUEST RESPONSE type ref to IF_HTTP_RESPONSE NAVIGATION PAGE PAGE_CONTEXT type ref to IF_BSP_NAVIGATION type ref to IF_BSP_PAGE type ref to IF_BSP_PAGE_CONTEXT Example BSPs with Layout.Functions You can access the following objects in the implementation: Object APPLICATION Reference Type type ref to application class Description Application class refers to the individual application or application class specified in the BSP application. Initialization and Navigation OnManipulation Use This event handler is processed after the WCF controls embedded in the page are generated.

The response object is defined in interface IF_HTTP_RESPONSE. The request object is defined in interface IF_HTTP_REQUEST. this means that the object application is not available. Functions You can access the following objects in the implementation: Object APPLICATION Reference Type type ref to application class Description Application class refers to the individual application or application class specified in the BSP application. The runtime object is defined in interface IF_BSP_RUNTIME .You can use OnManipulation to manipulate the HTTP data stream again (in particular for XSLT processing). Page object is defined in interface IF_BSP_PAGE. . If there is no application class in the BSP application. You can use it to execute closing actions for a page. Page context object is defined in interface IF_BSP_PAGE_CONTEXT. RUNTIME REQUEST type ref to IF_BSP_RUNTIME type ref to IF_HTTP_REQUEST RESPONSE type ref to IF_HTTP_RESPONSE PAGE PAGE_CONTEXT type ref to IF_BSP_PAGE type ref to IF_BSP_PAGE_CONTEXT Example Persistency of Data Using Serverside Cookies OnDestroy Use This event handler runs immediately before the page instance is deleted and is therefore the exact opposite of OnCreate.

this event handler is not usually required and is therefore rarely used. both OnCreate and OnDestroy are called for every request-response cycle. The runtime object is defined in interface IF_BSP_RUNTIME . for example: Using OnCreate you can load the cookie and then (at the end of the process flow) you use OnDestroy to store it again so that the information held in the cookie does not get lost. Page object is defined in interface IF_BSP_PAGE. RUNTIME PAGE PAGE_CONTEX T type ref to IF_BSP_RUNTIME type ref to IF_BSP_PAGE type ref to IF_BSP_PAGE_CONTEXT You can use this event handler in connection with server-side cookies. Page context object is defined in interface IF_BSP_PAGE_CONTEXT.Since locks and so on are reset in ABAP. The system then explicitly destroys the controller and calls the corresponding method. With stateless processing. If there is no application class in the BSP application. Object APPLICATION Reference Type type ref to application class Description Application class refers to the individual application or application class specified in the BSP application. This event handler is therefore called in very rare cases. You can access page attributes from the layout and from all event handlers. OnDestroy is only called right at the end when you switch back to stateless processing. With stateful processing. this means that the object application is not available. You use page attributes to store data that . the event handler OnDestroy is not called in every request-response cycle and the page object is not destroyed. Functions You can access the following objects in the implementation: Page Attributes Page attributes are parameters that are declared explicitly for one page. for example if an application is stateful and the controller’s lifetime is shorter.

Additional information is described below. for example. given automatically at any time. This kind of attribute only has to be declared for one page. If. you can access firstname in the layout as follows: <input type=text name="myaddress. Now.10. Access to the contents of the page attribute is not. If you then use a parameter of the same name on another page. 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. you fill an internal table in OnIntialization that you have defined as a page attribute. Possible Types for Automatic Page Attributes Before SAP Web Application Server 6. this parameter will automatically get the value ' LH' (Lufthansa) at runtime. although this definition is known in OnInputProcessing.firstname"> . If another page uses a parameter with the same name. at runtime that parameter automatically gets the same values as the attribute. however. other types are available: • • • Elementary types except for XSTRING Structures Tables If firstname is a field in a structure called myaddress of the type address. and you can use the page attributes to make the data accessible to layout processing and the remaining event handlers. It is identified by its name equivalence. the attribute automatically gets its values via the calling URL or via the navigation process from other pages. and myaddresses is a table of addresses. There are two types of page attributes: • • Automatic page attributes Non-automatic page attributes Automatic Page Attributes If you mark a page attribute as ‘automatic’ (auto in the system). the table contents is not known if you are working in stateless mode. auto page attributes could only have the type STRING.is determined in the event handler OnInitialization.

In explicit navigation. With implicit navigation. so that the values that were set are not lost. When the page object is being reinstantiated.firstname allows you to specify the first name in question in the line of the table represented by ‘i’. both in stateful and stateless mode. the page attributes are transferred automatically from OnInputProcessing to OnInitialization. if i=6.htm) is called. the attributes with navigation->set_parameter must be transferred to auto page attributes of the same name. but is reinstantiated in stateless mode.myadresses[i]. Transferring Parameters Between Pages: Visibility of Page Attributes The visibility of page attributes when parameters are transferred between BSP pages depends on whether the navigation is explicit or implicit. the same page is run again. The difference is that. The auto page attributes are refilled by the request. both in stateful and stateless mode. the page object is always reinstantiated. that is. the first name used in line 6 of the table is being referred to. this is explicit navigation. if navigation->goto_page(page. Non-automatic page attributes If you flag a page attribute as non-automatic. Lifetime of Page Attributes When you navigate between pages. Because no explicit navigation has been provided. in both stateful and stateless mode. This is because the page instance stays ‘alive’ in stateful mode. • Implicit navigation User input triggers the sending of a request. the values are reset to the original values. there are the following cases of different lifetimes for automatic and non-automatic page attributes: • • Lifetime of attributes remaining on the same page Lifetime of attributes with navigation to the same page . the attribute gets its values from the class attribute. any non-auto page attributes that may have changed retain the changed value. • Explicit navigation For example. It does not matter if the navigation takes you to the same page from which you came. whereas in stateless mode. in stateful mode.

Attribute Type Value in Request (Example Value) SAP SAP Value in OnInputProcessing Explicit Transfer Value in OnInitialization automatic automatic Non-automatic Non-automatic SAP SAP SAP SAP No Yes No Yes SAP Lifetime of attributes with navigation to a different page The navigation object is used (navigation->goto_page(otherpage. Attribute Type Value in Request (Example Value) SAP SAP Value in OnInputProcessing Explicit Transfer Value in OnInitialization automatic automatic Non-automatic Non-automatic SAP SAP SAP SAP No Yes No Yes SAP SAP SAP SAP Lifetime of attributes with navigation to the same page The navigation object is used (navigation->goto_page(samepage.htm)) to navigate to a different page.htm)) to navigate to the same page.• Lifetime of attributes with navigation to a different page Lifetime of attributes remaining on the same page No navigation takes place. .

however. If you want to use a page attribute that should only be used within a page and in the different methods of the page (event handler and layout). Types that are used several times or that can be implemented universally should be defined in the Data Dictionary. you call the BAPI browser through which you cut & paste the type definitions and a template for the requested BAPI call to the Type Definition and Event Handler tabs in your BSP. you can create a local type for this. In the page editor. You define local types only for those objects that are necessary within a BSP for the processing process. BSP Directives Overview . Type definitions are not available for views. Type definitions are therefore local types visible in all event handlers of a BSP and the BSP itself. Type definitions are also relevant when BAPIs are used (see BAPI Explorer).Attribute Type Value in Request (Example Value) SAP SAP Value in OnInputProcessing Explicit Transfer Value in OnInitialization automatic automatic Non-automatic Non-automatic SAP SAP SAP SAP No Yes No Yes SAP Type Definitions You can create type definitions for pages with flow logic.

. * BSP SCRIPT source . The following BSP directives are available: • • • • • • Page Directive Inline Code Comments Include Directive OTR Directives Extension Directive You use the Tag Library to add BSP directives to your code using Drag & Drop. The syntax is compatible with the familiar server page technology. endif.BSP directives are enclosed in tags: <% Directive %> The directives described in the following sections are supported by Business Server Pages (BSP).. if sy-subrc ne 0. %> and: <% read table itab index lv_index. %> <% if sy-subrc ne 0. * BSP SCRIPT source read table itab index lv_index. Special Programming Features The following code sections for the layout of a BSP are not equivalent: <% read table itab index lv_index. * BSP STATIC source * HTML begin: #### ###### CALL METHOD %_IF_PM->ADD_STATIC_REF exporting encoding = 0 source = %_HTML_POOL offset = 0000018407 length = 0000000039 . The second code extract does not: . clear workarea. %> The first code extract above contains a function module call between the two ABAP commands. clear workarea.. For more information see Transferring Variables. endif.

The default value is FALSE.. Page Directive Definition This directive is used to specify the script language.if sy-subrc ne 0. An example of switched on attribute (otrTrim=true): <%@page language="abap" otrTrim="true" %> <% DATA: s TYPE STRING VALUE 'test'. If it is set to TRUE. </otr>]<br> [<%= otr(sbsp_test/it00_otr_1) %>] . This means that the sy-subrc set when the internal table is read is overwritten by the function module call.. .. ABAP and JavaScript are currently supported. <%@ page language=("ABAP" | "JAVASCRIPT") otrTrim=("TRUE" | "FALSE") %> This attribute is a boolean value. endif. clear workarea. the attribute otrTrim is also available for the page directive. it can have the values TRUE and FALSE. all OTR texts on a page are condensed by removing all blank characters from the start and end of a string. <%@ page language=("ABAP" | "JAVASCRIPT") %> otrTrim From SAP Web AS 6. %> [<otr> test line </otr>]<br> [<otr> before <%= s%> middle <%= s%> end. The two pieces of code therefore behave differently. that is.20 Support Package 7.

The inline code is written in the language specified with the Page directive. <% inline code %> . </otr>]<br> [<%= otr(sbsp_test/it00_otr_1) %>] The output generated using this coding then looks as follows: [ test line ] [ before test middle test end. ] [This is a test for an alias text] Inline Code Definition With this directive you can embed the script code into the page.The output generated using this coding then looks as follows: [test line] [before test middle test end. %> [<otr> test line </otr>]<br> [<otr> before <%= s%> middle <%= s%> end.] [This is a test for an alias text] Example of the case when otrTrim is switched off (otrTrim=false): <%@page language="abap" otrTrim="false" %> <% DATA: s TYPE STRING VALUE 'test'.

Enter the URL of the page to be pasted in relative to the URL of the current page.code comments or text --%> Include Directive Definition With this directive you can paste in existing pages or pages fragments into the page. <%@ include file="relative URL"%> .<%@ page language="javascript"%>… <% inline code javascript %>… Comments Definition You can write comments on the code on the server. they require longer processing times as well as larger bandwidths. When you use HTML comments. Unlike code that includes HTML comments. This is why you should not use HTML comments with BSPs or views. however. <%-. server-side comments are not included in the page sent to the client /browser.

Use There are two ways of using the OTR. See also: Internationalization and Translation Online Text Repository (OTR) Transferring Variables You can transfer expressions. If the user logs on in a different language. they see the translated text. 2. for example variables. OTR texts can be translated into other languages using translation tools. 1. At runtime.OTR Directives Definition The Online Text Repository (OTR) is a repository for all HTML texts. the OTR directive is replaced by the text defined for the logon language. Then you can display the text with the following syntax: <%=otr(alias)%>. You can first write the text in the OTR and give it an alias that should be as meaningful as possible. can also contain scripting code </otr> This is an auto-OTR text that is automatically transferred to the OTR and translated there. which are accessed using an alias. You can however also specify the text in the page layout: <otr> HTML text. The text is only automatically transferred if it was entered in the original language. with the following syntax: Value transfer: object = <%=varname%> .

The prefixes sap and bsp are reserved. With bgcolor = "<%=color%>" the current value of the variable color is assigned to the attribute bgcolor.bgcolor = "green" creates a green background by transferring the value green. The extension directive is always located immediately after the page directive. See also: BSP Extensions Classes and Interfaces The following classes and interfaces are central components of the BSP programming model. <%@extension name="<Name>" prefix="<Präfix>"%> The prefix is used as the namespace for all elements in the BSP extension. Classes: • • • • Class CL_BSP_APPLICATION Class CL_BSP_MESSAGES Class CL_BSP_SERVER_SIDE_COOKIE Class CL_BSP_GET_TEXT_BY_ALIAS • Class CL_BSP_CONTROLLER2 Interfaces: • • • • • • Interface IF_BSP_APPLICATION Interface IF_BSP_APPLICATION_EVENTS Interface IF_BSP_NAVIGATION Interface IF_BSP_PAGE Interface IF_BSP_RUNTIME Interface IF_BSP_PAGE_CONTEXT . As a result you can access all elements of the extension in your BSP. Extension Directive Definition You can use the extension directive to import a BSP extension into your BSP.

All of the methods of class CL_BSP_APPLICATION can be accessed via the interface IF_BSP_APPLICATION and are described in the corresponding reference documentation. you can use interface IF_CLIENT_INFO. To develop BSP applications with the focus on representing Web pages on different mobile end devices. Each application has the option of deriving its own application class from CL_BSP_APPLICATION .• Interface IF_HTMLB_TABLEVIEW_ITERATOR Many of these classes and interfaces are the basis for their associated global objects. . If the application class has not already been derived in an inheritance hierarchy. Class CL_BSP_APPLICATION Overview Class CL_BSP_APPLICATION is an optional superclass for BSP application classes. current URL of BSP application. Class CL_BSP_APPLICATION has 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. See Also: • • IF_BSP_APPLICATION Object application Class CL_BSP_MESSAGES Overview You can use class CL_BSP_MESSAGES in BSPs for outputting error and information messages. we recommend that it is derived from CL_BSP_APPLICATION . state mode and so on) can be called or set.

Each BSP has an instance of this class that contains the current messages of the class. This method inserts the message on the condition specified into the list of messages. The object is accessed from a BSP via the parameter page of the event handler as page->messages or via the self-reference me in the form of interface qualification me->if_bsp_page~messages. If Description . This makes it easy to place input-specific messages directly beside the relevant input fields. Inheritance Hierarchy/Interface Composition Implemented Interface - Superclass - Attributes Attribute Name co_severity_error co_severity_fatal_error co_severity_info co_severity_success co_severity_warning Declaration Type Constants Constants Constants Constants Constants Description Error severity: error Error severity: Fatal error Error severity: Information Error severity: Confirmation of success Error severity: Warning Methods Method add_message Signature method add_message importing condition type string message type string optional otr_alias type string optional severity type i default co_severity_error . The object is reset after every HTTP request/response cycle.You can flag each message with a condition that serves as a key for the message. The effect of this is that a message is only output in a BSP if the pertinent condition is fulfilled.

Description .. assert_message. the message text is transferred directly. for example. Parameters CONDITION MESSAGE Message condition Message text (if otr_alias-parameter is not used) Alias name of an OTR text to be used as message text (if message parameter is not used) Message severity (see constants co_severity_. One of the two parameters message or otr_alias must be specified (exclusive or).n) for the condition specified or 0 if there is no message for this condition.. This makes it easy to address language-dependent messages from the OTR. you want to insert HTML areas in the output on a messagedependent basis.) OTR_ALIAS SEVERITY Return Values/Exceptions Cross References See also: assert. assert_severity Method assert Signature method assert importing condition type string returning index type i . This method returns the message index (1. you can use this method in BSPs in if statements if. If message is used. Thus. it is overwritten. if otr_alias is used. the alias name of an OTR text is transferred.there is already a message with the condition..

Example: . it returns an empty string.. assert_severity Method assert_message Signature method assert_message importing condition type string returning message type string . If there is no message for the condition.. <% if page->messages->assert( 'invaliduser' ) <> 0.gif"> <%= page->messages>assert_message( 'invaliduser' ) %> <% endif %> … Parameters Return Values/Exceptions CONDITION INDEX Message condition =0: no message for condition >0: Message index Cross References See also: assert_message. This method returns the message for a specified condition. . CONDITION MESSAGE Message condition Message Description Parameters Return Values/Exceptions Cross References See also: assert. assert_severity Method assert_severity Signature method assert_severity importing condition type string returning severity type i . %> <img src="stop.

) Description Parameters Return Values/Exceptions Cross References See also: add_message. assert_message Method get_message Signature method get_message importing index type I exporting severity type I condition type string message type string . CONDITION SEVERITY Message condition =0: no message for condition >0: Message severity (see constants co_severity_. if index > num_messages().) Parameters Return Values/Exceptions Cross References See also: assert...n). ) for the specified condition. in other words. This method returns information about the message for the specified index (1. If there is no message for the index. or 0 if there is no message for the condition.. INDEX message condition severity Message index (1.num_messages()) Message text Message condition Message severity (see constants co_severity_. num_messages Method num_messages .. this is indicated by severity = 0 ...Description This method returns the message severity (see constants co_severity_...

The parameters username and session_id deserve special attention. and managing cookies on the server. Server-side cookies are persistent data. A server-side cookie is stored on the database. . getting. an error will occur. It would be better to use session_id (see example) since runtime->session_id indicates the browser session. the number of cookies to 300 in total and 20 per server or domain. server-side cookies are subject to no such restrictions.Signature method num_messages returning count type I . please note that it must be returned to the same data structure. However. For technical reasons. Setting username to sy-user is ambiguous in cases where an application is started by an anonymous user stored on the server. which you can query using an error method. while on the client-side. count See also: add_message Number of currently existing messages Description Parameters Return Values/Exceptions Cross References Class CL_BSP_SERVER_SIDE_COOKIE Overview Class CL_BSP_SERVER_SIDE_COOKIE provides methods for setting. similar to the usual client-side cookies. each individual cookie can be stored in one of the following ways: • • • as a field or as a structure or as an internal table When you get a cookie. This method returns the number of messages that were defined using add_message(). there are restrictions that limit the size of cookies to around 4 kilobytes per cookie. deleting. Otherwise.

or whether the application should be stateful. Cookie does not exist. The data object of the cookie to be read does not match the data object of the set cookie.When you design an application. The program BSP_CLEAN_UP_SERVER_COOKIES deletes all expired cookies to the day. The system administrator should schedule the program BSP_CLEAN_UP_SERVER_COOKIES to run in the background on a regular basis. Class CL_BSP_SERVER_SIDE_COOKIE is contained in the package SBSP_RUNTIME. A stateful application makes sense when there is a large amount of context data that would otherwise have to be read from or written to the database using cookies and thus slow down performance (see also Stateful or stateless programming?). The program BSP_SHOW_SERVER_COOKIES provides an overview of all of the cookies set in the system. you should give careful consideration to whether the application should be stateless and the required context data be retained from page to page in cookies (client-side or server-side). Call parameters are missing. Inheritance Hierarchy/Interface Composition Implemented Interface - Superclass - Attributes Attribute Name CC_OK CC_WRONG_DATA_OBJECT Declaration Type Constants Constants Description Action was successful. CC_PARAMETER_MISSING CC_NOT_EXISTS Constants Constants Methods .

call method cl_bsp_server_side_cookie=>get_server_cookie . EXPIRY_TIME EXPIRY_DATE DATA_NAME SESSION_ID USERNAME APPLICATION_NAMESPACE APPLICATION_NAME NAME DATA_VALUE Validity date (time): to time Validity date (date): to date Data object name Session ID Name of user Name space of BSP application Name of BSP application Name of cookie Data object content Description Parameters data: sorders type sales_orders. usr type string. edate type d. clear sorders. Method get_server_cookie Signature method GET_SERVER_COOKIE exporting NAME EXPIRY_TIME EXPIRY_DATE SESSION_ID USERNAME APPLICATION_NAMESPACE APPLICATION_NAME DATA_NAME DATA_VALUE This method gets a server cookie.All of the methods are in the visibility section public section. etime type t.

. Method delete_server_cookie Signature method DELETE_SERVER_COOKIE exporting NAME APPLICATION_NAME APPLICATION_NAMESPACE USERNAME SESSION_ID This method deletes a server cookie.exporting name = 'SALESORDER_GETLIST' application_namespace = runtime>application_namespace application_name = runtime->application_name username = usr session_id = runtime->session_id data_name = 'SORDERS' importing expiry_date = edate expiry_time = etime changing data_value = sorders. NAME APPLICATION_NAME APPLICATION_NAMESPACE USERNAME SESSION_ID Name of cookie Name of BSP application Name space of BSP application Name of user Session ID Description Parameters data: usr type string. call method cl_bsp_server_side_cookie=>delete_server_cookie exporting name = 'SALESORDER_GETLIST' application_namespace = runtime>application_namespace application_name = runtime->application_name username = usr session_id = runtime->session_id.

and email address Relative validity duration in seconds If you do not specify a value.59. DATA_NAME SESSION_ID USERNAME EXPIRY_TIME_REL Data object name Session ID if required Name of user. DATA_VALUE EXPIRY_DATE_ABS EXPIRY_TIME_ABS Data object content Valid to date Absolute validity duration Description Parameters If you do not specify a value. . the system sets the relative validity duration to 23.59.Method set_server_cookie Signature method SET_SERVER_COOKIE importing DATA_VALUE exporting EXPIRY_DATE_ABS EXPIRY_TIME_ABS DATA_NAME SESSION_ID USERNAME EXPIRY_TIME_REL EXPIRY_DATE_REL APPLICATION_NAMESPACE APPLICATION_NAME NAME This method sets a server cookie. the system sets the absolute validity duration to 23.

Description .EXPIRY_DATE_REL APPLICATION_NAMESPACE APPLICATION_NAME NAME Validity duration in days Name space of BSP application Name of BSP application Name of cookie data: sorders type sales_orders. usr type string. "valid for one day call method cl_bsp_server_side_cookie=>set_server_cookie exporting name = 'SALESORDER_GETLIST' application_namespace = runtime>application_namespace application_name = runtime->application_name username = usr session_id = runtime->session_id expiry_date_abs = edate expiry_time_abs = sy-uzeit data_name = 'SORDERS' data_value = sorders. call function 'BAPI_SALESORDER_GETLIST' destination 'ABC' exporting customer_number = '0000001000' tables sales_orders = sorders. edate = sy-date. Method get_last_error Signature method GET_LAST_ERROR importing RC This method returns the return code of the last call. edate type d. add 1 to edate.

rc = cl_bsp_server_side_cookie=>get_last_error( ). txt type string. if rc ne 0. endif. txt = cl_bsp_server_side_cookie=>get_last_error_name( ). NAME Internal error text Description Parameters data: rc type i.Parameters RC Returncode data: rc type i. rc = cl_bsp_server_side_cookie=>get_last_error( ). Method get_server_cookie_info Signature method GET_SERVER_COOKIE_INFO exporting COOKIES APPLICATION_NAMESPACE APPLICATION_NAME SESSION_ID USERNAME NAME . Method get_last_error_name Signature method GET_LAST_ERROR_NAME importing NAME This method returns the internal name of the exception of the last call. txt type string.

Class CL_BSP_GET_TEXT_BY_ALIAS Overview Class CL_BSP_GET_TEXT_BY_ALIAS provides a method to fetch OTR alias texts. cookie_info type tsscookiei. Inheritance Hierarchy/Interface Composition Implemented Interface - Superclass . COOCIES APPLICATION_NAMESPACE SESSION_ID USERNAME NAME APPLICATION_NAME List of all cookies. call method cl_bsp_server_side_cookie=>get_server_cookie_info exporting application_name = runtime->application_name username = usr importing cookies = cookie_info .Description Parameters This method returns information about server cookies. Name space of BSP application Session ID Name of user Name of cookie Name of BSP application data: usr type string.

. write / TEXT.- Attributes - Methods Method GET_TEXT Signature method GET_TEXT importing LANGUAGE ALIAS returning ALIAS_TEXT. data TEXT type STRING. This method fetches an OTR alias text for a specified OTR alias name. TEXT = CL_BSP_RUNTIME=>GET_OTR_TEXT( ALIAS = 'sbsp_test/it00_otr_1' ). LANGUAGE ALIAS Current language of SAP System Name of alias in form ’<Paket>/<Aliasname>’ Text of the alias Description Parameters ALIAS_TEXT Cross References See also: Internationalization and Translation Method GET_OTR_TEXT of IF_BSP_RUNTIME report OTRTEST. class CL_BSP_RUNTIME definition load.

Class CL_BSP_CONTROLLER2 enables you to: • • • • Retain a list of sub-controllers Create unique IDs for the sub-controllers. where the sub-controller is assigned the controller ID prefix Use models Forward data to the correct controller as well as fill model classes (if they exist) Methods Below you can find an overview of all methods in a controller class. Functions where overwriting is recommended . then this method handles both input and output processing. then this method only handles output processing. Processing Process provides details on the most important methods. Every controller class automatically inherits all methods and attributes from this central basic class. change the inheritance hierarchy accordingly.Class CL_BSP_CONTROLLER2 Overview Class CL_BSP_CONTROLLER2 is used to create controllers and components. If the basic class of your controller class displays CL_BSP_CONTROLLER instead of CL_BSP_CONTROLLER2. this method is called for every request. DO_REQUEST can be used in two different areas: • • If it is the top-level controller of a component. The individual methods can be separated into different categories: Functions where overwriting is required DO_REQUEST is the central method in a controller class. In DO_REQUEST you specify the request processing. You must overwrite this method. If it is a sub-controller of a component. that is. in particular it should branch to the correct view. This method does the "main work".

which contains an event such as a save button. Functions where overwriting is possible You can overwrite these methods in order to determine input processing.You should overwrite these methods in order to determine input processing. In this method. DO_FINISH_INPUT Ends the input processing. This method is not absolutely necessary. Method DO_INIT Description This method is called once at the start and is used for initialization. Method DO_HANDLE_DATA DO_HANDLE_EVENT Description Reacts to user input. Exactly one view controller is called to handle the event. DO_INITATTRIBUTES This method is called with every request and is used to initialize the attributes. since you can use DO_REQUEST to solve everything that you can (theoretically) handle here. The parameters are read from the request. Service functions You can call these methods: Method CREATE_VIEW Description Creates or fetches a view instance . Processes data input for this component. This method behaves like a constructor method. Reacts to user input. for example. Processes events if the component contains them. you can also execute initializations that are required for each request. You can also use this method to set additional attributes.

Changes the lifetime of this page (only for the toplevel controller) Creates a formatted string Writes a formatted string in the output Fetches the current output writer Changes the MIME type of the page or the content type of the header field Instantiates the parameter from the request using the request data Changes the caching values There are two types of caching: • • Browser cache Server cache GET_ATTRIBUTE GET_LIFETIME GET_PAGE_URL SET_ATTRIBUTE SET_LIFETIME TO_STRING WRITE GET_OUT SET_MIME_TYPE INSTANTIATE_PARAMETER SET_CACHING . object A view must always belong to the same BSP application as its controller. CALL_VIEW CREATE_CONTROLLER CALL_CONTROLLER Calls the request handler of the view instance. or the navigation. Generic method for setting an attribute value. Returns the specified page attributes. Generic method for reading an attribute value. Returns the lifetime of this page (only for the top-level controller) Returns the URL of the page or the current controller Sets the specified page attributes.Use either the name of the view. Creates or fetches a controller instance Calls the request handler (method DO-REQUEST) of the controller instance.

DISPATCH_INPUT calls the correct methods in the correct sequence. This is relevant with input processing. See also Lifetime Deletes a model instance Fills the model data Deletes a sub-controller Fetches a model instance Is this controller a top (main) controller (0: no. This method fetches data from the request. GET_ID SET_MODEL CREATE_MODEL GET_CONTROLLER CONTROLLER_SET_ACTIVE Calculates the ID from the specified ID and the component ID Creates and registers a model instance Creates and registers a model instance Fetches a sub-controller Sets a controller to active/inactive. For each input. 1: yes)? DELETE_MODEL FILL_MODEL_DATA DELETE_CONTROLLER GET_MODEL IS_TOPLEVEL IS_NAVIGATION_REQUESTED . You can only use limited caching here.See also Caching BSPs. Note that the server cache is not user-specific. DISPATCH_INPUT Dispatches the input processing (only for the top-level controller). since you can use it to hide a controller. you should reset the cache that may be set. If you change the page. 1: yes)? Has a controller requested a navigation (0: no. This method does not have any attributes.

They are not usually relevant for application development. It provides methods that enable a BSP application to call up information about its runtime environment or influence this environment.Framework functions These methods are provided as part of the framework and are only included here for the sake of completeness. Processes or dispatches: handling values Processes or dispatches: Handle event Finds components for a field name Finds model for a field name Methods DO_DESTROY and SUBSCRIBE are not relevant. Interface IF_BSP_APPLICATION Overview The interface IF_BSP_APPLICATION is implemented using class CL_BSP_APPLICATION. Inheritance Hierarchy/Interface Composition Implementing Classes CL_BSP_APPLICATION Enhanced Interface . Method IF_BSP_DISPATCHER~REGISTER IF_BSP_CONTROLLER~FINISH_INPUT_PROCESSING IF_BSP_CONTROLLER~FILL_VALUES IF_BSP_CONTROLLER~HANDLE_EVENT GET_FIELD_COMPONENT GET_FIELD_MODEL Description Registers a sub-components Processes or dispatches: end of input processing.

in other words. this is the SAP name space. Description . This method returns the name space of the corresponding BSP application as defined in the development environment (transaction SE80). This method returns the name of the BSP application as defined in the development environment (transaction SE80). the method returns "sap".- Specializing Interfaces - Attributes - Methods Method get_application_name Signature method get_application_name returning name type string . For BSP applications that have no explicit name space specified. - Description Parameters Return Values/Exceptions NAME Name of the BSP application Method get_application_namespace Signature method get_application_namespace returning namespace type string .

Parameters - Description Return Values/Exceptions START_PAGE Start page of the BSP application Method get_application_theme Signature method get_application_theme returning theme type string . the method returns the name default. This method returns the start page of the corresponding BSP application as defined in the development environment (transaction SE80). The start page of a BSP application is called if no specific page is included in the URL when the application is started.htm. If there is no theme explicitly associated with the Description . If no page was explicitly specified. when the URL ends with the application name. This method returns the name of the theme of the BSP application as defined in the development environment (transaction SE80). in other words.Parameters - Return Values/Exceptions NAMESPACE Name space of the BSP application Method get_application_start_page Signature method get_application_start_page returning start_page type string .

BSP application, the method returns an empty string (default theme). Themes can be used together with BSP applications to customize the look and feel, see also Layout Adjustments to BSP Applications. Parameters -

Return Values/Exceptions

THEME

Name of the theme associated with the BSP application

Method get_application_url
Signature method get_application_url returning url type string . This method returns a server-specific URL that references the current BSP application, for example /sap/bc/bsp/sap/retailstore. -

Description

Parameters

Return Values/Exceptions

URL

Server-specific URL of current BSP application

Method get_request
Signature method get_request returning request type ref to if_http_request . This method returns an interface reference to the current HTTP request object. -

Description Parameters

Return Values/Exceptions

REQUEST

Interface reference to the HTTP request object

Method get_response
Signature method get_response returning request type ref to if_http_response . This method returns an interface reference to the current HTTP response object. -

Description Parameters

Return Values/Exceptions

RESPONSE

Interface reference to the HTTP response object

Method get_runtime
Signature method get_runtime returning runtime type ref to if_bsp_runtime . This method returns an interface reference to the current BSP runtime object. -

Description Parameters

Return Values/Exceptions

RUNTIME

Interface reference to the BSP Runtime Object

Method get_timeout
Signature method get_timeout returning timeout type t .

Description

This method returns the current timeout value (length of time). The timeout value is only important for stateful BSP applications. Stateful applications use this value to determine after what length of time the server should terminate a running application when no further requests are received.

You can set timeout values in Transaction SICF for BSP applications, see also Creating an ICF Service. Parameters -

Return Values/Exceptions

TIMEOUT

Maximum length of time which a BSP application may continue to run in the absence of requests. After this time the application is automatically terminated.

Cross References

set_timeout

Method is_stateful
Signature method is_stateful returning stateful type i . You can use this method to determine whether a BSP application is working stateful or stateless. -

Description

Parameters

Return Values/Exceptions

STATEFUL

0: Application is stateless 1: Application is

stateful. Cross References See also: set_stateful, set_stateless

Method set_stateful
Signature Description Parameters Method set_stateful This method sets the BSP application to stateful processing. -

Return Values/Exceptions

STATEFUL

0: Application is stateless 1: Application is stateful.

Cross References

See also: is_stateful, set_stateless

Method set_stateless
Signature Description Parameters method set_stateless. This method sets the BSP application to stateless processing. -

Return Values/Exceptions

STATEFUL

0: Application is stateless 1: Application is stateful.

Cross References

See also: is_stateful, set_stateful

Method set_timeout

Signature

method set_timeout importing timeout type t . This method sets the current timeout value (length of time) of the BSP application. The timeout value is only important for stateful BSP applications. Stateful applications use this value to determine after what length of time the server should terminate a running application when no further requests are received.

Description

You can set timeout values in Transaction SICF for BSP applications, see also Creating an ICF Service. Parameters TIMEOUT Maximum length of time which a BSP application may continue to run in the absence of requests. After this time the application is automatically terminated.

Return Values/Exceptions Cross References

See also: get_timeout

Interface IF_BSP_APPLICATION_EVENTS
Overview
The interface IF_BSP_APPLICATION_EVENTS can be implemented by a BSP Application Class if it wants to have control over executing its own functions at specific points in the lifecycle of a BSP application. The possible time points for doing so are at application start and end, and at HTTP Request Input and HTTP Response Output. Typically, these time points are used to carry out authorization checks, data persisting, or data restoration in stateless BSP applications.

Inheritance Hierarchy/Interface Composition

This method is called by the BSP runtime environment when the corresponding BSP application is first started at the start of the BSP session. Parameters RUNTIME REQUEST RESPONSE Reference to the BSP runtime Reference to the current HTTP Request Reference to the current HTTP Response Description Return Values/Exceptions - Method on_stop Signature method on_stop . this time point is used to carry out authorization checks that apply to the entire application. This applies to both stateless and stateful applications. Typically.Enhanced Interface - Specializing Interfaces - Attributes - Methods Method on_start Signature method on_start importing runtime type ref to if_bsp_runtime request type ref to if_http_request response type ref to if_http_response . or for preliminary data retrieval (in stateful applications).

Consequently. This method is called by the BSP runtime Description . Please note that this time point is not available after every request in stateless BSP applications.importing runtime type ref to if_bsp_runtime request type ref to if_http_request response type ref to if_http_response . this is a good time for cleanup operations such as deleting browser cookies or server-side cookies. in this method it is only possible to execute optional operations that are not critical. the time point is not evaluated if the session is implicitly terminated by a timeout. Typically. if the application generated them. Description This method is called by the BSP runtime environment when the corresponding BSP application is explicitly ended. Parameters RUNTIME REQUEST RESPONSE Reference to the BSP runtime Reference to the current HTTP Request Reference to the current HTTP Response Return Values/Exceptions - Method on_request Signature method on_request importing runtime type ref to if_bsp_runtime request type ref to if_http_request response type ref to if_http_response . Moreover. This applies to both stateless and stateful applications.

This method is called by the BSP runtime for every outgoing response of a BSP after the BSP has been processed (after the OnManipulationevent handler).or server-side cookies in a previous request. for example. Parameters RUNTIME REQUEST RESPONSE Reference to the BSP runtime Reference to the current HTTP Request Reference to the current HTTP Response Return Values/Exceptions - Method on_response Signature method get_parameter importing name type string returning value type string . This time can be used by a stateless application class for tasks such as rescuing attributes in client-side or server-side cookies. This time can be used by the application class. Parameters RUNTIME REQUEST RESPONSE Reference to the BSP runtime Reference to the current HTTP Request Reference to the current HTTP Response Description Return Values/Exceptions - .environment for every incoming request to a BSP before the BSP is given control (in the OnRequest event handler). to restore attributes that were rescued in client.

in <form> or <a>HTML elements with <%= page->page_name( ) %>) and a page change is triggered (per HTTP Redirect) by means of the navigation object (see also Object navigation) that corresponds to the event. This is the preferred method in BSP applications. you can use the mechanism "AutoSubmit-Forms" as an alternative (see IF_BSP_NAVIGATION~USE_AUTO_SUBMIT_FORM() ). we recommend that you do not use this mechanism as a general rule since it causes problems with the browser history and it is not available for all devices (for example. In the BSP layout. the subsequent page is addressed directly in the relevant HTML 2. However. In the layout of a BSP only the page itself is referenced (for example. WAP). but rather where possible selection IDs that lead to the data concerned. elements such as <form> or <a>. If this is not possible in every case. Page control via the navigation interface requires in some cases transfer of arguments to the auto page attributes of the subsequent page. Please note that the amount of data to be transferred is restricted by Web Browser limitations (typically to 1KB). You should not try to transfer large amounts of data. There are two possible options for navigating between BSPs: 1. The relevant interface reference is available in all event handlers of a BSP via the parameter NAVIGATION.Interface IF_BSP_NAVIGATION Overview The interface IF_BSP_NAVIGATION controls the transition between BSPs in a BSP application. This lifts the data volume restriction. There are methods available for this purpose in the navigation interface. Inheritance Hierarchy/Interface Composition Implementing Classes CL_BSP_NAVIGATION Enhanced Interface .

The calling application must be implemented accordingly and 2. For ITSbased applications. Description . Since we cannot assume that all external applications have the same prerequisites for transferring the return address. The application is accessed via the HTTP Redirect mechanism. The default name is sap-exiturl.- Specializing Interfaces - Attributes - Methods Method call_application Signature method call_application importing url type string return_url_parameter type string default 'sap-exiturl' return_event_id type string optional . whereby BSP applications are able to call each other easily. You must specify the external application in the parameter URL. The required return address must be specified. the address ~exitURL should be used. You can use this method to call an external application. you have the option of selecting this in the parameter return_url_parameter as required. There are two prerequisites for returning to the calling application from the external application: 1. The parameter return_event_id lets you select an additional event ID that should be triggered on return as the event ID in the onInputProcessing event handler of this BSP. The current page from which the external application was accessed is taken as the return URL.

that is. BASE64-coded as a value of the URL parameter sap-params. or coded.Actual navigation is not triggered at this point. Parameters are passed in coded form by default. This method controls whether the parameters defined using set_parameter() should be passed uncoded in plaintext as name/value pairs in the query string of the URL. It is triggered on return from the BSP event handler! Parameters URL RETURN_EVENT_ID URL of external application Name of the parameter used to transfer the return address/URL to the calling application Event ID used to address the onInputProcessing event handler of the calling page on return from the calling application RETURN_URL_PARAMETER Return Values/Exceptions - Method encode_parameters Signature method encode_parameters importing encoded type i value 1 . not encrypted Parameters ENCODED 0: Parameter is passed in plaintext as name/value pairs 1: Parameter is BASE64-coded . Description Note that we are talking of coded form here.

This method terminates this BSP application regardless of whether the application is working stateful or stateless. You can use the optional parameter exit_url to branch to any end page or URL per HTTP Redirect. In particular. It is triggered on return from the BSP event handler! Parameters EXIT_URL URL to which a HTTP Redirect should branch as the "end page". This method returns the value of the requested parameter from the navigation object.Return Values/Exceptions - Method exit Signature method exit importing exit_url type string optional . Description Actual navigation is not triggered at this point. Return Values/Exceptions - Method get_parameter Signature method get_parameter importing name type string returning value type string . Description . the event handler if_bsp_application_events~on_stop is triggered if the interface IF_BSP_APPLICATION_EVENTS is implemented by the application class.

It is triggered on return from the BSP event handler! Parameters URL URL of the subsequent page. this is a relative URL and contains only the name of the subsequent page. Unlike the method next_page(). Description Actual navigation is not triggered at this point.Unlike set_parameter(). In most cases. this method always returns the value as a string. This method handles navigation to the specified URL. here the subsequent page is specified directly. for example navigation>goto_page( 'confirm. Parameters NAME VALUE Return Values/Exceptions Cross Reference set_parameter Parameter name Parameter value Method goto_page Signature method goto_page importing url type string .htm' ). typically a relative URL or only the page name Return Values/Exceptions Cross Reference next_page Method has_parameters .

Signature method has_parameters returning has_parameters type i . When you do so. for navigating between pages. a "link" identified by a unique name). you assign a target page via a page exit (that is. an indirection is inserted instead. the subsequent page is not directly defined in ABAP code. starting from the current page. It is triggered on return from the BSP event handler! Parameters EXIT Name of page exit in the navigation graph (case-insensitive) . Description Actual navigation is not triggered at this point. This method defines the subsequent page by specifying a page exit. HAS_PARAMETERS 0: No parameters set 1: Parameters set Description Parameters Return Values/Exceptions Cross Reference set_parameter Method next_page Signature method goto_page importing url type string . This can be changed easily without having to adapt all of its usages in the code. The name of the page exit is used to determine the subsequent page currently assigned to the page exit. 1: yes). Then. You can define page exits of a navigation graph in the development environment (transaction SE80) of a BSP application. This method indicates whether parameters have been set for the current navigation object (0: no.

This method sets the specified parameter for the transfer to the subsequent page. the HTTP Response has already been completely generated and can be sent back to the client/browser. include unwanted output in the response (for example. Otherwise. As a rule. it can be read on the subsequent page using Request Object and the method Description . MIME Object from the database or generated XML Output) and was written directly to the HTTP Response object. blanks that are of critical importance in binary document). Parameters Return Values/Exceptions - Method set_parameter Signature method set_parameter importing name type string value type any optional . This method is typically called in the OnRequest or OnInitialization section of a BSP. when the HTTP Response was generated differently from the OnLayout section (for example. On the contrary. Calling the OnLayout section would. The call can be suppressed here. the name of the parameter is the same as an auto page attribute of the subsequent page. in such cases.Return Values/Exceptions Cross Reference goto_page Method response_complete Signature Description Method response_complete You can use this method to indicate to the BSP runtime that no further event handlers/sections should be addressed on return from the BSP event handler in which it was called.

when navigating to a subsequent page. the value of the parameter can be omitted. Return Values/Exceptions Cross Reference get_parameter. no HTTP redirects can be used. Using this method. has_parameters Method use_auto_submit_form Signature method use_auto_submit_form importing target_frame type string optional . that auto submit forms can cause problems in the browser history and that this mechanism canot be used with WAP devices. for example. and the form is automatically returned to the subsequent page (auto submit) after it is received in the browser. In certain circumstances. This would be the case if a form field of the same name was sent in the current request to be passed on to the subsequent page. With this method.if_http_request~get_form_field(). Description . you can circumnavigate the dataset restrictions with query string parameters. The parameter value is then simply taken over from the current request and passed to the subsequent page. the parameter VALUE can only be untyped. Since it is possible to transfer any ABAP data types with the exception of references. The parameters to be transferred are mixed into the form as hidden fields. Note however. the value of the form field of the same name of the HTTP Request is taken. Parameters NAME VALUE Parameter name Parameter value. If the parameter is not specified. but insread an HTML page is used with an embedded form.

the methods and attributes of this interface are indirectly available by inheritance in all BSPs and can be accessed with the appropriate qualification via the interface name (for example "name = if_bsp_page~get_page_name( ). Return Values/Exceptions cx_bsp_inv_param_type Interface IF_BSP_PAGE Overview The interface IF_BSP_PAGE gives access to information about a BSP such as the page names. Consequently. and so on. In particular. which is the base class of all BSPs. the URL of the page. IF_BSP_PAGE is implemented using the class CL_BSP_PAGE. the corresponding BSP application. Inheritance Hierarchy/Interface Composition Implementing Classes CL_BSP_PAGE Enhanced Interface - Specialized Interfaces - . The interface can also be addressed in all BSP event handlers by means of the parameter page and can be extended to lower application levels if required. the BSP page attributes can be read and set using the methods get_attribute() and set_attribute().You can use parameter target_frame to control in which HTML frame (or new browser window) the subsequent page should be displayed."). the lifetime. Parameters target_frame Name of frame in which subsequent page is to be displayed. Exception: the parameter type is not allowed.

or to_string()-method: Output as currency write(). This method returns the application object for this BSP.or to_string()-method: standard formatting write(). a zero (0) reference is returned. - Description Parameters Return Values/Exceptions Cross References application Name of the BSP application Application Class of a BSP Application .or to_string()-method: short output write().Attributes Attribute Name co_format_currency co_format_long co_format_lower co_format_none co_format_short co_format_upper lifetime_page lifetime_request lifetime_session messages Declaration Type Constants Constants Constants Constants Constants Constants Constants Constants Constants Instance attribute Description write().or to_string()-method: long output write().or to_string()-method: output in upper-case letters Page is valid until explicit navigation away from this page Page is only valid for this HTTP Request Page is valid for the complete session (only for stateful BSP applications) Reference to the messages-object of this BSP Methods Method get_application Signature method get_application returning application type ref to object .or to_string()-method: output in lower-case letters write(). If no application class was defined for the BSP application of this page.

If there is no theme explicitly associated with the BSP application. - Description Parameters Return Values/Exceptions Cross References name - Name of the BSP application Method get_application_start_page Signature method get_application_start_page returning start_page type string . the method returns an empty string (default theme). This method returns the name of the BSP application of this page as defined in the development environment (transaction SE80). If no page was explicitly specified.Method get_application_name Signature method get_application_name returning name type string . This method returns the start page of the corresponding BSP application as defined in the development environment (transaction SE80).htm. This method returns the name of the theme of the BSP application as defined in the development environment (transaction SE80). The start page of a BSP application is called if no specific page is included in the URL when the application is started. Themes can be implemented in connection with BSP applications for Look & Feel customizing. when the URL ends with the application name. - Description Parameters Return Values/Exceptions Cross References start_page - Start page of the BSP application Method get_application_theme Signature method get_application_theme returning theme type string . in other words. Description . the method returns the name default.

This method returns the value of the requested attribute.Parameters Return Values/Exceptions Cross References - theme Name of the theme associated with the BSP application Tailoring Layouts to BSP Applications Method get_application_url Signature method get_application_url returning url type string . This method returns a server-specific URL that references the current BSP application. the return value can only be untyped and must be integrated type-related when called. for example /sap/bc/bsp/sap/retailstore. - Description Parameters Return Values/Exceptions Cross References url - Server-specific URL of current BSP application Method get_attribute Signature method get_attribute importing name type string exporting value type any . The ABAP restrictions regarding type conversion apply so that exceptions may occur in the event of incompatible type assignments. Since attributes can be of any type. Description Parameters Return Values/Exceptions Cross References name value Name of attribute (case-insensitive) Attribute value Exception: Attribute does not exist cx_bsp_inv_attr_name set_attribute() . ABAP move logic plays a role in the assignment of the attribute value to the return value to enable the type conversion to take place.

This method returns the server-specific URL for this BSP.-constants of the IF_BSP_PAGEINTERFACE). - Description Parameters Return Values/Exceptions Cross References name - Name of the BSP Method get_page_url Signature method get_page_url returning url type string . - Description Parameters Return Values/Exceptions Cross References url - Server-specific URL of the BSP ..Method get_lifetime Signature method get_lifetime returning lifetime type i .constants of the IF_BSP_PAGE): lifetime_page | lifetime_request | lifetime_session Cross References set_lifetime.. lifetime_request. This method returns the current settings of the lifetime of this BSP page (see lifetime_.. lifetime_session Method get_page_name Signature method get_page_name returning name type string . This method has no effect on stateless applications and always returns the value lifetime_request. Description Parameters Return Values/Exceptions - lifetime Current lifetime of the BSP (see lifetime. lifetime_page. This method returns the name of this BSP.

This method returns an interface reference to the current HTTP Response Object. This method returns an interface reference to the current HTTP Request Object.Method get_request Signature method get_request returning request type ref to if_http_request . This method returns an interface reference to the current BSP Runtime Object. - Description Parameters Return Values/Exceptions Cross References response Interface reference to the HTTP Response Object IF_HTTP_SERVER IF_HTTP_RESPONSE and IF_HTTP_REQUEST Method get_runtime Signature method get_runtime returning runtime type ref to if_bsp_runtime . - Description Parameters Return Values/Exceptions Cross References request Interface reference to the HTTP Request Object IF_HTTP_SERVER IF_HTTP_RESPONSE and IF_HTTP_REQUEST Method get_response Signature method get_response returning response type ref to if_http_response . - Description Parameters Return Values/Exceptions Cross References runtime - Interface reference to the BSP Runtime Object .

This method does not let you define new attributes dynamically at runtime. This method is typically only called in the OnManipulation section of the BSP when the generated output needs to be postprocessed. This method serializes the content of this page (after processing in the layout event handler) in a string. The ABAP restrictions regarding type conversion apply so that exceptions may occur in the event of incompatible type assignments. This can be done with the method if_http_response~set_cdata() and the HTTP Response Object. IF_HTTP_SERVER IF_HTTP_RESPONSE and IF_HTTP_REQUEST Method set_attribute Signature method set_attribute importing name type string value type any . On the contrary. The output of a BSP is no longer automatically returned to the client in the HTTP Response when this method is called explicitly. Description . the return value can only be untyped and must be integrated type-related when called. only attributes that were defined in the development environment (SE80) statically for the BSP page can have values assigned. the method will terminate with the exception cx_bsp_inv_attr_name. Instead. Otherwise.Method serialize Signature method serialize returning data type string . Description Parameters Return Values/Exceptions Cross References - data: Serialized response of the BSP after the layout section is processed. This method sets the value of the specified attribute. the developer is responsible for sending it. However. ABAP move logic plays a role in the assignment of a value to the attribute to enable the type conversion to take place. Since attributes can be of any type. for performance reasons this is not recommended unless absolutely necessary.

Description Parameters value Value to be formatted . The string generated can be easily integrated in the output in a BSP using the output directive <%= .-constants of the IF_BSP_PAGE). This method has no effect on stateless applications. Description Parameters lifetime New lifetime of the BSP (see lifetime. lifetime_request. There are several optional parameters available to let you control the formatting. lifetime_page.constants of the IF_BSP_PAGE): lifetime_page | lifetime_request | lifetime_session Return Values/Exceptions Cross References get_lifetime.. This method returns the current lifetime of this BSP page (see lifetime_.. This method formats as a string the value of a scalar ABAP variable with any type. lifetime_session Method to_string Signature method to_string importing value type any format type i optional outputlength type i optional num_decimals type i optional reference_value type c returning string type string . %>..Parameters name value Name of attribute (case-insensitive) Value of attribute (appropriately typed) Exception: Attribute does not exist Return Values/Exceptions Cross References cx_bsp_inv_attr_name get_attribute() Method set_lifetime Signature method set_lifetime importing lifetime type i ..

Description Parameters value format Value to be formatted Output format (see if_bsp_page~co_format_. in script directives <% . Output is at the current “write position” in the BSP.constants) Maximum output length (in characters) Number of decimal places Reference value (for example. %>.. There are several optional parameters available to let you control the formatting. the currency) outputlength num_decimals reference_value Return Values/Exceptions Cross References to_string . the currency) Formatted output string outputlength num_decimals reference_value Return Values/Exceptions Cross References output write() Method write Signature method write importing value type any format type i optional outputlength type i optional num_decimals type i optional reference_value type c . This method outputs as a string the value of a scalar ABAP variable with any type.constants) Maximum output length (in characters) Number of decimal places Reference value (for example... This method can be used for output in a BSP for example.format Output format (see if_bsp_page~co_format_.

Accessibility is integrated in the BSP runtime. It gives you access to the most important objects and information in the form of attributes. Inheritance Hierarchy/Interface Composition Implementing Class CL_BSP_RUNTIME Attributes Attribute Name application_name application_namespace application_theme application_url ddic_utils keep_context Declaration Type Instance attribute Instance attribute Instance attribute Instance attribute Static attribute Static attribute Description Name of the BSP application Name space of the BSP application Theme of the BSP application URL prefix of the BSP application Dictionary services Stateful/stateless BSP application . This method returns the language-dependent text for an OTR alias (short text) This method is available from SAP Web AS 6.Method otr_trim Signature method otr_trim importing alias returning text . alias Description Parameters Return Values/Exceptions Cross References Name of the defined OTR alias Text in current language text Internationalization and Translation Interface IF_BSP_RUNTIME Overview The interface IF_BSP_RUNTIME gives you access to information contained in the current runtime environment of a BSP application.20 Support Package 7.

that is. The backend is therefore completely independent. The value of this attribute does not change: 1 1 If you set keep_context from 0 to 1 and session_id Static attribute 1 1 If you already have a browser open and you open a new one (using File → New → Window. the value of this attribute is set independently of the context at the server. for example) .(0/1) page_name page_url runtime_url server session_manager client_info Instance attribute Instance attribute Static attribute Static attribute Static attribute Static attribute Name of the BSP URL prefix of the BSP URL prefix of the BSP runtime HTTP Server Workplace Session Manager Device properties for the current request BSP Session ID This attribute uniquely labels the user session.

You are recommended not to call it unnecessarily often. At runtime. application_url or page_url as an Description .or HTTPS URL should be generated. This method can be expensive at runtime. This method builds a server-specific.The value of this parameter does change if you close the browser and open a new one. instead of using this static method. absolute URL for a BSP application or BSP. You can use the parameter in_protocol to control whether a HTTP. you can use the instance attribute runtime_url. Methods Method construct_bsp_url Signature class-method construct_bsp_url importing in_protocol type string default 'http' in_host type string optional in_port type string optional in_application_ns type string optional in_application type string in_page type string optional in_parameters type tihttpnvp optional in_suppress_rewrite type I default 0 exporting out_protocol type string out_host type string out_port type string out_local_url type string out_abs_url type string .

including protocol. which can differ from in_protocol if not supported by the server Domain name of the application server Port number for protocol on the application server URL relative to current application server Absolute URL. Parameters in_protocol in_host in_port in_application_ns in_application in_page in_parameters Requested protocol (HTTP or HTTPS) Requested host Requested port number Namespace of the BSP application (if not 'sap') Name of the BSP application Name of the BSP Table with name/value pairs that are to be integrated in the URL as query-string parameters 0: Allow URL rewriting of the BSP runtime 1: Suppress URL rewriting of the BSP runtime Actual protocol (HTTP or HTTPS). that is. port number etc. application server name. in_suppress_rewrite Return Values/Exceptions out_protocol out_host out_port out_local_url out_abs_url Method get_otr_text Signature method get_otr_text importing .alternative.

Description alias type string returning text type string . This method returns the OTR text in the current language (sy-langu) for the alias specified. an empty string is returned. If there is no text for the alias in the current language. Note that this does not make any statement about the accessibility of the application itself. alias OTR alias including name space (caseinsensitive) OTR text for alias in the current language or empty string if no alias exists Parameters Return Values/Exceptions text Method with_accessibility Signature method with_accessibility returning access type boolean . You determine the accessibility using this method. the secondary (or fallback) language is used. access This return value states whether accessibility is active or not. Description Parameters Return Values/Exceptions Interface IF_BSP_PAGE_CONTEXT . If there is no such alias.

Method GET_REQUEST This method returns the request object.Overview Interface IF_BSP_PAGE_CONTEXT forms a wrapper around a BSP and is based on the Page Context Object. Inheritance Hierarchy/Interface Composition Implementing Classes Enhanced Interface Specializing Interfaces - Attributes - Methods Method GET_OUT This method outputs the current. active writer to the stack. Method GET_PAGE This method returns the page object. Method GET_NAVIGATION This method returns the navigation object. Method GET_RESPONSE This method returns the response object. Method GET_RUNTIME This method returns the runtime object. .

Process Flow The interface IF_HTMLB_ITERTATORcontains 3 callback methods. As <htmlb:tableView> does not contain application logic itself. When processing its BSP (in which its own iterator object is embedded) with <htmlb:tableView iterator="<%= my_iterator %>" . the iterator allows the TableView to handle data very flexibly. />. .. Iterator: Interface IF_HTMLB_TABLEVIEW_ITERATOR Overview Definition The iterator is an instance object that implements the interface IF_TABLEVIEW_ITERATOR. With the iterator.. for example for the evaluation of a TableView row and calculation of the value of another row.Method POP_WRITER This method takes the first writer off the stack and returns it. or – when controllers are used – by the controller class. row or column. The interface should be implemented by the corresponding application class of the BSP application. you can create complex logic for <htmlb:tableView> elements. but that there is a communication with the application after each field or column which enables the application to influence the rendering of a certain field. Method ELEMENT_PROCESS You can use this method to process other BSP elements dynamically. Method PUSH_WRITER This method sets a new writer on the stack and returns it as a response. You can use this when you create Composite Elements for example. the iterator calls back the three interface methods every time it encounters an <htmlb:tableView/> element or an <htmlb:tableViewColumns/> element. This iterator interface makes it possible that a <htmlb:tableView> BSP element is not rendered in one step.

Use 1.. i. data: col_value type string. p_replacement_bee = html_bee.add() can have up to 10 params for concatenation html_bee->add( html = html_str ). 2. In transaction SE24. /> element. Note that you execute the instantiation via the application class or the controller class.. * p_column_key has a name of each table column if p_column_key = 'COLUMN_NAME'.e.. data: html_str type string. endmethod. * do something interesting html_str = "<HTML_code_you_want_to_generate_dynamically />" endif. <col> type any. * html_bee object is responsible to modify HTML code data: html_bee type ref to cl_bsp_bee_html. . Embed your iterator instance in the <htmlb:tableView iterator=< %= my_iterator %> . 3. 2. 4. 1. Instantiate your iterator class. * set HTML code you want. you can create your own class that implements the interface IF_HTMLB_TABLEVIEW_ITERATOR.. Minimal example coding for the implementation of the method render_cell_start: method if_htmlb_tableview_iterator~render_cell_start. called back. create object html_bee. if col_value = 'CONDITION_YOU_WANT'. You can implement them according to your needs. * <row> is a structure of table field-symbols: <row> type any.. assign component p_column_key of structure <row> to <col>.. 1. 3. The three methods of IF_HTMLB_TABLEVIEW_ITERATOR are called. col_value = <col>.. endif. 4. See also: How do I get a blank line using the iterator? Inheritance Hierarchy/Interface Composition Implementing Classes - . * conventional logic to extract column value assign p_row_data_ref->* to <row>.

Overwrite this methode. This methode contains important import parameters which provide information about the current TableView. The row definitions of the TableViews are handed over. the application can exert influence.Enhanced Interface - Specialized Interfaces - Attributes - Methods Method get_column_definitions Signature Description This method is called at the start of the rendering of the TableViews. Parameters P_TABLEVIEW_ID Import parameter for the ID parameter for columns in the TableView Changing parameter to overwrite certain cells in the TableView P_COLUMN_DEFINITIONS Changing P_OVERWRITES Return values / Exceptions Method render_row_start Signature - . if you plan to make changes here. At this moment.

Paramet ers P_TABLEVIEW_ID P_CELL_ID P_CELL_BINDING P_ROW_INDEX P_ROW_KEY P_COLUMN_INDE X Import parameter for the ID Import parameter for the cell ID Importparameter for the binding name Import parameter for the row index Import parameter for the row key Import parameter for the column index . the <htmlb:tableView> element calls this application-specific renderer for this row.Description RENDER_ROW_START is called at the beginning of every row. as well as a reference to the current row. you can define a custom rendering for a certain row as is shown in: Custom-Rendering for the Author column.. Use this method if you want to influence the rendering at the beginning of every row. use the parameter p_replacement_bee. You can give the rendering information exactly to the rows that are rendered. You use this method to render columns dynamically. Parameters P_TABLEVIEW_ID P_ROW_INDEX P_ROW_KEY Import parameter for the ID Import parameter for the row index Import parameter for the row key the reference to the data of a row P_ROW_DATA_REF Import parameter for P_EDIT_MODE Return values / Exceptions Import parameter for a checkbox checkbox P_SKIP_ROW Method render_cell_start Signatur e Descripti on RENDER_CELL_START is called at the beginning of every column (cell). This methode contains important import parameters which provide useful information about the current row. Thus. This is especially convenient for tables that do not put out all rows.e. you obtain the row and column index. before the rendering of every single table field. i. To define a new rendering engine. Then. You can filter rows or insert additional information to the rendering. Via the import parameters.

P_COLUMN_KEY P_ROW_DATA_RE F P_EDIT_MODE P_REPLACEMENT _BEE Import parameter for the column key Import parameter for the reference to the data of a row Import parameter for a checkbox Export parameter for a BSP extension expression (BEE) .

row 50: if design eq '2002'. STCD_BADVALUE_DARK. STCD_ALTERNATING. STCD_GOODVALUE_LIGHT. You can find an example for the use of cellDesign in the BSP application sbspext_table. STCD_GROUP_HIGHLIGHTED. STCD_BADVALUE_LIGHT. When using Design2003. Note. If you want to change the background color there. P_STYLE="cellDesign:STCD_STANDARD"). STCD_GROUP_LEVEL2. STCD_CRITICALVALUE_DARK. STCD_SUBTOTAL. STCD_TRANSPARENT. Possible values of cellDesign are STCD_STANDARD. STCD_GROUP_LEVEL3. STCD_POSITIVE. that the specification of cellDesign does not have any effect in Design2002. STCD_KEY_MEDIUM. method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_C ELL_START. On the other hand. STCD_BADVALUE_MEDIUM. p_style = 'background-color:#BBDDDD'. STCD_MARKED. p_style = 'celldesign:GROUP_HIGHLIGHTED_LIGHT'. endif. page TableViewIterator. STCD_GOODVALUE_MEDIUM. STCD_CRITICALVALUE_MEDIUM.. elseif design eq '2003'. STCD_NEGATIVE. STCD_TOTAL. STCD_GROUP_HIGHLIGHTED_LIGHT.. you have to do this via CSS attributes. STCD_CRITICALVALUE_LIGHT. iterator class CL_SBSPEXT_ITERATOR.g. use the attribute cellDesign in P_STYLE (e.P_STYLE Changing parameter for <td style=". To do this. STCD_FILTER and STCD_POPIN.bsp. you can change the background color of a cell with predefined colors via P_STYLE (P_CLASS is no longer analyzed in Design2003).">. . STCD_GROUP_LEVEL1. except via cellDesign itself. STCD_SUBTOTAL_LIGHT. it is no longer possible to set specifications in Design2003 style for the cell. STCD_GOODVALUE_DARK.

P_ISREADONLY Return values / Exceptio ns - Changing parameter for <td readonly>. For those device properties not assigned a priority. In general. you can use the methods of the IF_CLIENT_INFO interface when you create Web applications like BSP application. some of them have been assigned a priority. Note. and thus take the – often substantial – differences in the display of Web pages on different devices into account. Device properties can be categorized by their significance as follows: Prio. along with other device-specific properties – such as screen size or input method.">.. At most.P_CLASS Changing parameter for <td class=". these conditions are fulfilled by all "real" devices that fulfil the HTML or WAP standard. You can also use this Device Recognition Process and the comparable ClientInfo Interface when developing Java applications. do not fulfil these prerequisites. Example You find an example in the BSP tutorial: Our Little Online Bookshop using MVC and HTMLB and Custom-Rendering for the Author column.. IF_CLIENT_INFO Interface Definition The IF_CLIENT_INFO interface provides a range of methods that take into account the different display options for Web applications on different browsers. that P_CLASS is no longer anaylzed in Design2003. So that you can estimate the significance for your Web application of the methods described in the following table. Thus this property need not be checked in the application. 1 Title Prerequisite Description This property is prerequisite for running the mobile application at all. you need a check program that ascertains whether or not an emulator is suitable for executing the application . you can decide yourself whether or not you want to use them in your Web application. Emulators. Use In this way. however.

some properties are assigned to the markup languages WML (Wireless Markup Language) and HTML (Hypertext Markup Language) – that is. it is HTML browsers on handheld devices like PDAs and pocket PCs. the application may not show all its information For example. the display should not actually disturb the user significantly. it is possible that the end of the text is simply truncated. may not be executable If this property is not assigned a value. the application may crash on some devices – that is. If the 3 mobile device does not support the GET_MARQUEE_TEXT_SUPPORTED property. 4 Unacceptable display If this property is not assigned a value. the method GET_FRAMES_SUPPORTED is only significant in HTML.. For example. because of their screen interfaces. However. the application may not be displayed at its best. WAP-enabled mobile telephones with small screens cannot display frames. . since only HTML-enabled browsers can interpret frames.. . 5 Inappropriate display Similarly. the method can be used in both markup languages. If the appropriate table column does not contain a value. the application may be displayed in a way that does not do justice to the look and feel of the device If this property is not assigned a value. data client_info type ref to IF_CLIENT_INFO. to make better use of a small screen on a mobile telephone. you specify the markup language for which each method is relevant and thus how it can meaningfully be used. client_info = runtime->client_info.. The following source code fragment shows how you can access the methods of the IF_CLIENT_INFO interface: <%@page language="abap"%> <% .2 Application does not work Loss of information If this property is not assigned a value. In general.. if client_info->get_title_supported( ) = ‘X’. use the links in the table. Possible values Content type Prio. a loss of information may occur if the paragraph attribute for automatic line breaks is switched off (<p mode=nowrap>) and the paragraph (in a WML page) contains text that does not fit on one line. %> To obtain more information on using some of the methods of the IF_CLIENT_INFO interface in your Web application. Methods Method GET_ACCEPT Signature method get_accept returning value type string Description Equivalent to the HTTP request-header "userAgent". for example. For this reason we advise you to think carefully before switching off the automatic line break property – even if doing so would allow you.

GET_ALERTING_SUPPORTED method get_alerting_supported returning value type flag method get_anchor_supported returning value type flag method get_anchor_prev_support ed returning value type flag method get_app_links_supported returning value type flag method get_app_link_types returning value type string method get_back_hard_wired returning value type flag Specifies whether or not the device supports messaging – for example. Specifies whether or not the <anchor> tag is supported "X" or space 1 GET_ANCHOR_SUPPORTED "X" or space WML 1 GET_ANCHOR_PREV_SUPPORTE D Specifies whether or not the anchor tag supports a "Back" action "X" or space WML GET_APP_LINKS_SUPPORTED Specifies whether or not you can call a local application on a device using a special link Specifies what type of application links the device supports "X" or space HTML 3 GET_APP_LINK_TYPES HTML GET_BACK_HARD_WIRED Specifies whether or not you can execute the "Back" function using a fixed key without an associated tag Specifies whether or not a label attribute must be specified in the <do type=prev> tag to display a label Specifies whether the <do type="prev"> tag can lead to any Web address "X" or space WML 4 GET_BACK_LABEL method get_back_label returning value type flag "X" or space WML 3 GET_BACK_TO_ANY_URL_SUPPO RTED method get_back_to_any_url_sup ported returning value type flag method get_big_supported returning value type flag method get_bold_supported returning value type flag method get_breaking_space returning value type string method get_browser_category returning value type string "X" or space WML 1 GET_BIG_SUPPORTED Specifies whether or not text can be formatted as "large" "X" or space WML GET_BOLD_SUPPORTED Specifies whether or not text can be formatted as "bold" "X" or space WML GET_BREAKING_SPACE Returns the smallest character string for an empty space GET_BROWSER_CATEGORY Returns the browser category „unknown" „pocketie" „avantgo" „imode" „palm" „wap" „epoc" . using SMS.

2 or 1. "X" or space HTML 4 . for example 5.2 for HTML 3. for example 256 colors HTML GET_COLOR_SUPPORTED Specifies whether or not the device has a color screen "X" or space HTML GET_CONTENT_TYPE Returns the content type.1 Specifies whether or not browser cookies are supported "X" or space 2 GET_CONTENT_TYPE_VERSION GET_COOKIES_SUPPORTED 1 GET_CSS_SUPPORTED Specifies whether or not the browser supports CSSs (Cascading Style Sheets).1 for WML 1.5 GET_CACHE_ENABLED_BY_DEFA ULT Specifies whether or not cache memory on the browser is activated by default "X" or space GET_CERTIFICATES_SUPPORTED Specifies whether or not the device supports client certificates "X" or space GET_CHAR_HEIGHT Returns the screen height in rows 4 GET_CHAR_WIDTH Returns the screen width in characters 4 GET_COLOR_DEPTH Returns the color depth. 3.GET_BROWSER_NAME method get_browser_name returning value type string Returns the browser name „unknown" „InternetExp lorer" „NetscapeN avigator" „mobile" „unknown" „HPUX" „Linux" „MacPPC" „SunOS" „Win32" „mobile" GET_BROWSER_NAME method get_browser_os returning value type string Returns the operating system running on the device GET_BROWSER_VERSION method get_browser_version returning value type int4 method get_cache_enabled_by_d efault returning value type flag method get_certificates_supported returning value type flag method get_char_height returning value type int4 method get_char_width returning value type int4 method get_color_depth returning value type float method get_color_supported returning value type flag method get_content_type returning value type string method get_content_type_version returning value type int2 method get_cookies_supported returning value type flag method get_css_supported returning value type flag Returns the browser version. for example HTML or WML Returns the version of the content type – for example.

GET_CSS_VERSION method get_css_version returning value type int4 method get_default_action_design returning value type string Returns the CSS version HTML GET_DEFAULT_ACTION_DESIGN Returns the default design for user interface elements representing an action „link" „button" „softkey" „linkAndSoft key" WML 3 GET_DEFAULT_BLOCK_SEPARAT OR method get_default_block_separat or returning value type string method get_default_bullet returning value type string method get_default_form_style returning value type string method get_default_menu_style returning value type string method get_device_category returning value type string Returns the default string used to separate paragraphs 5 GET_DEFAULT_BULLET Returns the default symbol used to indicate points in a list Returns the default display type for input masks „onePage" „menu" „wizard" WML 5 GET_DEFAULT_FORM_STYLE WML GET_DEFAULT_MENU_STYLE Returns the default display type for menus „selectionLis t" „linkList" WML 4 GET_DEVICE_CATEGORY Returns the device category „unknown" „Phone" „PDA" „Voice" „PC" GET_DEVICE_NAME method get_device_name returning value type string method get_dom_supported returning value type flag method get_dom_version returning value type int4 method get_emphasized_supporte d returning value type flag method get_emulator returning value type flag Returns the device name Unique ID for a set of device properties Specifies whether or not the browser supports a Document Object Model (DOM) Returns the Document Object Model (DOM) version supported Specifies whether or not text can be formatted as "highlighted" "X" or space "X" or space HTML GET_DOM_SUPPORTED GET_DOM_VERSION HTML GET_EMPHASIZED_SUPPORTED WML 5 GET_EMULATOR Specifies whether or not the device is to be categorized as an emulator Specifies how input fields that belong together are to be laid out using the <fieldset> tag "X" or space GET_FIELDSET_LAYOUT method get_fieldset_layout returning value type string „notSupport ed" „ignored" „beneath" „beneathWit hIndent" WML 3 .

„sideBySide " GET_FIELDSET_TITLE_VISIBLE method get_fieldset_title_visible returning value type boolean method get_font_proportional returning value type flag method get_form_factor returning value type string Specifies whether or not the title attribute of the <fieldset> tag is used as label. Specifies whether or not the default font of the device is a proportional font Returns the screen format of the device "X" or space WML 3 GET_FONT_PROPORTIONAL "X" or space GET_FORM_FACTOR „PC" „VGA" „halfVGA" „mediumLan dscape" „mediumPor trait" „phone" „unknown "X" or space WML 3 GET_FORM_MENU_SUPPORTED method get_form_menu_supporte d returning value type flag Specifies whether or not the browser supports the technique of displaying a selection menu with the input mask Specifies whether or not frames are supported 4 GET_FRAMES_SUPPORTED method get_frames_supported returning value type flag method get_gray_level returning value type float "X" or space HTML 2 GET_GRAY_LEVEL Returns the number of shades of gray supported in grayscale pictures Specifies whether or not the device has a horizontal scroll bar "X" or space GET_HORZ_SCROLLING_SUPPOR TED method get_horz_scrolling_suppor ted returning value type flag method get_href_with_params_su pported returning value type flag method get_http_get_supported returning value type flag method get_http_post_supported returning value type flag method get_image_alignment_sup ported returning value type flag "X" or space GET_HREF_WITH_PARAMS_SUPP ORTED Specifies whether or not an Href attribute in a link can contain URL parameters. right. "X" or space WML 2 GET_HTTP_GET_SUPPORTED Specifies whether or not the HTTP GET is supported "X" or space WML 1 GET_HTTP_POST_SUPPORTED Specifies whether or not the HTTP POST is supported "X" or space WML 1 GET_IMAGE_ALIGNMENT_SUPPO RTED Specifies whether or not a graphic can be aligned (left. or centered) "X" or space WML .

GET_IMAGE_LINKS_SUPPORTED method get_image_links_supporte d returning value type flag method get_image_size_max returning value type float method get_input_format_date returning value type string method get_input_format_numeric returning value type string method get_input_method_hand_ writing returning value type flag method get_input_method_keyboa rd returning value type flag method get_input_method_keypad returning value type flag method get_input_method_keypad _intell returning value type flag method get_input_method_voice returning value type flag method get_input_shown_with_ca ption returning value type flag method get_italic_supported returning value type flag method get_java_supported returning value type flag method get_java_version Specifies whether or not a graphic can be used as link. "X" or space 2 GET_IMAGE_SIZE_MAX Returns the maximum memory size of a graphic WML GET_INPUT_FORMAT_DATE Returns the character string used to format date values WML GET_INPUT_FORMAT_NUMERIC Returns the character string used to format numeric values WML GET_INPUT_METHOD_HAND_WRI TING Specifies whether or not the device supports handwritten input "X" or space GET_INPUT_METHOD_KEYBOARD Specifies whether or not the device supports input using a keyboard "X" or space GET_INPUT_METHOD_KEYPAD Specifies whether or not the device supports input using a telephone keypad Specifies whether or not the device supports input using T9 text input or similar "X" or space GET_INPUT_METHOD_KEYPAD_IN TELL "X" or space GET_INPUT_METHOD_VOICE Specifies whether or not the device supports speech input "X" or space GET_INPUT_SHOWN_WITH_CAPTI ON Specifies whether or not the browser uses the title attribute of the <input> tag is used as a label Specifies whether or not text can be formatted as "ítalic" "X" or space WML 3 GET_ITALIC_SUPPORTED "X" or space WML 5 GET_JAVA_SUPPORTED Specifies whether or not the device supports the Java programming language Returns the Java "X" or space HTML 1 GET_JAVA_VERSION HTML .

gif.agif (animated . Specifies whether or not the device supports locally stored graphics or symbols "X" or space WML GET_LINK_TEXT_WIDTH method get_link_text_width returning value type int2 method get_local_images_support ed returning value type flag method get_local_variables_supp orted returning value type flag method get_marquee_link_suppor ted returning value type flag method get_marquee_text_suppor ted returning value type flag method get_max_link_length returning value type int4 method get_media_formats returning value type string WML 3 GET_LOCAL_IMAGES_SUPPORTE D 3 GET_LOCAL_VARIABLES_SUPPO RTED Specifies whether or not the browser supports local variables "X" or space WML 1 GET_MARQUEE_LINK_SUPPORTE D Specifies whether or not a long link can be displayed in one line. "X" or space WML 3 GET_MARQUEE_TEXT_SUPPORT ED "X" or space WML 3 GET_MAX_LINK_LENGTH 1 GET_MEDIA_FORMATS Returns the list of multimedia formats supported – such as .returning value type int4 version supported GET_LINKS_SEPARATED method get_links_separated returning value type flag method get_link_decoration returning value type string Specifies whether or not two consecutive links are visibly separated "X" or space WML 4 GET_LINK_DECORATION Returns the delimiters that are automatically added to the link text by the device – for example [ ] or < >. for example as a tickertape. Returns the maximum size of the Href attributes of a link. . . .wbmp Returns the maximum memory capacity of the device Returns the name of the device type – such as 7110 for the Nokia 7110 mobile telephone Specifies whether or not the device supports "X" or space WML HTML 3 GET_MEMORY method get_memory returning value type float method get_model returning value type string GET_MODEL GET_NBSP_SUPPORTED method get_nbsp_supported 4 .gif format).jpg. for example as a tickertape.png. Specifies whether or not a long text can be displayed in one line. Returns the maximum number of characters that a link can have to fit into one line. .

returning value type flag non-breaking blank characters Specifies whether or not the browser supports nested tables "X" or space HTML 2 GET_NESTED_TABLES_SUPPORT ED method get_nested_tables_suppor ted returning value type flag method get_newline_after_image returning value type flag method get_newline_after_input returning value type flag GET_NEWLINE_AFTER_IMAGE Specifies whether or not a line break is inserted automatically after an <img> tag. Specifies whether or not a line break is inserted automatically after an <input> tag on a specific mobile device. Specifies whether or not a line break is inserted automatically before a link Specifies whether or not a line break is inserted automatically before an <select> tag. "X" or space WML 4 GET_NEWLINE_BEFORE_IMAGE "X" or space WML 4 GET_NEWLINE_BEFORE_INPUT Specifies whether or not a line break is inserted automatically before an <input> tag. "X" or space WML 4 GET_NEWLINE_BEFORE_LINK "X" or space WML 4 GET_NEWLINE_BEFORE_SELECT "X" or space WML 4 GET_NEWLINE_BETWEEN_IMAGE S Specifies whether or not a line break is inserted automatically after an <image> tag "X" or space WML 3 GET_NEWLINE_BETWEEN_LINKS Specifies whether or not a line break is inserted automatically between two <image> tags "X" or space WML 4 GET_NEWLINE_BETW_LINK_AND_ TAG Specifies whether or not a line break is inserted "X" or space WML 4 . Specifies whether or not a line break is inserted automatically after a link "X" or space WML 4 GET_NEWLINE_AFTER_INPUT "X" or space WML 4 GET_NEWLINE_AFTER_LINK method get_newline_after_link returning value type flag method get_newline_after_select returning value type flag method get_newline_before_imag e returning value type flag method get_newline_before_input returning value type flag method get_newline_before_link returning value type flag method get_newline_before_selec t returning value type flag method get_newline_between_im ages returning value type flag method get_newline_between_link s returning value type flag method get_newline_betw_link_an "X" or space WML 4 GET_NEWLINE_AFTER_SELECT Specifies whether or not a line break is inserted automatically after an <select> tag. Specifies whether or not a line break is inserted automatically before an <img> tag.

"X" or space 1 GET_REDIR_RELATIVE_SUPPORT ED Specifies whether or not the browser supports the redirection of a relative URL address. "X" or space HTML 2 GET_OFFLINE_FORMS_SUPPORT ED "X" or space HTML 2 GET_PAGE_SIZE_MAX 2 GET_PIXEL_HEIGHT GET_PIXEL_WIDTH Specifies the screen width in pixels.d_tag returning value type flag automatically between a link and a tag GET_OFFLINE_BROWSING_SUPP ORTED method get_offline_browsing_sup ported returning value type flag method get_offline_forms_support ed returning value type flag method get_page_size_max returning value type float method get_pixel_height returning value type float method get_pixel_width returning value type float method get_redir_absolute_suppo rted returning value type flag method get_redir_relative_support ed returning value type flag method get_script_supported returning value type flag method get_script_version returning value type int4 method get_secure_protocols_sup ported returning value type flag Specifies whether or not the browser supports offline browsing through locally stored pages (that is. GET_REDIR_ABSOLUTE_SUPPOR TED Specifies whether or not the browser supports the redirection of an absolute URL address. "X" or space 2 GET_SCRIPT_SUPPORTED Specifies whether or not the browser supports scripting "X" or space 2 GET_SCRIPT_VERSION Returns the script version supported GET_SECURE_PROTOCOLS_SUP PORTED Specifies whether or not the browser supports SSL (Secure Socket Layer) or WTLS (Wireless Transport Layer Security) Returns the names of the security protocols supported The names are separated by semicolons "X" or space GET_SECURE_PROTOCOLS_NAM ES method get_secure_protocols_na mes returning value type string method get_selection_menu_supp orted GET_SELECTION_MENU_SUPPOR TED Specifies whether or not the menu "X" or space WML 4 . Specifies the screen height in pixels. cached pages) Specifies whether or not the browser allows the user to fill out input forms offline on the device Returns the maximum page size that can be processed in a mobile device.

returning value type flag layout type "selectionList" is supported Specifies whether or not the <setvar> tag can be used within the <onevent type="onenterforward"> event handler Specifies whether or not the browser automatically skips to the first <input> tag and displays a screen extract starting from this tag Specifies whether or not text can be formatted as "small" "X" or space WML 1 GET_SETVAR_ON_EVENT_SUPPO RTED method get_setvar_on_event_sup ported returning value type flag GET_SKIPPING_TO_INPUT method get_skipping_to_input returning value type flag "X" or space WML 4 GET_SMALL_SUPPORTED method get_small_supported returning value type flag method get_softkey_num returning value type int1 "X" or space WML 5 GET_SOFTKEY_NUM Returns the number of Soft Keys supported by the device Specifies how soft key 1 is displayed on the screen „notShown" „key" „menu" „screen" „notShown" „key" „menu" „screen" WML 3 GET_SOFTKEY_STYLE1 method get_softkey_style1 returning value type string method get_softkey_style2 returning value type string method get_softkey_title_width returning value type int2 method get_sound_supported returning value type flag method get_strong_supported returning value type flag WML 5 GET_SOFTKEY_STYLE2 Specifies how soft key 2 is displayed on the screen WML 5 GET_SOFTKEY_TITLE_WIDTH Returns the number of displayed characters for a soft key title. WML 3 GET_SOUND_SUPPORTED Specifies whether or not the device can play sounds "X" or space HTML GET_STRONG_SUPPORTED Specifies whether or not text with the <strong>can be formatted as "highlighted" Specifies whether or not "Submit" is supported within the <onevent type="onenterforward"> event handler Allows you to split devices into different sub-categories "X" or space WML 5 GET_SUBMIT_ONEVENT_SUPPOR TED method get_submit_onevent_supp orted returning value type flag method get_sub_category returning value type string "X" or space 1 GET_SUB_CATEGORY Any text .

or centered "X" or space WML 5 GET_TEXT_STYLES_SUPPORTED Specifies whether or not the browser can format text using tags such as <b> or <small> Specifies whether or not a label is to appear on the top of the screen using the "title" property of the <card> WML tag.GET_TABLE_HAS_BORDERS method get_table_has_borders returning value type flag method get_table_supported returning value type flag method get_telephony_links_supp orted returning value type flag method get_text_alignment_suppo rted returning value type flag method get_text_styles_supported returning value type flag method get_title_supported returning value type flag Specifies whether or not tables are displayed with gridlines "X" or space 4 GET_TABLE_SUPPORTED Specifies whether or not the browser supports tables with several columns Specifies whether or not a telephone can be dialed directly using a link "X" or space 3 GET_TELEPHONY_LINKS_SUPPO RTED "X" or space 4 GET_TEXT_ALIGNMENT_SUPPOR TED Specifies whether or not text within a paragraph can be aligned left. right. Returns the maximum number of characters of the title Specifies whether or not text can be formatted as "underlined" "X" or space WML 5 GET_TITLE_SUPPORTED "X" or space WML 3 GET_TITLE_WIDTH method get_title_width returning value type int2 method get_underline_supported returning value type flag method get_user_agent returning value type string method get_vars_across_card_su pported returning value type flag method get_vendor returning value type string method get_xsl_supported returning value type flag 3 GET_UNDERLINE_SUPPORTED "X" or space WML 5 GET_USER_AGENT Equivalent to the HTTP request header "userAgent" Specifies whether or not browser variables passed to a card can also be used for different cards Returns the manufacturer’s name "X" or space WML 1 GET_VARS_ACROSS_CARD_SUP PORTED GET_VENDOR GET_XSL_SUPPORTED Specifies whether or not the browser supports Extensible Stylesheet Language (XSL) Returns the XSL version supported "X" or space HTML GET_XSL_VERSION method get_xsl_version returning value type int4 HTML .

the request and response object. 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 application object (if an application class was defined for the BSP application). For example. can be accessed. The objects and their signatures for the individual event handlers are displayed if you choose Example: in the Web Application Builder. the navigation object. . layout. input processing).Global Objects Certain global objects can be accessed from all parts of a BSP (initialization. and the runtime object.

The following methods are available for navigation between BSP pages. The class contains methods which are used to determine the characteristics of the subsequent page. After the subsequent is navigated to. See also: • • Class CL_BSP_APPLICATION Interface IF_BSP_APPLICATION Integration This object is only available if an application class was defined for the BSP application.Object application Definition The object application refers to the application class of a BSP application. They collect information required for the presentation of the subsequent page. Object navigation Definition The object navigation has the same type as interface IF_BSP_NAVIGATION. the navigation object is deleted. the methods defined there can be accessed. and methods which can be used for transferring parameters between pages. Methods for Constructing the Subsequent Page next_page . Do not set parameters for the constructor. If so.

call_application You can use this method to navigate to a page (specified by the URL) in another application. . the current context is maintained. set_parameter Using the call navigation->set_parameter( name='myparameter' value = myvalue ). goto_page When this method is called. If the BSP application in which the method was called is running in stateful mode. The following methods exist for this purpose.sap. If no exit URL is given. and the subsequent page is opened. navigation->goto_page( 'error.When called.com' ). navigation->next_page( 'TOORDER' ). the exit URL of the BSP application is used. This call triggers a search for the navigation request TOORDER in the navigation structure of the BSP application. exit This method ends the current session in the active application and navigates to the given URL. The foreign application receives the URL as a parameter.htm' ). Methods for Transferring Parameters to the Subsequent Page A page can transfer parameters to a subsequent page. navigation->exit( exit_url = 'http://www. this method determines the subsequent page from the navigation structure. This value can then be used for processing in the subsequent page. you can set the page parameter myparameter to the value myvalue. the URL of the page that is to be navigated to next is displayed.

Object runtime Definition The runtime object refers to the interface IF_BSP_RUNTIME.If the form field (in the layout part) and the page parameter are of the type string and are specified by the same name (in this case. It is used when the user’s own HTTP request handlers are implemented. This method is not recommended for BSP applications. the following abbreviation can be used: navigation->set_parameter( 'myparameter' ). has_parameters This method returns 1 if at least one parameter was specified. Otherwise. get_parameter You can use this method to obtain the value of a parameter. the method returns 0. The following attributes can be set: • • • runtime->keep_context 0: stateless mode 1: stateful mode See also: • • Stateful and Stateless BSP Applications A Sample BSP Application Object request . myparameter).

when the entry cannot be converted to a specific format. This object is a message contained and outputs different types of error messages. Structure .Definition The request object is of the type IF_HTTP_ENTITY. and the corresponding text. Object messages Definition The object messages is the same type as the class CL_BSP_MESSAGES. IF_HTTP_REQUEST. It contains a list of error messages with details of severity. The attribute name must be available. IF_HTTP_REQUEST. Object response Definition The request object is of the type IF_HTTP_ENTITY. For more information see Handling Incorrect Input. for example. condition. This interface contains the interface The methods are explained in the section IF_HTTP_ENTITY. An entry is made in the list if syntax errors occur in automatic page attributes. This interface contains the interface The methods are explained in the section IF_HTTP_ENTITY. You can add additional entries to the messages object during input processing. Use You use the object to handle users‘ incorrect entries in BSP applications. Texts and conditions are user-definable in this case.

• GET_MESSAGE This method returns the requested message when it is called. • ADD_MESSAGE This method adds a single message when it is called.The following methods are available: • NUM_MESSAGES This method returns the number of messages when it is called. The following error levels are available: Attribute Name CO_SEVERITY_ERROR CO_SEVERITY_FATAL_ERROR CO_SEVERITY_INFO CO_SEVERITY_SUCCESS CO_SEVERITY_WARNING Initial Value 2 1 4 5 3 Description of Error Level Normal error Fatal error Information Success message Warning The messages are grouped together in a table (attribute M_MESSAGES). • ASSERT This method returns the message index for a specific condition or 0 when it is called. The conditions specify the message types or error levels. in the package SBSP_DOCU. • ASSERT_MESSAGE This method returns the message for a specific condition or an empty string when it is called. • ASSERT_SEVERITY This method returns the severity of the error for a specific condition or 0 when it is called. . Example There is an example showing the use of this object in the SAP System in the BSP application bsptutorialmessages.

htm . It is the same type as class CL_BSP_PAGE or the interface IF_BSP_PAGE Structure The following methods are the most important: Method get_page_name Use in Source Code <%= page>get_page_nam e( ) %> <%= page>get_page_url( ) %> <%= page>get_application _namespace( ) %> <%= page>get_application _name( ) %> <%= page>get_application _url( ) %> <%= page>get_application _theme( ) %> <%= page>get_application Output (Example) basic_page_object.htm sap Output of the BSP URL get_application_namespace Output of the BSP application namespace Output of the BSP application name Output of the BSP application URL Output of the BSP application theme Output of the BSP get_application_name it00 get_application_url /sap(bD1kZQ==)/bc/bsp/sap/it00 get_application_theme SAP_DEFAULT get_application_start_page default.htm Description Output of the BSP name get_page_url / sap(bD1kZQ==)/bc/bsp/sap/it00/b asic_page_object.Object page Definition The object page accesses information about a BSP.

In the BSP context. but only in connection with BSP extensions or elements. As an example. This object is not used in the BSPs themselves. 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. a simple HTML pushbutton can be implemented very easily: <input id=btn type=submit>. A BSP extension contains a collection of BSP elements. However. BSP Extensions Introduction The BSP programming model. each element is assigned to an ABAP class to represent the element functionality. XML. . repeatedly creating complex HTML coding is often a lengthy process that can easily result in errors. This mechanism is structured so that it can also be used by other types of BSPs. the original simple HTML coding becomes considerably more complex and unclear. the page context object provides information that is sent to all BSP elements. from an empty page right up to complex applications. WML and so on. With this technology you call them BSP extensions. which the generation of the HTML coding usually contains. Here an abstraction technology can be used to express both the syntax and the semantics of a specific section of HTML coding simply. provides developers with additional scope regarding the HTML coding that they can create._start_page( ) %> application start page Object page_context Definition Based on the interface IF_BSP_PAGE_CONTEXT. If you now start to use additional styles and other attributes for the size and the status of the button. which is based on the server pages technology.

Each element has specific attributes and is assigned to an ABAP class. which is first rendered in a string and then passed as a parameter to the element for further processing.20 system. could be an HTML link for creating a small text segment. btn1->end_tag( ). btn1->writer = current_output_writer. <htmlb:link id=”link1” reference=“http://www. For other examples. The element class writes the HTML to the HTML output stream based on the functionality that the element provides.sap. SAP delivers a set of predefined extensions such as HTML Business for BSP (HTMLB). it generates the following pseudocode. 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. In addition you can define your own extensions to meet specific requirements. No body components whatsoever are available or required (by the pushbutton). “button” is the element and “id” and “text” are attributes. for example: <htmlb:button id=”btn1” text=“Hit Me!” /> Here “htmlb” is the XML namespace.com”> Homepage of the e-company! </htmlb:link> This results in: . The usual notation for XML elements is used when elements are written to BSPs. In the sample pushbutton above. btn1->id = ‘btn1’. In this case. For more information see Creating Your Own BSP Extensions. You can also create composite elements to facilitate layout changes with complicated BSP applications. btn1->begin_tag( ). data: btn1 type ref to CL_HTMLBL_BUTTON. XHTMLB and PHTMLB which are available and can be used in every SAP Web Application Server 6. If the BSP compiler sees the element. This is based on the assumption that all elements in an extension support a common output style. A typical element. BSP Extensions and BSP Elements Each BSP extension consists of a collection of BSP elements. btn1->text = ‘Hit Me!’. for example.SAP provides an infrastructure that developers can use to implement BSP extensions within BSP applications. 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. it may be useful to manipulate the body or to process more detailed input. the start tag is followed immediately by the end tag. create object btn1. the element has a body.

dropdown lists and so on.The link element takes the Internet address as the reference. The HTML coding that is generated contains correct references to the style sheets that are available. the link element provides formatting based on the style that is provided by the BSP extension. 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. whose layout is implemented using HTMLB. thereby ensuring that the coding is correct. For example. Even if using elements and their resulting ABAP class calls seems to be fairly complex for this type of simple HTML element. . and further examples in BSP extension HTMLB_SAMPLES. You can find simple examples of using BSP extensions HTMLB. As part of the tutorials for creating Web applications with BSP. SBSPEXT_XHTMLB and SBSPEXT_PHTMLB. 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: Examples Different examples of BSP applications that use BSP extensions are available in the system. for example. XHTMLB and PHTMLB in the BSP applications SBSPEXT_HTMLB. Furthermore. you can also implement highly specialized extensions. The returned HTML coding need only be generated once (by an expert) in the ABAP element class. In this case. a Tutorial for a Small Online Bookshop is also available. In addition to a BSP extension for standard HTML elements such as pushbuttons. the user’s coding for this extension. you could develop an extension to map a company’s corporate identity to an HTML page. input fields. The element class can contain additional logic for generating browser-dependent HTML code. The body is used as input for the element.

bsp (package SBSPEXT_HTMLB).The following sections provide two simple examples of the HTMLB elements button and tableView: Button TableView Button You can find this example in the system under BSP application SBSPEXT_HTMLB. page button. Layout <%@page language="abap"%> <%@ extension name="htmlb" prefix="htmlb"%> <htmlb:content> <htmlb:page title = "BSP Extension: HTMLB / Element: Button"> <htmlb:form> <htmlb:button id = "myButton1" text = "standard" /> <br><br> <htmlb:button id = "myButton2" text = "Emphasized button" tooltip = "button quick info: Please click me" onClick = "MyButtonClick" .

* Scenario 1: Read event from manager. . IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.design = "emphasized" /> <br><br> <htmlb:button id = "myButton3" text = "Small button with fixed size " tooltip = "button tooltip: Please click me" onClientClick = "alert('myButton3 Clicked')" design = "small" width = "300" /> </htmlb:form> </htmlb:page> </htmlb:content> OnInputProcessing CLASS CL_HTMLB_MANAGER DEFINITION LOAD. * Optional: test that this is an event from HTMLB library.

DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON. Output TableView . * Scenario 2: Dispatch event directly onto event class DATA: event_handler TYPE REF TO CL_HTMLB_EVENT_EXAMPLE. ENDIF. CL_HTMLB_MANAGER=>dispatch_event( request = runtime->server->request event_handler = event_handler page_context = page_context ).DATA: event TYPE REF TO CL_HTMLB_EVENT. event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ). ENDIF. CREATE OBJECT event_handler. button_event ?= event. IF event->name = 'button' AND event->event_type = 'click'.

Layout <%@page language="abap"%> <%@ extension name="htmlb" prefix="htmlb"%> <htmlb:content> <htmlb:page title = "BSP Extension: HTMLB / Element: tableView"> <htmlb:form> <htmlb:tableView id = "tv1" headerText = "Connections" headerVisible = "true" design = "alternating" visibleRowCount = "8" fillUpEmptyRows = "true" onHeaderClick = "MyEventHeaderClick" onRowSelection = "MyEventRowSelection" selectionMode = "multiselect" table = "<%=sflight%>" > <htmlb:tableViewColumns> <htmlb:tableViewColumn columnName = "carrid" wrapping = "true" width = "100" onCellClick = "MyCellClickCarrid__" horizontalAlignment="center" title = "&nbsp. page TableView.bsp (package SBSPEXT_HTMLB)." type = "user" > <htmlb:textView id="$TVCID$" text = "$TVCVALUE$" design = "LABELSMALL" layout = "PARAGRAPH" required = "TRUE" width = "100%" tooltip = "$CARRNAME$" encode = "FALSE" wrapping = "TRUE" /> </htmlb:tableViewColumn> <htmlb:tableViewColumn columnName = "myicon" type = "user" title = "Image" horizontalAlignment="center" > <htmlb:link id = "$TVCID$" .You can find this example in the system under BSP application SBSPEXT_HTMLB.

onClick = "$CARRNAME$" tooltip = "$CARRNAME$"> <htmlb:image src = "$TVCVALUE$" alt = "$TVCVALUE$" tooltip = "$CARRNAME$" /> </htmlb:link> </htmlb:tableViewColumn> <htmlb:tableViewColumn columnName = "myinputfield" type = "user" title = "Input Field" cellInvalidKey = "invalid" cellDisabledKey = "disabled" horizontalAlignment="center" > <htmlb:inputField id = "$TVCID$" width = "100%" value = "$myinputfield$" type = "Date" showHelp = "true" firstDayOfWeek = "2" /> </htmlb:tableViewColumn> <htmlb:tableViewColumn columnName = "mybutton" type = "button" title = "Button" cellDesignKey = "design" onItemClick = "MyButton__" horizontalAlignment="center" /> <htmlb:tableViewColumn columnName = "fldate" onCellClick = "MyCellClickFldate__" title = "Datum" wrapping = "true" width = "100" horizontalAlignment="center" /> <htmlb:tableViewColumn columnName = "DDLKEY" title = "User defined: List Box" type = "user" > <htmlb:dropdownListBox id = "$TVCID$" table = "<%=sflight%>" nameOfKeyColumn = "DDLKEY" nameOfValueColumn = "CARRNAME" /> </htmlb:tableViewColumn> <htmlb:tableViewColumn columnName = "linktextid" title = "Link" type = "link" linkColumnKey = "linkcarrid" linkClickTarget = "_blank"/> .

value type string. scol type string. name type string. .<htmlb:tableViewColumn columnName="linkstextid" onItemClick = "MyLink__" title = "Link with Handler" type = "link" linkColumnKey = "linkcarrid"/> <htmlb:tableViewColumn columnName="linkid" horizontalAlignment = "center" type = "imagelink" linkColumnKey = "linkcarrid" linkClickTarget = "_blank" title = "ImageLink" /> </htmlb:tableViewColumns> </htmlb:tableView> </htmlb:form> </htmlb:page> </htmlb:content> Attributes Attribute rowSelection rowSelectionEvent sflight Auto Typing Type TYPE TYPE TYPE Reference Type STRING STRING MYSFLIGHT OnInitialization * event handler for data retrieval data: wa like line of sflight. str type string.

<wa>-FLOATT = 2000000. sytabix = sy-tabix. read table sflightlink assigning <waLink> with key carrid = <wa>-carrid. . field-symbols: <wa> like line of sflight. mod type i. if <wa>-carrid eq 'AA'. loop at sflight assigning <wa>. <wa>-myinputfield = sy-cdate. sytabix type sytabix. id type string. str = page->to_string( value = <wa>-FLDATE ). <wa>-LINKCARRID = <waLink>-HTTPLINK.gif'. select * from sflight into corresponding fields of table sflight./HTMLB_SAMPLES/aa. <wa>-linkstextid = <waLink>-CARRNAME.srow type string.. concatenate <waLink>-CARRNAME ' (' <wa>-CONNID '/' str ')' into <wa>CARRNAME. <wa>-linkid = '. sflightlink type table of sflightlink. concatenate <wa>-CARRID <wa>-CONNID str into <wa>-DDLKEY. str = <wa>-FLDATE. <waLink> type sflightlink. "<wa>-FLDATE <wa>-mybutton = <waLink>-CARRNAME. select * from sflightlink into table sflightlink. <wa>-linktextid = <waLink>-CARRNAME.

case mod. when 3. <wa>-invalid = 'X'. <wa>-myicon = 'ICON_WF_WORKITEM_ERROR'. case mod. <wa>-myicon = 'ICON_WF_WORKITEM_CANCEL'. endif. <wa>-disabled = 'X'. endcase. <wa>-myicon = 'ICON_WF_WORKITEM_COMPLETED'. when 6. when 7. <wa>-invalid = 'X'.. concatenate '. when 0.gif' into <wa>-linkid. case mod. when 2. when 2. <wa>-myicon = 'ICON_WF_WORKITEM_COMMITTED'. endcase. . mod = sytabix mod 8. when 5.else. <wa>-myicon = 'ICON_WF_WORKITEM_READY'. <wa>-myicon = 'ICON_WF_WORKITEM_RESERVED'. when 1. mod = sytabix mod 3. <wa>-myicon = 'ICON_WF_WORKITEM_STARTED'. when 1. when 4. mod = sytabix mod 5. when 0. <wa>-myicon = 'ICON_WF_WORKITEM_WAITING'. <wa>-disabled = 'X'./HTMLB_SAMPLES/' <waLink>-CARRNAME '.

endcase. event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ). ENDIF. OnInputProcessing * event handler for checking and processing user input and * for defining navigation CLASS CL_HTMLB_MANAGER DEFINITION LOAD. DATA: event TYPE REF TO CL_HTMLB_EVENT. <wa>-design = 'SMALL'. <wa>-design = 'EMPHASIZED'. IF event->name = 'tableView'. DATA: tableview_event TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW. IF event_id = CL_HTMLB_MANAGER=>EVENT_ID. * Optional: test that this is an event from HTMLB library.when 0. . <wa>-design = 'STANDARD'. endloop. * Scenario 1: Read event from manager. when 2. when 1. tableview_event ?= event.

you can develop your own tags for dynamic pages of BSP applications. and it . This object includes a record of related BSP elements with the corresponding attributes. ENDIF.* Scenario 2: Dispatch event directly onto event class DATA: event_handler TYPE REF TO CL_HTMLB_EVENT_EXAMPLE. CL_HTMLB_MANAGER=>dispatch_event( request = runtime->server->request event_handler = event_handler page_context = page_context ). CREATE OBJECT event_handler. Output Defining Your Own BSP Extension BSP Extensions and BSP Elements With the BSP extension concept. A BSP extension is represented by means of a special development object in the workbench.

• Clear-cut role distribution As a developer. as a designer. Advantages for Using BSP Elements • Reduces the complexity of the BSP pages. • Tool support within the workbench by the BSP extension editor Tool Support . a BSP element can be used by each BSP page. you define the BSP extensions and implement the respective element handler classes. on the other hand. • Reuse Generally speaking. The figure below explains these connections with a relatively simple example.also covers references to the appropriate element handler classes. you use the BSP elements in the page layout of BSP applications. Each BSP element has an element handler class assigned to it that implements its specific functions. The encapsulation of the functions into BSP elements can contribute greatly to reducing the script part in BSP pages.

each new BSP extension is copied. by the prefix ext. without additional effort. the BSP extension was created as a container for the corresponding elements. • Integration in the Tag Browser Through activation. specific attributes can be assigned to each element. On the BSP application pages. See also: Using BSP Extensions. • Generating the element handler class For each BSP element. you can then place the corresponding tags and their attributes wherever you want them in the editor using Drag&Drop. . 3. 4. Here. In addition. as an entry into the Tag Browser in SE80. and so on). 2. where-used list.In addition to the usual infrastructure (transport. you can generate a corresponding element handler class and its basis class in the Class Builder. a BSP page uses the elements of the BSP extension myExtension. you first create a BSP extension as a new development object. 5. Creating a BSP Extension Defining the Corresponding BSP Elements Implementing the Element Handler Class Activating the BSP Extension Entering Documentation BSP Extension Framework In the following example. The BSP elements are defined within the Workbench using the BSP extension editor. the workbench provides the following functions in order to ensure efficient processing of BSP extensions: • Creating and editing BSP extensions In the Object Navigator (SE80). in this case. Then you create one or several BSP elements and declare the individual element attributes. Process Flow Complete implementation of a BSP extension takes place in the following steps: 1. All the BSP elements in this extension are identified.

Creating BSP Extensions Use Whenever you wish to define and implement your individual tags for Business Server Pages. you first need a BSP extension as a separate workbench. as a rule.The specific functions of a BSP element are implemented with the help of a global element handler class myElementClass in the Class Builder. . This object then serves as a container for several BSP elements.

If there is none. the prefix references the corresponding BSP extension that is assigned through the extension directive. 1. The system displays the Object Directory Entry dialog box.Procedure To create a new BSP extension: 1. Assign a package. you create a separate development object in the Repository that appears in inactive status in your worklist. Each BSP element has a handler class assigned to it that implements its specific functions. . Alternatively (to steps 1-4). Choose the BSP Extension category from the object list selection and enter a name for the BSP extension you want to create. The predefined default prefix can be overwritten on the page of the BSP application by renaming the prefix attribute for the extension directive. The system checks whether a BSP extension with the specified name already exists in the SAP System. The new BSP extension is copied into the object list of the package. Choose Continue to confirm your entries. 5. The system displays the Create BSP Extension dialog box. you can create and declare attributes for each BSP element. Choose Yes to create the BSP extension. 2. The default prefix is a prefix that is entered into the BSP page in the standard version during Drag&Drop of the extension or one of your BSP elements from the Tag Browser into the BSP page Within a particular page. Result With the new BSP extension. 3. Also. you can create a new BSP extension by selecting the Create function from the context menu of a BSP extension that already exists within an object list. Click the button or press ENTER. 6. the Create Object dialog box appears. 4. Enter the default prefix without blanks or other special characters and also a meaningful description for the BSP extension as a short text. Open the Object Navigator (transaction: SE80). You can now create one or several BSP elements for this BSP extension and declare the appropriate element attributes. Defining BSP Elements Use You create individual elements for a BSP extension and these are inserted later on as tags in BSP pages.

2. The system displays the Create BSP Element dialog box. On the other hand. Then you have this generated. As a rule. This basis class already contains a standard implementation of the interface methods and is automatically updated whenever changes are made to the element data. you have the following options available to you: • User-Defined Validation . you enter the name of a non-existing class as the element handler class into the respective input field. Choose the function Create → BSP Element from the context menu. and a meaningful description for the BSP extension as a short text. Furthermore. 4. On the one hand. together with the corresponding basis class. Choose Continue to confirm your entries.Prerequisites The BSP extension already exists. For more details. valid ABAP class as the element handler class. Enter the name of the BSP element. refer to the section: • Defining Element Content. The properties of the created BSP element are displayed in the editor. a valid name for the Element Handler Class. We recommend that you derive this class from the automatically-generated basis class(Z)CLG_<name of BSP extension>_<name of BSP elements>. Defining Attributes of the BSP Element You can enhance the definition of a BSP element with a series of attributes. thus influencing the flow logic. 3. Procedure Creating BSP Elements 1. it is possible to access the element content through Further Options for the element and change it. Choose the required BSP extension from the object list. You can specify an existing. you can change the element content from the standard value. A valid class must support the interface IF_BSP_ELEMENT.

enter a name that uniquely identifies the attribute. P. Otherwise. no value is passed. you define that the attribute is passed to the event handler class as a reference. For more information. choose the Attributes tab in the element view and. you define that the value of the attribute in a BSP page may also be specified dynamically through a BSP expression (<%= . To create and declare an attribute.. and so on are not allowed because generically-typed attributes are not allowed in ABAP classes either. By setting this flag. no generic types) or object types (classes and interfaces). Dynamic value allowed Pass by reference Kind of typing X You have at your disposal the two types TYPE and TYPE REF TO.%>). X. refer to the section Pass by Reference for Attributes. N. switch to change mode. The reason for this is that object references in BSP pages can only be passed with the help of BSP expressions. if necessary. Required By setting this flag. depending on whether you have data or object references. you define that the attribute must be defined whenever the BSP element is used in a BSP page. only static values are possible in the form of a string. the system generates a public attribute with the same name in the basis class (CLG_* or ZCLG_*). Otherwise. .• • Iteration Through Element Content Manipulation of the Element Content Declaring Attributes for a BSP Element To create attributes for a BSP element. you can use the elementary ABAP types (however. Reference type X As reference type. Note that the selection TYPE REF TO is only appropriate in combination with the active option Dynamic Value Allowed. make the following specifications: Attribute X In this column. Generic types such as C. By setting this flag. not statically in the form of a string. There is a 1:1 relationship between the attributes of the BSP element and the class attributes. After you have activated the BSP extension ..

you have specified the BSP element behavior at runtime through further properties. Description The specifications marked with X are absolutely mandatory for each attribute. Here you enter an explanatory attribute description. Example: Input field from the BSP extension HTMLB <ui:inputField id="myID" value="" /> or <ui:inputField id="myID" value="" > </ui:inputField > . BSP elements have a particular content. This means that the resulting tags consist of a start and an end tag. With the new BSP element. provided this does not yet exist. and between these two there are either further (embedded) tags. By selecting the option for the Element Content in the attribute display of the BSP element. Also.Default value Here you always enter a value if the attribute is to be predefined with a value. you can define whether content should be embedded in the element or not. script elements. and possibly also the specified element handler class. In the next workstep. and have also declared the corresponding attributes. the basis class (Z)CLG_<name of BSP extension>_<name of BSP elements> is automatically created itself. and – if so – which content. you can activate the BSP extension Defining the Element Content In general. or even simply just text. Result The new BSP element is assigned as a subobject to the BSP extension and copied inactive into the object list. This value is copied from the Tag Browser into the BSP page when you insert the attribute or the entire BSP element. The display options comprise the following: Empty You select this option if the BSP element is not to have any content.

. you define that the content of the element is to be passed on unchanged...Solely BSP Elements By selecting this option. <a HREF="" .> . to the element handler class. without previous parsing. Example: Tree element from HTMLB <ui:tree id="myTREE"> <ui:treeNode id="ROOT" text="Root node"> <ui:treeNode id="N1" text="Node 1"/> <ui:treeNode id="N2" text="Node 2"/> </ui:treeNode> </ui:tree> BSP Elements and Static HTML This element can include both further BSP elements as well as any HTML part.. This reduction enables you to achieve performance optimization during runtime.</a> </ui:form> Element Interprets the Content Itself With this selection. Example: Form element from HTMLB <ui:form id="myFormID" method="POST"> <ui:inputField id="myID" value="" size="24"/> <br> <br> Some Text ... Any existing HTML part will be ignored by the runtime environment. you define that the BSP element is only to contain further BSP elements. This is appropriate whenever an interpretation of the element content is not required by .

<sql:selectStatement> SELECT * from SFLIGHT into table myFlights </sql:selectStatement > User-Defined Validation Use Activate this option in the Attributes display for the BSP element if you wish to execute a userdefined validation of the element call. You must set the return parameter valid within the method COMPILE_TIME_IS_VALID.. you need to redefine the methods COMPILE_TIME_IS_VALID (for validation at compile time) and/or RUNTIME_IS_VALID (for validation at runtime) in the element handler class. Runtime validation is particularly appropriate if attributes for BSP elements are assigned through BSP expressions (<%=. When determining this value. Activities In addition to activating the option User-Defined Validation . you use the predefined attributes and utilities belonging to the validation object validator. Example: The BSP element executes an SQL statement that must be specified in the element content. if you wish to check the correct type of attribute values. This can be the case. on the other hand. Validation at compile time.. validation can take place both at compile time and at runtime.the runtime environment. Generally speaking. or for attributes whose values are transformed into another data type (String -> I) at runtime. is done by the BSP compiler and takes place whenever values are passed using static attributes. for example. This object has corresponding conversion methods that identify attributes at compile time through the attribute name (see first .%>) only at runtime.

example). The validation object validator is already contained in the interface for COMPILE_TIME_IS_VALID as an input parameter. The RUNTIME_IS_VALID method, on the other hand, does not define any return parameter. The runtime validation triggers an appropriate runtime exception if there is an error. The validation object m_validator.is an important part of the method implementation. This object is already defined as an attribute of the element handler class and also has conversion methods that identify the attributes through their names and also through their value (see second example). The attributes to be checked (runtime attributes) are supplied as argument for calling the method RUNTIME_IS_VALID. This argument consists of a string in which the names of the attributes to be checked are listed, separated by ‘ / ‘.

It can happen that the string with the runtime attributes to be checked exceeds the maximum length of 200 characters when <Elementname>>RUNTIME_IS_VALID(attr_1/attr_2/ .../attr_n) is called – that is, if there is a large number of attributes. In such cases, you should pass the string ‘/ * / ‘ instead of the attribute name in order to avoid termination during activation.

Example: Validation at Compile Time
In the example below, the system is to check at compile time whether the value of the attribute required is a correct Boolean value and whether the two attributes size and maxlength contain integer values. For this purpose, the interface method COMPILE_TIME_IS_VALID is overwritten. The corresponding methods of the object validator for the attributes concerned are called for the conversion of the string value from the HTML data stream into Boolean and integer values. If all the checked attribute values are valid, the return value valid is filled accordingly with m_all_values_valid. method IF_BSP_ELEMENT~COMPILE_TIME_IS_VALID . validator->to_boolean( name = 'required' ). validator->to_integer( name = 'size' ). validator->to_integer( name = 'maxlength' ). valid = validator->m_all_values_valid. endmethod.

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.

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 . if howOften > 0. count = howOften - 1. rc = CO_ELEMENT_CONTINUE. else. 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

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. content = m_out->get_content( ). translate content to upper case. data: previous_out type ref to IF_BSP_WRITER. previous_out = me->get_previous_out(). previous_out-> print_string( content ). rc = CO_PAGE_CONTINUE. endmethod.

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.

the reference operator ->* must be used in ABAP in this case.In addition. endmethod. the indicator Dynamic Value Allowed was activated and TYPE REF TO was selected as Typing Kind in the attribute display.. Example The BSP element is to increase the content of a passed variable by 1. To access data. Note that in this case you must also select the typing kind TYPE REF TO for the corresponding attribute. Note that there is a reference to data in this example within a BSP element. The attribute value is required for passing the value. add 1 to value->*. you need to overwrite the method DO_AT_BEGINNING: method IF_BSP_ELEMENT~DO_AT_BEGINNING . the pass by reference is used whenever the BSP element is to change the content of a variable defined in the BSP page. rc = CO_ELEMENT_DONE. Activating the BSP Extension Use . . For the value attribute.. To execute this pass by reference at the beginning of the element call. 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.

Calling the respective BSP pages again means they will be regenerated if changes have been made. you create a runtime version of the BSP extension. If necessary.You use this standard function of the Workbench in order to put the entire BSP extension. Choose the required BSP extension from the object list. Result When you activate. Activation does not take place for the individual BSP elements alone. the system will generate the basis class (CLG_* or ZCLG_*) again upon activation. for example. but is always done for the entire extension. deleted. 3. Note that activating the extension can invalidate all the BSP pages that use this extension. There it is assigned to the selection Transportable or Local. the system will also regenerate the element handler classes and your basis classes. Newly-created classes are automatically written to the same transport request as the BSP extension. Confirm the selection by clicking Continue. If necessary. for example. Procedure 1. . Select the Activate function from the context menu or through the respective the application toolbar. This renewed generation always tales place during activation in the following cases: • • If generation-relevant element data has been changed because. icon in The system displays a list of all inactive objects. or was not transported by mistake. including its elements. The selected BSP extension is marked. into the active version. depending on the object catalog entry. Now the active version of the BSP extension appears in the Tag Browser under the entry BSP Extensions. 2. Prerequisites You have either created a BSP extension or processed one that already exists. element attributes have been created. If a basis class for a particular element does not exist at all because. it was deleted manually. or changed.

Implementing Element Handler Classes Use The element handler class is the central class of a BSP element. Element handler classes are instantiated during the processing of a BSP page and called at defined points in time using certain class methods. Through the type of implementation of certain methods belonging to this class. Prerequisites A valid element handler class must implement the interface IF_BSP_ELEMENT. you can control whether data is updated in the HTML data stream and whether the content of a BSP element is processed or discarded. 2. It implements the specific functions of an element and thus influences the flow logic of the BSP page that uses this element. you make sure that the new attributes are added as attributes of the element handler classes after activation of the BSP extension. In this way. Creating the attributes for the BSP element See also Defining BSP Elements. 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. Creating further methods or attributes that enhance the element functions Generated Classes and Class Hierarchy . Process Flow The flow during implementation of the specific functions of a BSP element is divided up into the following three steps: 1. Overwriting certain interface methods of the element handler class 3.

CL_BSP_ELEMENT . Basis class with a standard implementation of the IF_BSP_ELEMENT methods for all BSP elements.The following figure shows the position of the element handler class within the inheritance hierarchy of the classes involved: Extension Framework IF_BSP_ELEMENT Basic interface that each valid element handler class must implement. The methods and attributes of this interface already define the actual extension framework for BSP applications.

it contains public attributes that correspond to element attributes and. special interface methods can be redefined. As a rule. Use . it is derived from the CLG class. the element handler class can be enhanced to include specific methods. It has a 1:1 relationship to a BSP element and already contains a standard implementation for the corresponding element. This is recommended. CL_<EXTENSION>_<ELEMENT> The element class. depending on the element attributes. In addition. the standard implementation for the constructor (and. but not compulsory. Compared to its basis class. Basis Class CL_BSP_ELEMENT Definition The CL_BSP_ELEMENT class supplies a standard implementation of the interface IF_BSP_ELEMENT. if necessary. This basis interface basically provides a series of methods and attributes that are used as a framework for the implementation of individual elements in BSP extensions. additionally. has a 1:1 relationship to a BSP element and implements its specific functions. too.See also: Basis Class CL_BSP_ELEMENT Element-specific classes (Z)CLG_<EXTENSION>_<ELEMENT> This class is automatically generated by the development environment for each new BSP element and is provided as a basis class for the element handler class. In contrast to its superclass CL_BSP_ELEMENT. for the class constructor as well).

For more information. By calling the runtime method <Elementname>>RUNTIME_IS_VALID with the special argument ‘/*/‘. refer also to the example for user-defined validation. DO_AT_ITERATION This method is accessed after evaluation of the element content when the BSP page is processed.. Refer also to the section: Implementing Element Handler Classes. refer to the example given for userdefined validation.) becomes too long (maximum length is 200 characters) and thus overflows. The possible values of the return parameter RC are therefore: CO_ELEMENT_CONTINUE and CO_ELEMENT_DONE. you must overwrite certain interface methods in the element handler class and possibly also create new ones there. RUNTIME_IS_VALID Determines at runtime whether correct values have been assigned to the element attributes. The possible values for valid are: ‚X' or ' ' (blank). Using the return parameter RC you can control whether the content of the current BSP element is to be evaluated or not.The standard implementation of the class CL_BSP_ELEMENT provides the common basic functions for all element handler classes. you can prevent termination from happening at activation if the string with runtime attributes (arg_1/arg_2/. For information on how you can overwrite this method in the element handler class. For an example of a special implementation of this method. refer to the section Pass by Reference for Attributes. The prerequisite . Methods Interface Methods for Validation COMPILE_TIME_IS_VALID Determines at compile time whether correct values have been assigned to element attributes.. Interface Methods to Influence Element Flow and Element Content DO_AT_BEGINNING This method is always accessed at the beginning of the element call when the BSP page is processed. The validation result is written to the return parameter valid. To implement specific functions of a BSP element.

whatever the case. Returns the direct parent element. Returns an arbitrary parent element that is identified by the element handler class. Attributes General Interface Attributes .for calling this method at all is that the corresponding option Iteration Through Element Content has been explicitly set for the element. Returns an arbitrary parent element that is identified by the name of the extension and the name of the element. you can control whether the entire BSP page is to be evaluated further or not. Since the entire element content is available at this point. For an example of the implementation. Interface Method for Accessing the Content of the BodyWriter GET_PREVIOUS_OUT Returns the reference to the BodyWriter of the surrounding element. This method returns the return parameter RC. The possible values of the return parameter RC here. at the end of the element call. too. Using the return parameter RC. this method can be used for Manipulation of the Element Content. refer to the section Iteration Through Element Content. include the following: CO_ELEMENT_CONTINUE and CO_ELEMENT_DONE. Interface Methods for Accessing Parent Nodes GET_CLASS_NAMED_PARENT GET_ELEMENT_NAMED_PARENT GET_DIRECT_PARENT Interface Method For Error Handling RAISE_ERROR Triggers an exception of the class CX_BSP_ELEMENT_EXCEPTION. The possible values are therefore: CO_PAGE_CONTINUE and CO_PAGE_DONE. DO_AT_END This method is accessed.

This constant defines that the BSP element is not to be evaluated further. Static validator (for all class instances) that is used for runtime validation. This constant defines that the BSP element is to be evaluated (once more).ID M_NAME M_EXTENSION M_CLASS_NAME M_PARENT M_PAGE_CONTEXT Predefined Interface Constants CO_PAGE_DONE CO_PAGE_CONTINUE CO_ELEMENT_DONE CO_ELEMENT_CONTINUE Interface Attribute for the BodyWriter M_OUT Interface Attribute for Validation M_VALIDATOR BSP element ID BSP element name BSP extension name Name of element handler class Reference to a parent element Reference to the page context (IF_BSP_PAGE_CONTEXT) This constant defines that the BSP page is not to be evaluated further. Reference to the BodyWriter that manages the element content. Entering Documentation Use . Instances of this object are created only if the option Iteration Through Element Content has been explicitly set for the element. This constant defines that the BSP page is to be evaluated further.

2. 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. 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. Select the BSP extension in the Repository Browser. Result You have created a SAPScript document for the long text documentation of a BSP element and have assigned a transport request to it. 8. 3. Procedure To create documentation for a BSP element in SE80: 1. Go to Change mode. The SAPScript Editor is called up and displays an empty template with predefined paragraphs. Click the Documentation pushbutton in the toolbar. 7. Write your text into the predefined paragraphs. Save the document as active version. Test the documentation and make whatever corrections are necessary. Prerequisites • • The BSP extension and the elements to be documented have already been created. however. Save the SAPScript document as a raw version first. Double-click the required BSP element in the object list.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 will be transported to the translation worklist. If you have saved the document as an active version as well. 5. There are two different templates available for the BSP extension and the BSP elements. 6. . The procedure for creating the documentation is the same. Example The documentation for all BSP elements is available for the BSP extension HTMLB. 4. The system displays the element editor. If you store the documentation in the system.

Using BSP Elements Use All delivered or newly created BSP extensions are available in the Tag Browser of the Object Navigator. 7. including all the obligatory element attributes. Under BSP Extensions. however. You can use these in BSP application pages in order to create flexible Web user interfaces. are inserted at the selected cursor position in the BSP page. Multiple selection within the tree display is currently not supported. The system adopts as prefix the default prefix that was specified when you created the BSP extension. the extension directive for the page is automatically created. If this is not the case. . you can rename the prefix. 5. Double-click the selected entry in order to display the documentation for the BSP element. 4. the corresponding start tag and end tag. Choose the Layout view for the required BSP page. Click the switch button Tag Browser in the navigation area of the Object Navigator. So that the BSP extension is displayed with the required elements in the Tab Browser. proceed as follows: 1. 6. If you enter an element attribute. 2. You enter the individual BSP elements and their attributes as tags or tag attributes from the Tag Browser into the layout source text of the BSP pages. choose the appropriate extension. Using Drag and Drop. Prerequisites • • The switch button Tab Browser is available in the navigation area of the Object Navigator. 3. change the corresponding user settings. This means that all tags entered subsequently from the Tag Browser already contain the new prefix. With the first element of a BSP extension. Result When you select an element in the tree display. Procedure To insert BSP elements or their attributes into a BSP page. drag the selected element or element attribute to the appropriate position in the layout editor. the system takes the predefined standard value. Switch to Change mode. By typing over the prefix value in the extension directive. Expand the tree display and click the required BSP element. the extension must already be activated.

you can call this by pressing F1 in the layout editor of the BSP page. Example The following example demonstrates the usage of the BSP extension HTMLB in a BSP application. The flight data is displayed using a TableView element. and form elements . input.If documentation was created for a BSP element. 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. 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.for simple selection of flight data. and pushbutton element – in addition to the content. page. <%@page language="abap"%> <%@ extension name="htmlb" prefix="ui" %> <ui:content> <ui:page> <ui:form> <ui:label id for text design width = "myLabel" = "carrier" = "Airline" = "LABEL" = "65" /> . This example contains a label.

the default prefix is taken. A prefix serves as a unique identification of this extension within the page.<ui:inputField type id = "carrier" = "String" = "<%=carrier%>" = "3" = "standard" /> = "myButton" = "Find Flights" value size design <ui:button text id onClick = "FIND" design <br><br> <ui:tableView id table = "myTable" = "<%=flights%>" = "STANDARD" /> headerVisible = "true" footerVisible = "true" fillUpEmptyRows= "true" selectionMode = "MULTISELECT" design </ui:form> </ui:page> </ui:content> Note on the prefix: The BSP extension HTMLB is imported into the BSP page through the extension directive (2nd line). However. This directive is automatically crated after you have inserted the first BSP element for the page. = "ALTERNATING" /> . you can rename the prefix by overwriting the corresponding value in the extension directive (in our example: ui). In the standard version.

htm. 3. You should use BSP extension HTMLB to solve this task. Task Three input fields with labels should be displayed on a screen. The three fields should be arranged under each other. and to minimize the amount of work required to develop BSP applications and their layouts.htm. A simple BSP extension is presented and implemented. To generate the layout you require. 2. including labels and tableformat displays. Although the example is restricted to three simple input fields. In such cases. typical task to display possible solutions. First use the already existing BSP extension HTMLB on page before. you often need a number of special elements. . with the following predefined layout elements: • • • <htmlb:gridLayout> <htmlb:label> <htmlb:inputField> Process 1. already existing BSP elements to generate the output within the layout framework by including and wrapping the BSP elements that already exist. you can create composite BSP elements to facilitate handling several special elements. Integration Composite BSP elements use other. it may not be easy to use elements that are essentially simple BSP elements. Then create the composite element and use it on page after.Composite Elements Use When you create BSP applications with BSP extensions. Users should enter their name. password and e-mail address in these input fields. the composite element solution is intended for cases where a number of variable input fields should be displayed. Create a test BSP application. The following uses a complex.

Activities Create page before.htm as a page with flow logic 2. this Procedure 1. (see also Creating Pages). create page before. Define three page attributes for the three input fields: .htm Design solution Create a new BSP extension with elements Create page after. Prerequisites You have created a BSP application (see also has the name BSP_TUT_COMPLEX.Prerequisites You already understand the concept of BSP extensions and their implementation. Creating BSP Applications). implement the output using HTMBL. In our example.htm Dynamically process BSP elements Create a new BSP extension with composite elements Step 1 a) Implement <sf:SimpleFormItem> Step 1 b) Use <htmlb:SimpleFormItem> Step 2: Create <sf:SimpleForm> Step 3: Changes to the Look and Feel Creating Page before.htm Use On this page. In your BSP application.

name --%> <htmlb:gridLayoutCell columnIndex = "1" rowIndex = "1" > <htmlb:label id = "name_label" text = "Name:" for = "name" /> </htmlb:gridLayoutCell> <htmlb:gridLayoutCell columnIndex = "2" rowIndex = "1"> <htmlb:inputField id = "name" value = "<%=name%>"/> </htmlb:gridLayoutCell> <%-.password --%> <htmlb:gridLayoutCell columnIndex = "1" rowIndex = "2" > <htmlb:label id = "password_label" text = "Password:" for = "password" /> </htmlb:gridLayoutCell> <htmlb:gridLayoutCell columnIndex = "2" rowIndex = "2"> <htmlb:inputField id = "password" value = "<%=password%>" password = "TRUE" /> </htmlb:gridLayoutCell> <%-.Attribute name password email Auto x x x Typing Type TYPE TYPE TYPE Reference Type STRING STRING STRING 3.email --%> <htmlb:gridLayoutCell columnIndex = "1" rowIndex = "3" > <htmlb:label id = "email_label" text = "Email:" . Create the page layout with HTMBL elements: <%@page language="abap"%> <%@extension name = "HTMLB" prefix = "htmlb" %> <htmlb:content> <htmlb:page> <htmlb:form> <htmlb:gridLayout cellSpacing = "2" cellPadding = "0" width = "100%" rowSize = "3" columnSize = "2"> <%-.

you cannot always immediately recognize at a glance the coding structure. most attributes can now be calculated automatically. It is therefore recommended that you design a BSP extension library that also contains inherent information (that is. Save and activate your page and the BSP application. . although it makes sense to use it with more complex layouts. Result The generated output is as follows: Analysis You need more than 40 lines coding to code the simple three input fields. For these flow-type layouts. hard-coded elements) for the layout of a specific BSP application or a group of BSP applications. As a result. You can do all this using the Design Solution. the individual BSP extensions in this library will be "slim" and easy to create.for = "email" /> </htmlb:gridLayoutCell> <htmlb:gridLayoutCell columnIndex = "2" rowIndex = "3"> <htmlb:inputField id = "email" value = "<%=email%>" /> </htmlb:gridLayoutCell> </htmlb:gridLayout> </htmlb:form> </htmlb:page> </htmlb:content> 4. It is exactly the same when you connect <htmlb:label> to <htmlb:inputField>. Also. Many of the attributes can also be hard-coded in a set of wrapper elements. This element is not absolutely necessary for our example. These can be used to create "toolboxes" that encapsulate the appearance and the whole layout centrally. Ideally. you can also make changes to the whole application very quickly. especially counters for rows and columns. because of the <htmlb:gridLayout> element.

Finally. of course.htm. The flexibility of the <htmlb:inputField> is still available. Element <SimpleForm> b. but a solution for a clearly delimited application area. Procedure The following describes the procedure for implementing this solution: 1.Design Solution After analyzing the page before. Create the new BSP extension 2. so that you can carry out functions such as password handling without any problems The format of the layout can be specified with BSP elements as follows: <sf:SimpleForm id = "sf" > <sf:SimpleFormItem id = "name" label = "Name:" value = "<%=name%>" /> <sf:SimpleFormItem id = "password" label = "Password:" value = "<%=password%>" password = "TRUE" /> <sf:SimpleFormItem id = "email" label = "Email:" value = "<%=email%>" /> </sf:SimpleForm> Here you require a new BSP extension. You also need a test page. Create the elements for the new BSP extension a. style. As a result. which contains all of the necessary elements. you need a set of elements that are easy to use and which can be used for the outlined task area. Element <SimpleFormItem> . and so on) are hard-coded Elements <htmlb:label> and <htmlb:inputField> are linked to each other. the initial situation is as follows: • • • • All row and index counters are calculated automatically All values for the layout (such as width. you also need to implement the elements. this is not a universal solution. Starting with the example.

create element <SimpleForm> (see also Defining BSP Elements). 3. or if you want to insert them in the view without having used this extension previously. At the end. Specify that the BSP elements are processed dynamically Creating a New BSP Extension with Elements Procedure To create the new BSP extension for the solution that is described. We recommend that you integrate the default BSP extension prefix with the name of the element handler class. you can change the default prefix at any time by renaming the prefix attribute of the extension directive. In our example. . the name of the element handler class is CL_BSP_TUTCMPLX_SIMPLE_FORM.htm 3.1. Create the page after. 2. In our example. first define the extension itself and then the elements that it contains. 1. In your new extension. this has the name BSP_TUTORIAL_COMPLEX. In our example. this is TutCmplx. In our example. 4. The default prefix is used for this BSP extension if you use drag & drop to add elements of this extension in the page with flow logic. If you use the BSP extension. In our example. Create a new BSP extension in the ABAP Workbench (see also Creating BSP Extensions). activate the extension. Enter a Default prefix. the element content consists exclusively of inner BSP elements and therefore does not have any freely-defined text. Generate your new BSP extension 2. the element has an (obligatory) attribute called id of type string. Define and configure the BSP element as usual.

The new definition in particular is still linked to the original implementation class (element handler class). you can use this new extension already in a new page in your BSP application.. This element displays an element that wraps both <htmlb:label> and <htmlb:inputField>. even if they do not create any tasks. Since the copy function only copies the logical definition of the element. c. Then enter as the destination the BSP extension BSP_TUTORIAL_COMPLEX and SimpleFormItem as the destination BSP element. Add the additional attributes that you require for processing <htmlb:label>. branch to the BSP extension HTMLB for element <inputField> and on the selected element in the context menu choose Copy. which is the label name. enter the additional attribute label of type string. On the tabstrip Attributes. Procedure . Save the BSP extension and generate it. you can simply copy the <htmlb:inputField> element... the empty implementations for the elements were already generated. you only need one new attribute.5. and empty standard implementations were generated by the system for each element. Use the tabstrip Properties to change the connection to the element handler class and enter CL_BSP_TUTCMPLX_SIMPLE_FORM_IT. a. In this simple example. As a result. All elements are defined. the elements can be used already.htm Use Once you have created your new BSP extension with the two new elements. d. To do this. 1. b. You can now create a simple test page (although this does not create any output). Creating Page after. Result At this point. you must make a few additional changes. Create new BSP element <SimpleFormItem>. Since the <htmlb:inputField> element contains most of the attributes that you require for the new <TutCmplx:SimpleFormItem> element.

htm to the name after. (in simple pseudocode notation) this could be as follows: Element: <lib:element a1 = "v1" /> . although there is no output. before. In the Web Application Builder.htm. In a simple example. a compiler translates the XML syntax that represents the interface for the element in source code. activate and test your BSP application. Save. implement dynamic BSP element processing Dynamically Processing BSP Elements If a BSP element is located in the layout of a BSP. Change the layout coding: <%@page language="abap"%> <%@extension name = "HTMLB" prefix = "htmlb" %> <%@extension name = "BSP_TUTORIAL_COMPLEX" prefix = "sf" %> <htmlb:content> <htmlb:page> <htmlb:form> <sf:SimpleForm id <sf:SimpleFormItem id label value <sf:SimpleFormItem id label value password <sf:SimpleFormItem id label value </sf:SimpleForm> </htmlb:form> </htmlb:page> </htmlb:content> = "sf" > = "name" = "Name:" = "<%=name%>" /> = "password" = "Password:" = "<%=password%>" = "TRUE" /> = "email" = "Email:" = "<%=email%>" /> 3. Result Everything runs as usual. use the context menu to copy the existing page 2.1. In the next step. which is then executed at runtime.

e124->a1 = ‘v1‘. </lib:element3> Source: DATA: e125 TYPE REF TO CL_LIB_ELEMENT3. </lib:element2> Source: DATA: e124 TYPE REF TO CL_LIB_ELEMENT2. page->current_element = e124->parent. e123->a1 = ‘v1‘. or it can include inner.. The element can either contain body text only. context->POP_WRITER( ). page->current_element = e123. e123->DO_AT_END( ).. CREATE OBJECT e125. however. also require its own writer. e124->m_out = context->PUSH_WRITER( ).. This suggests that the body of the element is processed more than once. e123->context = page->context. embedded elements that must be processed. Element: <lib:element3 a1 = "v1" /> . CREATE OBJECT e124. e125->parent = page->current_element. e124->RUNTIME_VALIDATION( ). ENDIF. page->current_element = e123->parent. context->current_writer->PRINT_STRING( `. an element can specify that its body requires iteration. page->current_element = e124. CREATE OBJECT e123. page->current_element = e125. e124->DO_AT_END( ). IF e124->DO_AT_BEGINNING( ) = CO_ELEMENT_CONTINUE. e123->DO_AT_BEGINNING( ).Source: DATA: e123 TYPE REF TO CL_LIB_ELEMENT.. Furthermore. e124->parent = page->current_element. Element: <lib:element2 a1 = "v1" /> . An element can.. e123->parent = page->current_element. e124->context = page->context. and possibly also validation. . e125->a1 = ‘v1‘..` )..

externally of the page. You can. .. You cannot encapsulate body processing.body processing. From the examples above. rc125 = e125->DO_AT_ITERATION( ).. since it is not known if the body is a string. processing_before_body( eX ). rc125 = e125-> DO_AT_BEGINNING( ). however. you can see that to set an element’s attributes you need a reference to the actual class. context->current_writer->PRINT_STRING( `.` ). Due to these design constraints. the compiler uses the additional information about the BSP element’s definition to generate the optimum code for processing the element. or if it consists of several embedded elements that have to be processed. If an element is processed dynamically. Also. elements do not have methods to actually set attributes. CREATE OBJECT eX. that is. . context->POP_WRITER( ). you must know the element class (you can find it in the BSP extension workbench). e125->m_out = context->PUSH_WRITER( ). or the phase in which attributes are set.e125->context = page->context.. the following pseudocode can be written: DATA: eX TYPE REF TO CL_LIB_ELEMENTX.. The attributes are set directly as public attributes of the element classes. WHILE e125 = CO_ELEMENT_CONTINUE.... ENDWHILE. eX->a1 = ‘v1‘. processing_after_body( eX ). Obviously. page->current_element = e124->parent. It is not effective to encapsulate the actual element class reference. e125->RUNTIME_VALIDATION( ). e125->DO_AT_END( ). and not to interface IF_BSP_ELEMENT. pack the remaining code in one or more methods. The same flexibility is now required for processing BSP elements externally of the actual BSP.

or only a simple string body is required. The body can also be written dynamically during the processing step. eX->a1 = ‘v1‘. Now to processing an "empty" element. Element: <lib:eX a1 = "v1" /> Source: DATA: eX TYPE REF TO CL_LIB_ELEMENTX. . In this case. eX->a1 = ‘v1‘. this can be done when the body string is provided. The pseudocode can therefore be written as follows: DATA: eX TYPE REF TO CL_LIB_ELEMENTX. m_page_context->ELEMENT_PROCESS ( element = eX ). This type of element processing method with the name ELEMENT_PROCESS is available in interface IF_BSP_PAGE_CONTEXT. Element: <lib:eX a1 = "v1" /> body string </lib. If the simple element requires a body as well. users can be flexible when determining how inner elements are to be used.body processing. This enables users to set the element attributes first of all. if this is possible). CREATE OBJECT eX.. which is available in every element. "empty" means that the element is flagged in the Workbench as empty. eX->a1 = ‘v1‘. you must decide whether iteration is carried out.This code is still not sufficiently flexible to handle element iteration. ENDWHILE. After the body has been processed. it does not mean that there is only an optional body. If a body is not required. provided that the optional body string is available. CREATE OBJECT eX. WHILE process_element( eX ). Furthermore. CREATE OBJECT eX.eX> Source: DATA: eX TYPE REF TO CL_LIB_ELEMENTX.. m_page_context->ELEMENT_PROCESS ( element = eX body = ‘body string‘)... processing continues as far as possible (until it is complete. or if it should be stopped. .

. CREATE OBJECT eX. Element: <lib:eX a1 = "v1"> body before <lib:eY a1 = "v1"> body inside </lib:eY> body after </lib:eX> Source: DATA: eX TYPE REF TO CL_LIB_ELEMENTX. CREATE OBJECT eX. out->PRINT_STRING( `body string` ). DATA: out TYPE REF TO IF_BSP_WRITER. Element: <lib:eX a1 = "v1" /> body string </lib. Each time a new element is (partly) processed. out = m_page_context->GET_OUT( ). new writers may be pushed on the stack.eX> Source: DATA: eX TYPE REF TO CL_LIB_ELEMENTX. the system assumes that this body represents the whole body. that the active writer is used for writing the body. and therefore then ends processing for that element. eX->a1 = ‘v1‘. You can process inner elements by starting your processing when the external element is processed. out = m_page_context->GET_OUT( ).Note however. If the body is transferred as a parameter. Ensure that you do not transfer a body to the processing code. m_page_context->ELEMENT_PROCESS ( element = eX ). m_page_context->ELEMENT_PROCESS( element = eX ). eX->a1 = ‘v1‘. The writer that is used must be the last writer that was added. m_page_context->ELEMENT_PROCESS( element = eX ). DATA: out TYPE REF TO IF_BSP_WRITER.

. out = m_page_context->GET_OUT( ). DATA: eY TYPE REF TO CL_LIB_ELEMENTY. it is always correct to write a WHILE loop around the ELEMENT_PROCESS().out->PRINT_STRING( `body before` ). m_page_context->ELEMENT_PROCESS( element = eY body = `body inside` ).call. eY->a1 = ‘v1‘. the element instance can not be reused. ENDWHILE. m_page_context->ELEMENT_PROCESS ( element = eX ). eX->a1 = ‘v1‘. CREATE OBJECT eX. m_page_context->ELEMENT_PROCESS( element = eX ). CREATE OBJECT iterator. CREATE OBJECT eY. CREATE OBJECT eX. since you cannot rest all element default values like the BSP compiler does. iterator->repeat = 3. As soon as an element has been processed. WHILE m_page_context->ELEMENT_PROCESS ( element = iterator body = ‘body string‘ ) = CO_ELEMENT_CONTINUE. eX->a1 = ‘v1‘. Iteration implies that the same body is processed until the element has enough. The create object call must therefore always be executed when the same element is to be processed again. Element: <lib:eX a1 = "v1" /> <lib:eX a1 = "v1" /> Source: DATA: eX TYPE REF TO CL_LIB_ELEMENTX. out->PRINT_STRING( `body after` ). In principle. This is the recommended technique for using this method. Element: <lib:iterator repeat = "3" /> body string </lib:iterator> Source: DATA: iterator TYPE REF TO CL_LIB_ITERATIR.

you will see how you can change the layout of all pages simply by changing the new elements.m_page_context->ELEMENT_PROCESS ( element = eX ). In the second step. the following selects a two-level implementation. Procedure Step 1 a) Implement <sf:SimpleFormItem> Step 1 b) Use <htmlb:SimpleFormItem> Step 2: Create <sf:SimpleForm> Step 3: Changes to the Look & Feel Step 1 a) Implementing <sf:SimpleFormItem> . a simple HTML code sequence is written using the <table> HTML element. Creating a New BSP Extension with Composite Elements Use Instead of creating a complete solution using the <htmlb:gridLayout> as in the first implementation. Finally. • • In the first section. Now create the new BSP extension with the composite elements. The elements <htmlb:label> and <htmlb:inputField> are used for the actual table content. the <htmlb:gridLayout> is added.

out = me->GET_PREVIOUS_OUT( ). Create the element class 2. RC = CO_ELEMENT_CONTINUE. they can be processed in one step. the rendering code is as follows: <tr><td> <htmlb:Label/> </td><td> <htmlb:inputField/> </td></tr> For the implementation. endmethod. For the actual element <sf:SimpleFormItem>. Since both elements are empty (that is. Set the attributes 3. overwrite and implement the following two methods: method IF_BSP_ELEMENT~DO_AT_BEGINNING . method IF_BSP_ELEMENT~DO_AT_END . endmethod. DATA: out TYPE REF TO IF_BSP_WRITER.Since the <sf:SimpleFormItem> requires an HTML <table> wrapper. The complete coding is then as follows: method IF_BSP_ELEMENT~DO_AT_BEGINNING . RC = CO_PAGE_CONTINUE. and written to the data stream. . first create the <sf:SimpleForm> element to render the correct HTML in the output stream. The processing steps are as follows for each element: 1. Within class CL_BSP_TUTCMPLX_SIMPLE_FORM. out = me->GET_PREVIOUS_OUT( ). out->PRINT_STRING( '</table>' ). DATA: out TYPE REF TO IF_BSP_WRITER. out->PRINT_STRING( '<table>' ). they don’t have a body). the HTML coding is fetched in the usual way using the current output writer. Processing the <htmlb:*> element is slightly more difficult. Use method ELEMENT_PROCESS for the final processing.

out = me->GET_PREVIOUS_OUT( ). inputField->width = me->width. * <htmlb:Label/> DATA: label TYPE REF TO CL_HTMLB_LABEL. * <htmlb:inputField/> DATA: inputField TYPE REF TO CL_HTMLB_INPUTFIELD. inputField->size = me->size. label->encode = 'FALSE'. inputField->password = me->password. inputField->type = me->type. label->for = me->id. label->text = me->label. CONCATENATE me->id '_label' INTO label->id. inputField->value = me->value. inputField->required = me->required. inputField->description = me->description. inputField->invalid = me->invalid. m_page_context->ELEMENT_PROCESS( element = inputField ). inputField->maxlength = me->maxlength. * <tr><td> out->PRINT_STRING( '<tr><td>' ). inputField->id = me->id. * </td><td> out->PRINT_STRING( '</td><td>' ). m_page_context->ELEMENT_PROCESS( element = label ). inputField->disabled = me->disabled. inputField->visible = me->visible. CREATE OBJECT inputField. rc = CO_ELEMENT_DONE. . endmethod. * </td></tr> out->PRINT_STRING( '</td></tr>' ). inputField->showHelp = me->showHelp. label->wrapping = 'FALSE'. inputField->firstDayOfWeek = me->firstDayOfWeek. CREATE OBJECT label.DATA: out TYPE REF TO IF_BSP_WRITER.

of course.Note that you cannot make any changed to the actual output writer structures. You can now test page after. the entry must be changed so that it renders a string. although not in the output stream. This is automatically controlled by the development environment (indirectly using the PROCESS_ELEMENT call). a counter is required to count exactly the number of fields that are required so that the gridLayout and. and with which they are finally rendered. and that this string is forwarded for rendering the <sf:SimpleForm> later. which are both of type string. . The following task appears: Continue with Step1 b) Using <htmlb:SimpleFormItem> Step 1 b) Using <htmlb:SimpleFormItem> Element <sf:SimpleFormItem> has been implemented and can therefore be used. The best way to do this is if elements <htmlb:label> and <htmlb:inputField> are rendered immediately. This means that entries are first counted and then later rendered. The coding. in which the content is stored and the entries are counted. To realize this. each individual cell can be configured correctly.htm. A new method ADD_ITEM is added to element <sf:SimpleForm> with the two parameters label_html and inputField_html. these elements are rendered in separate writers. You must now ensure that each entry is rendered directly in the current output stream. exactly like the inner elements that are processed. is executed on the current writer. If the <htmlb:gridLayout> is used later. Instead.

'<tr><td>' ).. * Add own temporary writer on stack my_out = m_page_context->PUSH_WRITER( )... inputField_html TYPE STRING.. '</td><td>' ). the element output must not be written to the current writer under any circumstance. which implement additional functionality. The simple coding will be as follows: method ADD_ITEM . all new elements will write to this new writer. DATA: my_out TYPE REF TO IF_BSP_WRITER. * <htmlb:Label/> . The changed coding is then as follows: method IF_BSP_ELEMENT~DO_AT_BEGINNING . inputField_html = my_out->GET_CONTENT( ).. For each internal element that is used. Furthermore. DATA: out TYPE REF TO IF_BSP_WRITER. the coding is changed within <sf:SimpleFormItem>.. In the next step. The element handler classes are normal ABAP classes that can be processed in the Workbench. " <htmlb:inputField/> " </td></tr> . * <htmlb:inputField/> .You can add additional methods to the BSP event handlers. out = me->GET_PREVIOUS_OUT( ). label_html TYPE STRING. this ensures that a new writer is pushed on the stack. As a result. The only task for ADD_ITEM at the moment to render the string immediately. label_html ). inputField_html '</td></tr>' ). my_out->CLEAR( ). and the context can be extracted from this new writer at any time. label_html = my_out->GET_CONTENT( ). and which can in turn be used by "lesser" elements. " <tr><td> " <htmlb:Label/> " </td><td> ). out->PRINT_STRING( out->PRINT_STRING( out->PRINT_STRING( out->PRINT_STRING( out->PRINT_STRING( endmethod.

my_out->CLEAR( ). endmethod. * Remove my writer from stack m_page_context->POP_WRITER( ).htm again to ensure that it still runs correctly. rc = CO_ELEMENT_DONE. The call of method ADD_ITEM(). see Step 2: Creating <sf:SimpleForm> Step 2: Creating <sf:SimpleForm> . • The use of methods GET_CONTENT() to extract the current string to the output. At the end of this method. which represents a local method that is defined by the element. the additional writer must be removed from the stack using method POP_WRITER(). We have also described how the output of this type of element can be written to a string. • • You can now execute page after. This section has described how BSP elements are processed on the stack. For more information. * Copy Text to <sf:SimpleForm> DATA: sf TYPE REF TO CL_BSP_TUTCMPLX_SIMPLE_FORM. Note the following points: • The use of PUSH_WRITER() at the beginning to add an additional writer to the stack. and CLEAR() to ensure that the two elements are in separate strings. sf ?= me->GET_CLASS_NAMED_PARENT( 'CL_BSP_TUTCMPLX_SIMPLE_FORM' ). so that it can be rendered later. sf->ADD_ITEM( label_html = label_html inputField_html = inputField_html ). All new elements that are now processed write to the top writer on the stack. The use of method GET_CLASS_NAMED_PARENT() to receive a reference to an element that is located "further up" in the element stack. The element <sf:SimpleFormItem> is then complete.

The next step after Step 1: Using <htmlb:SimpleFormItem> is similar. endmethod. endmethod. This is why the whole local data structure must be reset each time that a new element is restarted. CLEAR labels. The coding for the output would therefore be as follows: . APPEND inputField_html TO inputFields. In the last step. This is triggered by the code generator for the BSP. The entries must be collected and rendered at the end. You must first enhance the simple form handler class so that the entries are not written as soon as they are added. CLEAR inputFields. The coding that is executed at the beginning must be changed as follows: method IF_BSP_ELEMENT~DO_AT_BEGINNING . the whole rendering should be executed at the end tag of the element. APPEND label_html TO labels. Add two string tables as class attributes to class CL_BSP_TUTCMPLX_SIMPLE_FORM: Name LABELS INPUTFIELDS Type Instance attribute Instance attribute Visibility private private Typing Type TYPE TYPE Reference Type STRING_TABLE STRING_TABLE Description Table of strings Table of strings Change the ADD_ITEM method to collect the entries: method ADD_ITEM . Ensure that an element handler class can be reused several times. RC = CO_ELEMENT_CONTINUE.

</htmlb:GridLayout> Here. LOOP AT labels INTO label. gridLayout->columnSize = 2. An element would usually be processed by a WHILE loop.code to process gridLayoutCell for label and for inputField ENDLOOP.. gridLayout->id = me->id. the second call of PROCESS_ELEMENT is required for processing the end tag. The <htmlb:gridLayout> is processed in the first part of the coding. . Ensure that the whole output is written to the currently active writer. rc = CO_PAGE_CONTINUE. and finally the end tag </htmlb:gridLayout> must be processed. both the start and the end tag are processed. READ TABLE inputFields INTO inputField INDEX sy-tabix. After the inner tag has been processed. . After the first processing call. the element was pushed on the processing stack and is therefore available as if the compiler had generated the code. while PROCESS_ELEMENT is called at the end. DATA: label TYPE STRING. inputField TYPE STRING.<htmlb:GridLayout …> LOOP AT labels/fields <htmlb:GridLayoutCell …> output "label" string </htmlb:GridLayoutCell> <htmlb:GridLayoutCell …> output "inputfield" string </htmlb:GridLayoutCell> ENDLOOP. * <htmlb:gridLayout> DATA: gridLayout TYPE REF TO CL_HTMLB_GRIDLAYOUT. * Output all cells. gridLayout->cellSpacing = '0'. gridLayout->rowSize = lines( labels ). CREATE OBJECT gridLayout. The coding is as follows: method IF_BSP_ELEMENT~DO_AT_END .. gridLayout->cellPadding = '2'.. There then follows a LOOP. * </htmlb:gridLayout> m_page_context->ELEMENT_PROCESS( element = gridLayout ). in which all of the calls are executed. m_page_context->ELEMENT_PROCESS( element = gridLayout ). As a result. the most interesting point is that tags must be processed with bodies. gridLayout->width = '100%'.

The coding is therefore split into three steps. It is important that GET_OUT() is called each time an element is processed. all of the new output is written to the parent writer of the gridLayout. The method PROCESS_ELEMENT is aligned with element processing. It is therefore important that the new active writer is always received after a PROCESS_ELEMENT call and before the new output. For the <htmlb:label> string. In this case. after every write/processing cycle the system should check explicitly whether the element has finished. CREATE OBJECT gridLayoutCell. In theory. the body can be transferred as a parameter of the PROCESS_ELEMENT method. even the BSP framework can add its own writer to the stack from time to time. Every element can push additional writers on the stack. out = me->m_page_context->GET_OUT( ). the current body (the HTML string that was previously collected) must be written to the output stream. m_page_context->ELEMENT_PROCESS( element = gridLayoutCell ). then the body is written to the current output writer. In cases where only one body must be written.endmethod. If only one single writer is received at the start of the method. gridLayoutCell->verticalAlignment = 'MIDDLE'. that is. particularly if the body is already present as a string. even if they require iteration. out->PRINT_STRING( label ). The reason for this is that for each cell. and finally the end tag is processed. PROCESS_ELEMENT can therefore be called again without any problems. First the start tag is processed. gridLayoutCell->rowIndex = sy-tabix. Processing the <htmlb:gridLayoutCell> element is slightly more complex. the element does not include iteration. * print content DATA: out TYPE REF TO IF_BSP_WRITER. * </htmlb:gridLayoutCell> m_page_context->ELEMENT_PROCESS( element = gridLayoutCell ). this is therefore probably the parent writer of the gridLayout. A writer is . the coding is as follows: * <htmlb:gridLayoutCell> for label DATA: gridLayoutCell TYPE REF TO CL_HTMLB_GRIDLAYOUTCELL. gridLayoutCell->horizontalAlignment = 'LEFT'. gridLayoutCell->columnIndex = 1. Ensure that the output writer that is currently active is not received until just before it is used.

It must be newly created each time a new element is required. Step 3: Changes to the Look and Feel After <sf:SimpleForm> is implemented. Instead of having to individually change all of the BSP elements that were already created. gridLayoutCell->verticalAlignment = 'MIDDLE'. you make changes to the look and feel. there may be requirements for visualization.not required. gridLayoutCell->horizontalAlignment = 'LEFT'. and the processing code automatically writes the body correctly and finished processing the method. causes the following task: . Ensure that the gridLayoutCell object is not reused. to: CONCATENATE '<b>' me->label '</b>' INTO label->text. the change from: label->text = me->label. The more simple coding is as follows (here string inputField is used as an example): * <htmlb:gridLayoutCell/> for inputField CREATE OBJECT gridLayoutCell. gridLayoutCell->rowIndex = sy-tabix. gridLayoutCell->columnIndex = 2. In the last step. Within the coding for <sf:SimpleFormItem>. such as in our example that all field names should be formatted in bold. you only need to make one small change to a single BSP element. This is expressly forbidden. m_page_context->ELEMENT_PROCESS( element = gridLayoutCell body = inputField ). This is the advantage of composite elements.

you remain in the same work process. Its controller-based use ensures an even clearer distinction between application logic and presentation logic in BSP applications. Intuitive and east-to-use interface for application development. The call using <bsp:call> element is more variable than adding them using INCLUDEdirective. You have the option of generating program-driven layout. Using the MVC design pattern has the following advantages: • Structuring BSP applications is simplified. which is widely used in the user interface programming field and which has proved its worth. as an extension of the previous BSP implementation model. You can structure graphical user interfaces clearly and organize them in logical units. have various advantages with more complex applications. See Using MVC for BSP.Model View Controller (MVC) Use SAP Web Application Server 6. however. • • . Previous BSP applications. since the view is cleanly separated from the controller and the model. MVC does.20 has implemented the Model View Controller (MVC) design pattern. but also considerably improves their maintenance. BSP applications without MVC. The advantage of using <bsp:goto> navigation over redirect is that there is no additional network traffic. With the call option using <bsp:call>. can still be executed without requiring any changes. Furthermore. which can have advantages for creating objects and memory space. even with complex applications. that is. • • Optimized performance due to fewer redirects. you can also distribute the user interface into components. The HTML/XML output is therefore created by program code instead of a page with scripting. since it is triggered at runtime. Navigation using the <bsp:goto> element and call using the <bsp:call> element. This not only facilitates changing BSP applications.

such as using a browser. A controller is the controlling instance in the MVC design pattern. MIME objects and themes. Functions A BSP application can consist of one or more controllers and Business Server Pages. In the BSP-MVC environment. where the central method is DO_REQUEST. Controllers A controller is the instance of a central controller class. or a view or a page fragment: Within a BSP application. as well as known elements such application classes. There is a URL for every controller that can be addressed externally. each controller is directly or indirectly derived from the same base class CL_BSP_CONTROLLER2. It carries out the following tasks: • • • It provides the data It is responsible for selecting the correct layout It triggers data initialization . it is either a page with flow logic (as before). where it also acts as the controlling mechanism.20.Integration The MVC design pattern is integrated in the BSP programming model and the Web Application Builder of the ABAP development environment (Transaction SE80) from SAP Web Application Server 6. A controller can therefore be used as the initial point of entry to a BSP application. there can be several controllers. A BSP can have different characteristics. The mapping of the URL to the controller class is determined in the BSP application. several views and several pages with flow logic.

A controller can. can be used here as the selection criteria. A controller should not work with too many views. A reference to the controller is automatically transferred. which is responsible for filling the attributes. or a reference to one (or. You can find information about the life cycle of controllers in Lifetime. and this controller can be located in a different application. the controller should jump to all views that have the same or very similar input processing. delegate processing to another controller. and the corresponding data is then queried).• • It executes input processing It creates and calls a view instance Layout selection A controller will usually call a view instance for creating the HTML / XML output. It takes on all of the tasks that were executed in the previous BSP programming model by the event handlers: It carries out initialization and request processing. There is a service method that facilitates filling the attributes. The controller can call a view that is created using a factory method. A controller can also be used to delegate control over screens to the sub-controller. The theme or the browser variant. if it is checked internally whether the user has registered as a customer. A controller has access only to views in its own application. See also Navigation If it cannot be decided until input processing which page should follow. several) model(s). in extreme cases. manages data transfer and is responsible for managing views and controlling a view’s lifetime. A controller can delegate the control for a whole screen or a screen section to one or more different sub-controllers. we recommend that you let the controller branch to different views (for example. for example. On the other hand. a controller should provide a method init_attributes. These attributes may just be data. Event handling The controller also takes care of event handling. View . since all of these requests are processed centrally. they can be set and read using generic methods. If a controller passes the control to a view. Data provision Although a controller does not have any pre-defined attributes. This can result in a complex tree structure of controllers and components can be formed (that consist of both cascading controllers as well as their corresponding views). it can – and should – set attributes to the view. However. however. Redirects from the controller or page to the controller or page can be easily implemented.

Views are very much like pages. they visualize the application data. MVC in BSP Applications For more information. refer to: Using MVC for BSP Class CL_BSP_CONTROLLER2 Navigation Lifetime BSP Component Call Options Components . the view can also access the attributes of the controller class. this controller can create a reference to a class that is used as a model. Class CL_BSP_MODEL is available for this (see also Data Connection). blocking and saving data. normal page attributes can be used. nor their own URL. When used with controllers. which are then filled by the controller. Unlike auto-page attributes. Controllers should control calling views and communicate with a model. although they do not have event handlers nor auto-page attributes. If the type of controller class is known for a view (see the Properties tab for the view). The model is responsible for carrying out the central actions of reading. Models The model is used to obtain all necessary application data from the database. You can find information about the life cycle of views in Lifetime. It represents the internal data structures and corresponds to the application class used in the remaining BSP programming model.Views are only responsible for the layout. modifying.

Example You can find an example of MVC in the system in BSP application BSP_MODEL. without making reference to the application and its user interface. which usually come from the view. As a result. The general bookshop tutorial for BSP contains a more extensive MCV tutorial: Our Online Bookshop Using MVC and HTMLB. There can be different views for a model. The view takes of visualization. such as pushbuttons. dialog boxes and so on. The model is used as an application object of the application data administration. This is how the controller determines reactions to the user input and controls processing. only the model is used to process data internally. which are usually sent by the controller. It responds to information requests about its status. you can easily split Web applications into logical units.Activities Creating a Controller Creating a View Calling a Controller Calling a View Creating Error Pages A simple Tutorial is available for your first steps with the MVC design pattern. the view queries the model. The controller interprets and monitors the data that is input by the user using the mouse and the keyboard. These three areas are formally distinguished from each other by three objects: model. or the model informs the view about possible status changes. Input data is forwarded and changes to the model data are initiated. The view handles the graphical and textual output at the interface and therefore represents the input and output data in each interface element. Furthermore. causing the model or the view later to change if necessary. as well as to statements for status changes. data model and displaying the data in the interface. To visualize the status. which can be implemented using different view pages. The view and the controller together form the user interface. menus. the following Architecture Examples are outlined: • • • • • BSP Application with Controllers and Views BSP Application with Several Views per Controller Combination of the Previous Examples Calling Controllers of Other Applications Calling Several Controllers from a View MVC Design Pattern The Model View Controller (MVC) design pattern contains a clear distinction between processing control. . In this way. The controller uses the model methods to change the internal status and then informs the view about this. view and controller.

As a result. changes to the user interface have no effect on internal data processing and the data structure. You also have the option. As a result. the layout is componentized. such as by a generating program or an XSLT processor Combination of MVC with BSP . In general. • If input processing is so complex that it should be subdivided into different methods A controller offers great flexibility. If the system cannot decide which page comes next until input processing. You can find additional information about the MVC design pattern on the Internet and in current specialist literature. Using MVC for BSP Uses All BSP applications that you created with SAP Web AS 6.Since the model does not recognize either views or the controller. especially during input processing. The previous BSP implementation model gives you the option of controlling event handling and navigation using redirects. internal data processing is detached from the user interface. • • • • If redirects using navigation can lead to performance problems (such as slow diversion) If visualization logic is fairly important. you do not need to change anything. so that you can consider converting to MVC in the following cases: • If your pages are dynamically composed of several parts (components) A controller can assemble a page from several views. however. you can display election results as a table. The MVC design pattern provides you with various advantages.10 can also be executed without MVC. since you can create and call new methods. since you can use MVC to separate the logic from the layout If the layout from a different person is being processed as the visualization logic If parts of the layout should be created by the program. a bar chart or as a pie chart. of displaying the data in different formats. we recommend that you let the controller branch to different views.

First create a controller (see Creating Controllers). Prerequisites You are in a system from SAP Web AS 6. Use the Web Application Builder in the ABAP Workbench (Transaction SE80) to create a controller object as a sub-object of your BSP application. If necessary. you can also create error pages. and then the view (see Calling Views). Next create a corresponding view (see Creating Views). The URL is automatically inserted from the name of the BSP application and the controller name.You can combine the technology of the previous implementation model for BSPs with the new MVC design pattern. You can use a controller for the initial access (see also Testing Controllers). • • • • In an application. Redirects from pages to controllers and back can take place with the help of redirect using the navigation methods. In doing so. you determine the controller name and the class name of the controller. Creating a Controller Use You create a controller to use a Model View Controller design pattern in your BSP application. Now test your controller. In the page layouts you can use the <bsp:call> element or the <bsp:goto> element to call a controller. Process • • • • • Use the top controller as a point of entry to your BSP application and its process flow.20. Then call the controller or the sub-controller (see Calling Controllers). Then a call a view from this top controller. Procedure 1. You cannot use these elements to call pages. . there may be pages with flow logic as well as controllers and views The views can only be called by the controllers.

. Procedure 1. Save and activate your class and your controller. If you create your class directly from the Web Application Builder by double-clicking on the class names. You can find additional information about these methods in CL_BSP_CONTROLLER2 and Process Flow. create the class that is derived from CL_BSP_CONTROLLER2. then the inheritance of CL_BSP_CONTROLLER2 has already been configured. Specify the layout and any attributes that may be required. Overwrite some of the methods of your class. Use the Web Application Builder in the ABAP Workbench (Transaction SE80) to create a page with the page type View as a sub-object of your BSP application.2.20. 2. 3. 3. Example You can find examples of views in BSP application ITMVC2. 4. especially DO_REQUEST. Example You can find examples of controllers in BSP application ITMVC2. In the Class Builder (Transaction SE24). Creating a View Use You create views to use the view of the Model View Controller design pattern in your BSP application. Prerequisites You are in a system from SAP Web AS 6. Save and activate your view.

Testing Controllers Use You can use a controller as an initial point of entry to your BSP application. You have successfully activated your BSP application and the controllers and views to be tested. for example. Procedure 1. The browser starts and a logon screen may be displayed. . In the BSP programming model without MVC. Prerequisites • • You are in a system from SAP Web AS 6. Calling (Sub) Controllers Use Sub-controllers can be instantiated and called by a subordinate controller (main controller) or by a view or a page. Result The selected controller is started in the browser. We recommend that a subordinate controller in method DO_INIT creates a sub-controller. sets the parameters accordingly and then calls the sub-controller from the appropriate view. 3. Log on to the system if this is necessary. Use the main controller instead in connection with the MVC design pattern.20. Click on (Test/Execute) in the application toolbar. you have always used a central page as the initial page that you called start. Place your cursor on the top controller in your BSP application. 2.htm.

Unless you specify otherwise.do‘ controller_id = 'id' ). You have the following options: o data: l_ctrl type ref to cl_bsp_controller.do' ). l_ctrl = create_controller( key = navigation_key ). Instantiate your sub-controller. set the request parameters: l_ctrl->do_initattributes( ). Calling a Controller 1. Set additional attributes: l_ctrl->set_attribute( name = name value = value ). or at least a main and a sub-controller. application_namespace and application_name are optional. 2. You have crated at least one controller for your BSP application. 1. . Create the controller instance. or o l_ctrl = create_controller( application_namespace = 'fred' application_name = 'hugo' controller_name = 'do_something. the system uses the current values. Calling (Sub) Controllers 1.20.do' controller_id = 'fld' ). Example: flightdetails ?= create_controller( controller_name = 'flightdetails. If necessary.Prerequisites • • You are in a system from SAP Web AS 6. Create your sub-controller in method DO_INIT: subcontroller = create_controller (controller_name = ‚name. You can also specify each of the controller IDs. 3. Call the request: call_controller( l_ctrl ).

Ensure that the controller_id is specified. 2. Call your sub-controller. a. You can execute the call from the controller. This makes sense in particular if the calling controller does not control a layout. There are two call options here:  data: l_ctrl type ref to cl_bsp_controller. l_ctrl = create_controller( key = navigation_key ). or  l_ctrl = create_controller( application_namespace = 'fred' application_name = 'hugo' controller_name = 'do_something.do' ). application_namespace and application_name are optional. Unless you specify otherwise, the system uses the current values.

a. You can execute the call from the view. There are three call options here, which
are all implemented using the <bsp:call> BSP element. The comp_id used here corresponds to the controller_id from create_controller.  <bsp:call comp_id = "…"/> Note that the instantiation using the controller_id must have already taken place. <bsp:call url = "…" comp_id = "…"/> A controller instance is generated if no controller is created under the comp_id. <bsp:call key = "…" comp_id = "…"/> A controller instance is generated if no controller is created under the comp_id. The key is taken from the navigation table.

1. Determine the parameter transfer. a. You can execute the parameter transfer from the controller.   sub_controller -> set_attribute (name value) To do this, use any public method of the sub-controller if you know its class. Of course, you can also set the sub-controller’s public attributes directly.

a. You can execute the parameter transfer from the view. <bsp:call> <bsp:parameter name = "…" value = "…" /> </bsp:call>

Calling a View
Prerequisites
• • You are in a system from SAP Web AS 6.20. You have created at least one view for your BSP application.

Procedure
1. Create the view instance. data: l_view type ref to if_bsp_page. l_view = create_view( key = navigation_key ). or l_view = create_view( view_name = 'next.htm' ).

Note that you can call views only from your own application. 2. Set the attributes of the view: l_view->set_attribute( name = 'model' value = my_model_instance ). or l_view->set_attribute( name = 'hugo' value = 'Hugo-Text' ). 3. Call the view layout: call_view( l_view ).

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
1. You created the page (the controller) you want to use as error page. See also: Creating Pages or Creating Controllers. 2. You cannot assign an error page to a page or a controller that itself is marked as error page. 3. 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: 2. ... 3. Select the page or the controller for your BSP application. 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.

From Pages to Controllers
With a "normal" page, the presentation is determined by the layout, whilst in the MVC design pattern, views specify the presentation. With normal BSPs, predefined event handlers are available to process events. With MVC on the other hand, events are handled by controllers.

Normal pages are different from controllers especially with regard to event handling and programming. The events of the pages can be matched with the controller methods: • • Page events and main controller methods Page events and sub-controller methods

Page events and main controller methods

A main controller handles both input and output processing, where it uses the central method DO_REQUEST to call the methods specializing in input processing: DO_HANDLE_DATA, DO_HANDLE_EVENT and DO_FINISH_INPUT. In method DO_REQUEST, input processing must be triggered using DISPATCH_INPUT. This corresponds to the processing steps in the purely pagebased BSP programming model that are executed using events OnRequest, OnInputProcessing, OnManipulation and Layout. Page events and sub-controller methods From method DO_REQUEST, the three following methods required for input processing are called: • • • DO_HANDLE_DATA DO_HANDLE_EVENT DO_FINISH_INPUT

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>

Even if the amount of data is extremely small. There is then a new browser request to the destination page. In the page does not run in a frame. the new controller or view is called to provide the content for the current request. all temporary data from previous processing is lost. You hereby determine the parameters that are passed to the controller. navigation->goto_page With goto_page. there is a redirect to the specified page (or to the controller). This means that: • • • The browser does not recognize the URL for the destination page. since it requested it itself. . the request that results from sending the form (or also from a refresh) is sent to the requesting page. both can only have elements of type <bsp:parameter>. An additional browser request is required. As a result. its URL is displayed in the address line of the browser. the browser is informed that it may request a different page. this may slow down performance with very slow networks (such as via satellite). If no target has been entered in the form of the target page. Navigation There are two options for navigating to a different URL: • • navigation->goto_page for a page or a controller <bsp:goto> element for a controller. the target page only has the task of creating the HTML (view) and does not usually have to worry about input. The calling page is responsible for this and thereby takes over the controller functionality.Insert These two elements are based on the same technology as when a controller is called by a controller. No additional browser request is required. As inner elements. which leads to increased network load. In a stateless case. This has the following effect: • • • The browser recognizes the URL for the destination page. but tries to communicate with the existing page. <bsp:goto> Element With the <bsp:goto> element. that is.

It should not store this status on the server. By default. The controller must be able to use the input to decide on its current "status" if it should display several views after each other. The id can be specified as follows: • • From a page or a view: <bsp:call/goto comp_id = "id"> From a controller or a page event: create_controller(…controller_id=‘id‘) . you cannot use bookmarks on these pages. then its lifetime is the same as that specified in the controller’s properties (Properties tab). this is easier using redirects. • • What does page_name point to? runtime->page_name always points to the externally addressed page or the controller. As a result. the context remains the same even in a stateless application and you can therefore access the data and objects that have already been created. Lifetime Controllers You determine the lifetime of components or their controllers in the usual way using the Properties tab page of the controller. the URL does not change. If the controller instance is passed with id. You get the name and URL using page->get_page_name() or page->get_page_url(). see Lifetime and Note 545847. For more information. When you use different views. You can specify the lifetime as one of the following three options in Status: • • • To page change For the duration of the request For the duration of the session The setting is usually To page change. With different URLs. otherwise the "Back" processing would not function correctly.• The work process does not change. the lifetime of controller instances is limited to the one call. Lifetime of the View that is Called The lifetime of the view that is called is limited to the call only. that is.

the view must be explicitly recreated before it is used. . view = 'main. you must explicitly recreate the view.htm' ). Their life cycle looks as follows: 1. they are destroyed after they have been called. view = create_view( view_name = 'main. They are now no longer required and therefore expire. If sub-controllers should occasionally be hidden.20 up to and including Support Package 9. In any case. The controller is only hidden. They are called. since you cannot reuse it in a controller. the controller instance is not deleted. so that they are not involved in event handling for a while. Views This section concerning the lifetime of views concerns the use of MVC in SAP Web AS 6. They are created. 3. The following provides an example of correct and incorrect coding: Use: DATA: view TYPE REF TO if_bsp_page. TYPE REF TO if_bsp_page. They are supplied with parameters. views have only a very short lifetime.The controller_id or the comp_id of the <bsp:call> element must not contain an underscore (‘_ ‘). A controller that is set to inactive in this way will not be called for input processing. 2. The underscore is reserved as a separator between controllers. Views therefore only exist for the duration of the call. 4. As a developer of BSP applications with MVC. that is. then use method CONTROLLER_SET_ACTIVE. since views cannot be reused.htm' ENDIF. Unlike controllers or pages. " or IS NOT create_view( view_name = ). NOT BOUND. The lifetime of the top-level controller ranges from the first CREATE_CONTROLLER for a subcontroller to DELETE_CONTROLLER for the sub-controller. Do not use: DATA: view IF view IS INITIAL.

call_view( page ). Add the data that is required by the view to your model class as attributes. radioButtonGroup. textEdit and tableView.DATA: view TYPE REF TO if_bsp_page. CLEAR view. Simple Model Class Data binding is important for transmitting values for output data. It is also implemented for HTMLB elements dropdownListBox. you do not need to use the Application Class. checkbox. Structures .. If you are using the MVC Design Pattern. Data Binding To make programming easier for you with the MVC design. These attributes are all from the visibility range public and can be as follows: Simple variables 1. The model class provides: The data that are used for the views. set attributes . which you can use in your own model class as a class that passes on its properties. " . Instead of the usual application class with purely page-based BSP applications. The controller has a list of all model instances.htm' ). the framework for the model of an application provides you with basic class CL_BSP_MODEL. Input conversions Information about input errors that occurred for which data A controller can instantiate a model class or even several model classes (see also Calling the Model Class Using the Controller). as a result. view = create_view( view_name = 'main. The controller assigns unique IDs to each model instance..... you should use controllers and model classes in the MVC environment. analogous to the list of sub-controllers. Data binding is particularly important with HTMLBextension elements inputField and label (see also the documentation for these elements in the system). The model class represents the data context of your application and. with the corresponding type and data Dictionary information. A model class can either be designed quite simply or it can be used with more complex application cases. receives a copy of the data (or references to the data) that are relevant for the view from the database model.

separate setter/getter methods (see the following section) are written. This may be the case. You can therefore use these methods to determine your own implementations that are important for your specific application. User input is transferred to the model class at the next request. however. if you are working with generic data or if you need special methods for setting (SET) and getting (GET) attributes. Example: A BSP application contains an input field that is implemented using HTMLB. All data contained in the ABAP Dictionary structure for the field are available. one that determines whether fixed values exist. If. This type of simple model class provides the following functionality: The controller can create a model instance and initialize the attributes. if a conversion exit for a field exists in the ABAP Dictionary. for example. since they are public attributes. for example) are automatically executed by the base model class. the conversion exit can be switched off. The data binding to the model is specified in the view for each view element using a path expression (//. In these types of applications. the base class contains copy templates for the setter and getter methods: _SET_<attribute>and _GET_<attribute> . Data conversions including connection to the Dictionary (conversion exists. The content of the attribute is assigned to the input field value using the above statement. Complex Model Class It is possible that simple model classes are not sufficient for your requirements. for example. this conversion exit is called. Additional attributes are also generated. 5..). 4. 3. The naming conventions for the actual methods are as follows: Naming convention for setter methods: . Tables In the most simple case. model is defined as a page attribute. This generates the ID from the model. in which users can write data. In the default case.. If necessary you can also add your own methods to your model class for further processing attributes.2. 2. All of these templates begin with _. the model class has these attributes only and so can easily be used for data binding as part of a BSP application. The controller transmits a reference to the model instance to the view. The process flow is now as follows: 1. For the input field you can then write: <htmlb inputField … value=”//model/<Attribut>” This ensures that the content of value is bound to the corresponding attribute of the model class.

it is used automatically.<field name>” Table attribute value=”//<table name>[<line index]. assign component of structure flight to <l_comp>. translate value to lower case. field-symbols: <l_comp> type any. endif.SET_<attribute> for a field SET_S_<attribute> for a structure SET_T_<attribute> for a table 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 . value = <l_comp>. In method DO_HANDLE_DATA (see also Process Flow) of class CL_BSP_CONTROLLER2 all controllers automatically fill the form fields with data. If the structure component component points to a single flight connection (CONNID). 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>. then some of the introductory zeros may be deleted. the name of the airline is translated in lowercase. As soon as a setter or a getter method is set. The path specifications for the model data have the following syntax: Simple field attribute value=”//<field name>” Structure attribute value=”//<structure name>. Data binding is automatically available because the name is the same. if component eq 'CARRID'. endmethod. The value of <l_comp> is output as follows: If the structure component component points to an airline (CARRID).<field name>” Calling the Model Class by the Controller Uses . endif. shift value left deleting leading '0'. if component eq 'CONNID'.

20. Prerequisites You are in SAP Web AS 6. Components Use Complex BSP applications that are based on the MVC Design Pattern have many extensive components. Functions A component consists of a controller. whose class is derived from CL_BSP_CONTROLLER2. These reusable modules are: • • • Controllers One or more views A Model Together they form a component. which is identified by the model_id. Each individual part. a controller can hold one or several model classes (or instances). Components are only available for stateful BSP applications.A model class is called or managed by a controller. There are also methods for passing incoming data on to the correct model instance. contains precise application logic and well thought out presentation logic. Integration The use of components is integrated in the MVC design pattern. as well as one or more views. getting. It makes sense to create the individual BSP components as reusable modules. that is. consisting of a complex BSP application. The controller class provides methods for creating. setting and deleting this type of model class. which can result in regular nesting. This is outlines in the following graphic: .

1. It creates a controller or finds an existing one. 2. of which a page in the browser consists. 3. The controller has a hierarchical tree. are dynamically assembled during runtime. This is done by prefixing all IDs with the path of the controller IDs. • With components. Every controller controls its view or views. .Central features of components are: 1. This method is available for all controller classes. If you want to use data binding functionality. its model as well as the list of sub-controllers. It should therefore be placed in a view. For more information see Data Binding. This is done using the <bsp:call> element. The controller developer is responsible for controlling the view and the model. Basis class CL_BSP_CONTROLLER2 controls the sub-controllers. • Initialization can be called by the controller using method create_controller. • • • The parent controller contains a list of the individual sub-controllers and forwards all input to the relevant controller. • The individual parts. there are complex call sequences during an HTTP request. you can add a model class to your component. • One component can call a different component.

Service function DISPATCH_INPUT is available for this.. a. 2. Prefixes are added to the form fields. 2. 3.Activities 5. . The hierarchy itself is defined at output. 3. . This dispatches the input to the sub-controllers. 6. Then call DO_INITATTRIBUTES. Then call DO_REQUEST. First call DO_INIT. 1. 7. Process 1. 4. DO_REQUEST takes care of both input and output processing. Creating the top-level controller Creating a Component Calling the Component Determing the Input Processing Process Flow Uses The methods of class Class CL_BSP_CONTROLLER2 are used to create components as part of the Model View Controller design pattern. Input processing The browser request is sent directly to the top-level controller.. 8. DISPATCH_INPUT reads the form fields from the request and dispatches them to the sub-controller. With a main controller. The whole hierarchy level is processed with every request. 4.

a.The prefixes are written automatically for BSP elements. you have pure HTML or HTML tags. A view is created and displayed. then you must add the name of the controller as a prefix to your input data. service function GET_ID is available for adding prefixes. The process flow of the output is displayed in the following graphic: Page Output . The following methods are called:    DO_HANDLE_DATA DO_HANDLE_EVENT DO_FINISH_INPUT These three methods are called by the parent controller only with the form fields for the current controller. Depending on the status of the top-level controller. Output processing Determining output processes contains the output for the next page. If. In this case. by BSP extension HTMLB. All data that do not belong to one of the sub-components must be processed using method DISPATCH_INPUT in the main controller. for example. however. you can also set a sub-controller to inactive or create new controllers.

that is. Handling events DO_REQUEST determines whether data must be fetched from the model or from the global attributes. DO_REQUEST requests a view. The HTMBL manager collects the relevant information. DISPATCH_INPUT then calls method DO_HANDLE_DATA. for all active components).At output. ii. that is. the form fields are filled automatically. If a component contains events. The model class is filled with DO_HANDLE_DATA (see also Data Binding): The system transfers form fields and messages for the global messages object (see below). DO_REQUEST carries out the following tasks: i. DO_REQUEST fetches the table with the object keys from the top-level controller. . including the ID. DO_REQUEST calls the view. iii. v. DISPATCH_INPUT calls the HTMLB manager. DO_HANDLE_DATA is called by all controllers (that is. iv. DO_REQUEST sets the correct attributes for the view. the ID of the object that triggered the event. by the top-level controller as well as by all sub-controllers. If your model class is based on CL_BSP_MODEL and you have defined your setter and getter methods accordingly.

For example in the case of an error. this method can have data displayed again. This also states the event ID and the event is dispatched to the controller. DO_HANDLE_EVENT also has access to the global messages object and can carry out additional steps if necessary. If the event is an HTMLB event.The process flow with DO_HANDLE_DATA is displayed in the following graphic: Page Input (DO_HANDLE_DATA) Once DO_HANDLE_DATA has filled all data. Events are only dispatched to the relevant controller if the element ID was assigned to the HTMLB element (attribute id). method DO_HANDLE_EVENT is called for the controller that is responsible for the input event. DO_HANDLE_EVENT also outputs parameter GLOBAL_EVENT (a string). The process flow with DO_HANDLE_DATA is displayed in the following graphic: Page Input (DO_HANDLE_EVENT) . object HTMLB_EVENT is filled accordingly.

Note that only a sub-controller is called here. Using this global event. Method DO_FINISH_INPUT is always called (for every controller. use parameter GLOBAL_EVENT. To do this. which is set in method DO_HANDLE_EVENT. for all active components). The process flow with DO_FINISH_INPUT is displayed in the following graphic: Page Input (DO_FINISH_INPUT) . at the end of input processing each component should know exactly which events are present and how to react to them. You can use it to react to events in a component that occur in a different component. that is.

then you can forward this information to the global messages object and react to it using any component you like. then SET_ATTRIBUTE for the view. a top-level view as well as different sub-controllers and additional views. Furthermore. The main controller creates the global messages and forwards them to all sub-controllers. and so on. If the local messages object is now filled in a controller. . the messages object is local. which has the attributes PAGE and COMP_ID. A main controller first calls CREATE_VIEW. or that the end date entered by the user is before the start date. This is done using the <bsp:call> element. Use this parameter to handle incorrect user input. for example to display that an error occurred. Controllers and Their IDs Usually there is a main controller. and then CALL_VIEW. On the other hand.Global Messages Parameter GLOBAL_MESSAGES is shared by all components. The top level controller can also create sub-controllers. the embedded element <bsp:parameter> can also specify parameters for name and value.

which has a list of all the sub-controllers that belong to it. Creating Your Own Components Uses . COMPONENT_ID always identifies the controller. In method CREATE_CONTROLLER this reference is parameter COMPONENT_ID. a reference is sent to the parent controller.The attribute output takes place either in the view or in the top-level controller. Every subcontroller can query its parent controller for the COMP_ID of each additional sub-controller. and in the <bsp:call> element it is attribute COMP_ID: When a controller is created. The COMPONENT_ID has a reference to the controllers concerned.

Save your class. 2. b. then change the data for the class that passes on the properties. and a third team is responsible for developing the models. Enter a unique class name for the controller. 5. 3.You create components to use them independently as well as together with other components for BSP applications. Save your controller. Answer it with Yes. Branch to the Methods tab page. You branch to the Class Builder. Set the lifetime in the Status field to Session. for example if your class inherits properties from CL_BSP_CONTROLLER. Create a controller within this BSP application. you can also form teams. Process 1. You can create a component for a search in an online shop. 7. a. Create a BSP application and declare it as stateful. check that your class inherits properties from CL_BSP_CONTROLLER2. If this is not the case. 9. overwrite method DO_REQUEST using the icon (Redefine): . 4. a. 3. Create the top-level controller Create a component Call the component Determine the input processing Creating the Top-Level Controller Procedure 1. so that one team is responsible for developing controllers. Double-click on the controller class name. Save your BSP application. for example. In change mode. The following dialog box asks if you want to create the class. When you develop components. a different team is responsible for the views. and create an additional one for the detail display of the article that was found. 2. 4. You can find the checkbox for stateful on the Properties tab page as the ID Stateful. On the Properties tab page. 6. 8.

Create a view within your BSP application. * if any of the controllers has requested a navigation. * * * * if input is available. data: main_view type ref to if_bsp_page. the view is called main. Activate and test your finished BSP application. In order to react to user input. call_view( main_view ). endmethod. but leave current processing if is_navigation_requested( ) is not initial. c. b. Continue by Creating Components. 12. If necessary. b. overwrite methods DO_HANDLE_DATA and DO_HANDLE_EVENT. overwrite method DO_INIT. dispatch this input to subcomponent. a.htm' ). return. Activate your class. c. this call returns without any action) dispatch_input( ). In the following example. Creating Components Procedure . 11. Fill the view layout with HTML coding or HTMLB coding. this call is only necessary for top-level controllers. Save the view. 10. * do not try to display.htm. ( if this is not a top-level controller or no input is present. endif.method DO_REQUEST . * output current view main_view = create_view( view_name = 'main.

If this controller should always be used as the component controller. 2. Calling Components Use You can call a main controller. The component developers should device how these values should be set. create a public attribute or a method. These methods are called by the parent controller only with the form fields for the current controller. a. DO_HANDLE_EVENT is only called by the controller that is responsible for the input event. 2.1. By creating the sub-controller from a view . GLOBAL_MESSAGES is used to handle incorrect input. Methods DO_HANDLE_DATA and DO_FINISH_INPUT are called for all active components. Continue by Calling the Components. Overwrite methods DO_HANDLE_DATA. This controller may belong to an already existing BSP application or it can be located in its own BSP application. then change method DO_REQUEST so that only views can be displayed. By creating the sub-controller in a method of the main controller B. If not. Parameter GLOBAL_EVENT is set by method DO_HANDLE_EVENT and is used in DO_FINISH_INPUT. For every attribute that should be passed to this controller. Create a controller (including classes) in a BSP application. Note that the basic class of this controller and the top-level controller is class CL_BSP_CONTROLLER2 (see also Creating Top-Level Controllers and Views). DO_HANDLE_EVENT and/or DO_FINISH_INPUT. Activate the views. b. 1. sub-controller in two ways: A. Create one or several views. DO_REQUEST would look exactly the same as the DO_REQUEST from the top-level controller. All components share parameter GLOBAL_MESSAGES.

or .do' component_id = 'ad' ). 3. 2. add the following coding: .. Procedure Option A 1. ). * set some attributes with a self defined method addresscontroller->Init_data( .Option A is more flexible than Option B... for example.. * create the controller subcontroller ?= create_controller( controller_name = 'address.do' controller_id = 'ad' ). data: subcontroller type ref to CL_BSP_CONTROLLER2. especially if the sub-controller should be initialized once only in method DO_INIT... . * create the controller addresscontroller ?= create_controller( controller_name = 'address... data: addresscontroller type ref to CL_C_MYPROJ_ADDRESS. In method DO_INIT or DO_REQUEST. .

. 5. Call the controller in the view. In method CREATE_CONTROLLER this is the parameter COMPONENT_ID. COMPONENT_ID identifies the controller.do).do" comp_id="ad"> </bsp:call> </htmlb:tray> <htmlb:tray id = "tray2" title = "Flights" design = "form" width = "350" isCollapsed = "false" > <bsp:call url="flights.. 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.* set some attributes with standard method subcontroller->set_attributes( name = 'address' value = ship_address ). Two components are called in the above example: the address component (address. 4..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> .do) and the flight component (flights.

Determining Input Processing . which then creates and calls the controller.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> Continue by Determining Input Processing. Instead you should only add the parameters to the view call. you do not need to create the sub-controller in the coding of the main controller.Option B In this option. 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.

in the case of an error. you can specify that you want to display the data again. which is set by the event handler method. This is why it is necessary to call method DISPATCH_INPUT in the top-level controller. method DO_FINISH_INPUT is called with a global event. You can also set a global_event using method DO_HANDLE_EVENT. Handle event Method DO_HANDLE_EVENT is called for exactly one controller. The event is passed on and object htmlb_event is filled if it is an HTMLB-event. . Finish input processing For every controller. in order to determine the additional steps that are necessary. Every controller class automatically inherits all methods and attributes from this central basic class. This main controller dispatches the input to the appropriate sub-controller. If an error occurs during the data conversion. The closing input processing is carried out here. Class CL_BSP_CONTROLLER2 Overview Class CL_BSP_CONTROLLER2 is used to create controllers and components.Use The browser sends its request to the top-level controller. then this method can also pass one or more messages to the global error object (global_messages). method DO_HANDLE_DATA is called with a list of form fields that should be handled by this method. Method DO_HANDLE_EVENT has access to object global_messages. 2. 3. For example. Procedure Input processing consists of three steps: 1. depending on the error. Filling data For every controller.

The individual methods can be separated into different categories: Functions where overwriting is required DO_REQUEST is the central method in a controller class. If it is a sub-controller of a component. where the sub-controller is assigned the controller ID prefix Use models Forward data to the correct controller as well as fill model classes (if they exist) Methods Below you can find an overview of all methods in a controller class. . Class CL_BSP_CONTROLLER2 enables you to: • • • • Retain a list of sub-controllers Create unique IDs for the sub-controllers. Processing Process provides details on the most important methods. Functions where overwriting is recommended You should overwrite these methods in order to determine input processing. then this method only handles output processing. DO_REQUEST can be used in two different areas: • • If it is the top-level controller of a component. change the inheritance hierarchy accordingly. Processes data input for this component. that is. This method does the "main work". this method is called for every request. Method DO_HANDLE_DATA DO_HANDLE_EVENT Description Reacts to user input. in particular it should branch to the correct view. You must overwrite this method. then this method handles both input and output processing. In DO_REQUEST you specify the request processing.If the basic class of your controller class displays CL_BSP_CONTROLLER instead of CL_BSP_CONTROLLER2. Reacts to user input.

DO_INITATTRIBUTES This method is called with every request and is used to initialize the attributes. Functions where overwriting is possible You can overwrite these methods in order to determine input processing. DO_FINISH_INPUT Ends the input processing.Processes events if the component contains them. which contains an event such as a save button. Method DO_INIT Description This method is called once at the start and is used for initialization. Service functions You can call these methods: Method CREATE_VIEW Description Creates or fetches a view instance Use either the name of the view. you can also execute initializations that are required for each request. since you can use DO_REQUEST to solve everything that you can (theoretically) handle here. for example. Exactly one view controller is called to handle the event. This method is not absolutely necessary. The parameters are read from the request. You can also use this method to set additional attributes. . or the navigation. object A view must always belong to the same BSP application as its controller. In this method. This method behaves like a constructor method.

Creates or fetches a controller instance Calls the request handler (method DO-REQUEST) of the controller instance. you should reset the cache that may be set. Note that the server cache is not user-specific. Changes the lifetime of this page (only for the toplevel controller) Creates a formatted string Writes a formatted string in the output Fetches the current output writer Changes the MIME type of the page or the content type of the header field Instantiates the parameter from the request using the request data Changes the caching values There are two types of caching: • • Browser cache Server cache Caching BSPs. .CALL_VIEW CREATE_CONTROLLER CALL_CONTROLLER Calls the request handler of the view instance. Returns the specified page attributes. GET_ATTRIBUTE GET_LIFETIME GET_PAGE_URL SET_ATTRIBUTE SET_LIFETIME TO_STRING WRITE GET_OUT SET_MIME_TYPE INSTANTIATE_PARAMETER SET_CACHING See also You can only use limited caching here. If you change the page. Generic method for setting an attribute value. Generic method for reading an attribute value. Returns the lifetime of this page (only for the top-level controller) Returns the URL of the page or the current controller Sets the specified page attributes.

1: yes)? DELETE_MODEL FILL_MODEL_DATA DELETE_CONTROLLER GET_MODEL IS_TOPLEVEL IS_NAVIGATION_REQUESTED Framework functions These methods are provided as part of the framework and are only included here for the sake of completeness. See also Lifetime Deletes a model instance Fills the model data Deletes a sub-controller Fetches a model instance Is this controller a top (main) controller (0: no. since you can use it to hide a controller. They are not usually relevant for application development. Method IF_BSP_DISPATCHER~REGISTER Description Registers a sub-components . This method does not have any attributes. For each input. 1: yes)? Has a controller requested a navigation (0: no.DISPATCH_INPUT Dispatches the input processing (only for the top-level controller). This is relevant with input processing. DISPATCH_INPUT calls the correct methods in the correct sequence. GET_ID SET_MODEL CREATE_MODEL GET_CONTROLLER CONTROLLER_SET_ACTIVE Calculates the ID from the specified ID and the component ID Creates and registers a model instance Creates and registers a model instance Fetches a sub-controller Sets a controller to active/inactive. This method fetches data from the request.

normal BSP applications usually consisted of an application class and several BSPs. . Processes or dispatches: handling values Processes or dispatches: Handle event Finds components for a field name Finds model for a field name Methods DO_DESTROY and SUBSCRIBE are not relevant. Examples of Architecture Previous BSP Application With SAP Web AS 6. Navigation between the pages was controlled using redirects.10.IF_BSP_CONTROLLER~FINISH_INPUT_PROCESSING IF_BSP_CONTROLLER~FILL_VALUES IF_BSP_CONTROLLER~HANDLE_EVENT GET_FIELD_COMPONENT GET_FIELD_MODEL Processes or dispatches: end of input processing.

You navigate between the controllers and any pages that exist using redirect. You can use redirect to navigate between the controllers. you can combine controllers and views in a BSP application. . Each controller can have one (or several) model(s). You call the views using a call.20: BSP Application with Controllers and Views BSP Application with Controllers and Views From SAP Web AS 6.20.This is how it looks with SAP Web AS 6.

an individual controller can also call several views – either sequentially after each other or alternately. you always access it using a controller. . With this example.With several views for a controller. the whole thing looks as follows: BSP Application with Several Views per Controller BSP Application with Several Views per Controller With a BSP application with controllers and views.

Combination of the Previous Examples You can combine the examples of a BSP application with several views per controller with a BSP application with controllers and views so that each view is controlled by exactly one controller. . Central distribution is carried out by a superior controller.What does a combination of these two examples look like (this one here and BSP application with controllers and views)? Like this.

Does this also work with several BSP applications? Of course! Calling Controllers of Other Applications You can also call controllers of other BSP applications: .

several controllers are called from a view using a BSP element. these controllers provide the contents for a sub-area of the main views. A reference to the model can also be specified with the call. With help from the views that are allocated. however.Calling Several Controllers from a View With this example. at the level of the called areas (in the graphic on the right-hand side). . There can also be a page in place of the calling controller and view (in the graphic on the left-hand side). There cannot be a page.

20 system You know how to use MVC for BSPs Functions Creating a Controller .Model View Controller Tutorial Uses In this tutorial you can use a simple example to run through the first steps with the Controller design pattern for BSP. Prerequisites • • You are in an SAP Web AS 6. Model View The general bookshop tutorial for BSP contains a more extensive MCV tutorial: Our Online Bookshop Using MVC and HTMLB.

Procedure 1. On the following dialog box.Creating a View Calling a Controller Creating a Controller Prerequisites You have created an empty BSP application for this tutorial. . choose Create → Controller. 2. Create a controller within your BSP application. To do this. give the controller a name and add a short description.

assign a class name to the controller. 8. Choose the 7. the system asks you if you want to create it. Choose Yes so that you create a class with the specified name that is derived from CL_BSP_CONTROLLER2. The class does not have to exist yet. Generate the required output. it is simple HTML: . Se lect method DO_REQUEST and choose symbol to overwrite the methods. In this example. You navigate to the Class Builder by double-clicking on the controller class. 5. 6. symbol to branch to the change mode in your class. If the class does not already exist.3. On the following screen. Choose . 4. Each controller class must be derived directly or indirectly from CL_BSP_CONTROLLER2.

In Transaction SICF.Host → Activate. Activate your class and your BSP application. Result . endmethod.method DO_REQUEST . Before you can test the controller. 10. in Transaction SICF you must also activate the new entry that was automatically created for your BSP application (see also Activating and Deactivating an ICF Service). write( '</H1></body></html>' ). write( 'This is my very first controller' ). You can now test the new controller page that you have created. select the entry for your BSP application and choose Service/Virt. 11. Confirm the following confirmation prompts. 9. write( '<html><body><H1>' ).

5. then create a view that you can call from the controller.Continue by creating a view. choose Create → Page. . Procedure 9. and you want to create it as pure HTMLO layout instead. .. Creating a View Use If you do not always want to use the write function to create the HTML page content (as described in Creating a Controller).. Begin as if you are creating a normal page with flow logic in your BSP application. To do this. 1.

2. 5. Create the following attribute: 13. Choose . You cannot define auto-page attributes. 4. Define the layout as usual: <%@ page language="abap" %> <html> . In the following dialog box. 12. 3.10. Create the attributes for the variable parts of the view. since views cannot be called directly from the browser. enter a name and short description of the view and select View as the page type: 11.

. user <%= name%></H3> </body> </html> 14. Here. then you set the attributes.css"> <title> Layout for Controller </title> </head> <body class="bspBody1"> <H1>View Example</H1> <H3>Hello. 15./. Activate the view. Activate your class and test your controller. myview = create_view( view_name = 'view_test. myview->set_attribute( name = 'name' value = sy-uname ). . (For the time being you can ignore the warning concerning exception CX_STATIC_CHECK.htm' ). 7. First you create the view. and then you call the view. or you can set a try-catch block around the calls): method DO_REQUEST . adjust the DO_REQUEST method to the controller class. the schema is always the same. call_view( main_view ). data: myview type ref to if_bsp_page./sap/public/bc/bsp/styles/sapbsp. Finally. 8. 16.. 6.<head> <link rel="stylesheet" href=". endmethod. Result You have created your own view for the layout.

Create a page within your BSP application. select BSP extension bsp and drag it to the second line of your BSP’s layout under the page directive. Calling a Controller Use You can call a controller from a page with flow logic. or from a view. Ensure that you select Page with Flow Logic as the page type. 2. . Procedure 1. In the Tag Browser.Continue by Calling the Controller.

3./. Now drag the <bsp:goto> directive of BSP extension bsp to the body of the HTML layout and add the URL parameter.css"> <title> Initial page </title> </head> <body class="bspBody1"> <bsp:goto url="example. The page looks as follows: ... The source now looks as follows: <%@page language="abap"%> <%@ extension name="bsp" prefix="bsp" %> <html> <head> <link rel="stylesheet" href=". You can now activate and test the page.do"></bsp:goto> </body> </html> 4./sap/public/bc/bsp/styles/sapbsp.

. You can use View Source in the browser to see that nothing remains of the HTML text from the BSP. however./sap/public/bc/bsp/styles/sapbsp. The URL is different./. but that only the content of the view is displayed: <html> <head> <link rel="stylesheet" href=".. User GREBEL</H3> </body> .Ensure that the page you have tested looks exactly the same as when you tested the controller.css"> <title> Layout for Controller </title> </head> <body class="bspBody1"> </head> <body class="bspBody1"> <H1>View Example</H1> <H3>Hello.

retaining data using the Application Class or by Using Server-Side Cookies in a stateless application.</html> 5. or this value can be passed to the view. If you want to keep large datasets about request limits in the server (in internal tables). You can use it for example to control which view is called. The term stateless does not mean that request data for a running application is not retained on principle. This is a public class attribute. A running BSP application – regardless of whether it is HTTP stateful or stateless is referred to as a session from here on. It is set using the <bsp:parameter> element. the calling page text remains the same. otherwise these texts will be transferred twice. The start and end of a session is determined either by the user externally (compare System-Specific URL-Parameters) or by the application itself and then only the end is determined. You can now try out the difference between the <bsp:goto> element and the <bsp:call> element. 6. that is. Session Handling BSP applications can be implemented as both stateful and stateless applications. If you use the <bsp:call> element instead of the <bsp:goto> element. you should therefore delete the HTML text available on the outline page. or whether it is released following each request. You can add another attribute to the controller. which are explained in the following sections. it refers to whether in the SAP Web Application Server the application context (also called Roll Area) is retained for individual requests. Both ways have advantages and disadvantages. The following topics are dealt with: • • • • • Stateful BSP Applications Stateless BSP Applications Hybrid Forms Setting Stateful or Stateless Stateful or Stateless Programming? . this can be done either by working in stateful mode. In the view that is inserted.

scarce resources are unnecessarily blocked in the application server. this can lead to considerably better system performance compared to a procedure where identical read operations have to be executed for every request. Disadvantage This significant advantage is at the same time however a disadvantage – the improved runtime is offset by a larger memory requirement. So a user may navigate back to a Web site and the Web site sends the information again even though the application is expecting other requests. we plan to provide at least one detection mechanism. the BSP runtime uses Session Cookies to group requests into one common session. unlike SAPGUI. Since this can take some time. – independent of all user interactions . no further sessions can be started and users cannot log on. the SAP Web Application Server is not be informed. In the next release. if users navigate in their Web browsers to a different Web site. Note that with stateful applications. 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. Thus. When this space is exhausted. Multiple users/browsers can execute the same BSP application in parallel as often as required. This means that a BSP application can be executed within a browser only once at any one time. The name of the cookie is sap-contextid. Advantage The main advantage of stateful BSP applications is that they are simple to program. Measures are required in the application to deal with this.in one single context (roll area). Different BSP applications can operate in parallel in the same browser. The number of possible parallel sessions in an SAP Web Application Server is restricted not least by the amount of available memory space. Since the HTTP protocol itself operates in stateless mode and knows no implicit mechanism to assign independent requests to a common logical session.Stateful BSP Applications A stateful BSP application is executed like a normal SAP transaction. you have access to data determined previously and reading or re-calculating data can often be omitted. As usual. . Web browsers do not log off servers. A further advantage is the fact that. the application status can be easily distinguished from the status users accept based on their interface. an open session cannot be terminated and is retained in the application server until the context is released by the timeout mechanism. the validity area is restricted to the URL of the BSP application. This can be caused by users navigating in the browser history or using the browser Back button . that is. For database-intensive applications.information that is not necessarily passed on to the server.

which require the user’s confirmation. Stateless BSP Applications Stateless BSP applications only block resources on the SAP Web Application Server during the time one single request is being processed. session cookies involve no security risks and are deleted immediately the browser window is closed. When the request has been processed. if required. Some browsers now differentiate between these two cookie types and. the Web browser) until this is closed. which are usually saved on the hard disk of the client until an expiry date and session cookies. As such. which are not saved in the file system. only inform the user when persistent cookies are received. all resources in particular the application context are returned to the system for use in other requests. Integration The next version of the SAP Web Application Server will also support applications with no cookies at all.See also: Stateless BSP Applications Hybrid Forms Setting Stateful or Stateless Stateful or Stateless Programming? Session Cookie Definition A cookie is an HTTP mechanism that enables an HTTP server to store limited amounts of data in an HTTP client. There are two types of cookie: persistent cookies. . This data can then be sent back to the server for requests based on specific criteria. they are kept only in the memory of the client (for example.

• Storing Data in Client-Side Cookies: You must ensure that the size and number of cookies that can be saved in a Web client/browser is strictly limited. releasing the application context after every request may mean that identical data is read from the database and formatted multiple times.at least from the viewpoint of the memory resource – optimal scaling regardless of the number of users. in the query string part of the URL from the application. such as user entries. 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.Stateless applications allow . Rule of Thumb: Stateful or Stateless? As a rule of thumb. the runtime may offset the memory saving. This should be evaluated and analyzed on a case by case basis. You should pay particular attention to hyperlinks and to including the parameters you want to save. it is recommended that Internet scenarios used at the same time by a large number of users operate in stateless mode. for example. • Server-Side Cookies: The BSP runtime provides a generic mechanism – known as server-side cookies – that can be used to efficiently store data types of any kind and number. across multiple requests despite the loss of the application context after each request. You can easily define the attributes you want to save in the application class itself. • Application-Specific DB Table for Temporary Data Storage . The page fragment is then embedded in each Web site. Retaining Information in Stateless Mode Through Multiple Requests The question arises of how to save information in stateless applications. The application attributes from the request (we are working in stateless mode) are restored in the OnRequest event handler of the page (or preferably in the ONREQUEST method of the IF_BSP_APPLICATION interfaces. for example: <input type=hidden name="customerID" value="4711"> You can include hidden fields by implementing a page fragment. For this purpose. you must program the following functions for the application. In this respect. Possible technical solutions include the following options: • Temporary (Invisible) Storage of Data on the Web Site Itself: This can be done by means of what are called HTML hidden fields. For more information see Class CL_BSP_SERVER_SIDE_COOKIE as well as Data Persistency With Server-Side Cookies. On the other hand. which is embedded in each page of the application.

especially page attributes. 300 cookies in total.The application provides a database table specially designed to meet the specific requirements of the data to be saved. The session ID can be used to identify an entry and can be accessed through the programming interface IF_BSP_RUNTIME. Unlike server-side cookies appropriate typed tables can be used here. delete and manage cookies in the server. release of the database entry). this solution involves considerable application programming (in particular. . Class CL_BSP_SERVER_SIDE_COOKIE provides methods to set. Whereas the size of cookies on the client is restricted to four kilobytes per cookie. Server-side cookies consist of large datasets that are customized and stored on the server. similar to the usual client-side cookies. server-side cookies do not have any size or quantity restrictions. and 30 per server or domain. • Server-side cookies are persistent data. They are not transferred between client and server. However. These tables can provide for better performance than the generic solution. To do this you use simple ABAP statements in the event handlers OnManipulation and OnRequest. combined with methods of the class for server-side cookies: • Using export you can store the data (strings) as a cluster in database tables and you can transfer them back again using import. fetch. See also: Stateful BSP Applications Session Cookie Hybrid Forms Setting Stateful or Stateless Stateful or Stateless Programming? Server-Side Cookies and Data Persistency Use You can use server-side cookies to make data persistent.

They are displayed in a table on the interface. The list of page attributes looks like: Page Attributes Attribute Name LAST_STRING_ADDED NEXT_STRING STRINGS x Auto Typing Type type type type Reference Type STRING STRING STRING_TABLE Description Last string added by user Next string Table of strings Not all page attributes should be persistent. Event Handler In this BSP application the following event handlers are important: . CL_BSP_SERVER_SIDE_COOKIE->method for buffer(XSTRING).Functions In the specified event handlers you use the following ABAP expressions and class methods: • OnManipulation: o o • export (required page + controller + page attributes) to buffer XSTRING. The cookie is then stored with method SET_SERVER_COOKIE of class CL_BSP_SERVER_SIDE_COOKIE. OnRequest: o o CL_BSP_SERVER_SIDE_COOKIE->method for retrieval(XSTRING). in this BSP application only the strings LAST_STRING_ADDED and STRINGS are to be made persistent. Page Attributes This example contains some important page attributes that are to be defined as persistent. Example In the following example you can see how. in a BSP. import (required page + controller + page attributes) from buffer XSTRING. simple ABAP statements are used to group the page parameters (strings) using export in one object. Similarly the cookie can be fetched again with GET_SERVER_COOKIE and returned with import.only the strings added by users. Therefore. The steps listed here are explained in more detail in the example below.

Objectn from F to data buffer F. data: NAME type STRING.• OnRequest This event handler is always triggered with inbound requests to restore the persistent data. OnManipulation In this event handler the values of specific page attributes are saved in the server-side cookie. Next we have to make the server-side cookie XSTRING persistent: NAME = SY-UNAME. All page attributes that are relevant here are described in a byte sequence of variable length (XSTRING). The user details are written to the page data using the ABAP statement export. In this BSP we use the following code to receive XSTRING: data: PAGE_DATA type XSTRING. • OnManipulation This is the last event handler before the response is sent. export LAST_STRING_ADDED from LAST_STRING_ADDED STRINGS from STRINGS to data buffer PAGE_DATA. The export syntax is: export object1 from F . Both parameters are saved on the server and then combined in one object. OnManipulation is described first of all to explain the storage concept. A data cluster is stored in data buffer f. In this event handler the new values of the page attributes are stored in the form of server-side cookies.. . which must be of type XSTRING..

call method CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE exporting NAME = 'my_page_data' APPLICATION_NAME = RUNTIME->APPLICATION_NAME APPLICATION_NAMESPACE = RUNTIME -> APPLICATION_NAMESPACE USERNAME = NAME SESSION_ID = 'same_for_all' DATA_NAME = 'page_data' DATA_VALUE = PAGE_DATA EXPIRY_TIME_REL = 3600 . The export parameters mean: Parameters NAME APPLICATION_NAME APPLICATION_NAMESPACE USERNAME SESSION_ID DATA_NAME DATA_VALUE EXPIRY_TIME_REL Details of relative expiry time. Name and value of the data; these parameters must match. Meaning Any name can be chosen for the cookie Parameters which refer to the cookie and uniquely identify it. These are the name of the BSP application, the namespace of the BSP application, the user name and the session ID.

OnRequest

In this event handler the internal data structures of the requests are restored. The persistent page attributes are returned by the server-side cookie. So there are many parallels with the event handler OnManipulation. The server-side cookie is fetched by calling method GET_SERVER_COOKIE of class CL_BSP_SERVER_SIDE_COOKIE. The meaning of the parameters is essentially the same as for the parameters for the event handler OnManipulation (see above); only that here DATA_VALUE is a changing parameter. data: PAGE_DATA type XSTRING. data: NAME type STRING.

* User administration can, for example, use the ABAP system name NAME = SY-UNAME.

* The server-side cookie is fetched call method CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE exporting NAME = 'my_page_data' APPLICATION_NAME = RUNTIME->APPLICATION_NAME APPLICATION_NAMESPACE = RUNTIME -> APPLICATION_NAMESPACE USERNAME = NAME SESSION_ID = 'same_for_all' DATA_NAME = 'page_data' CHANGING DATA_VALUE = PAGE_DATA .

Provided that the data values do actually have values and therefore are not empty, the persistent page attributes are now restored by the server-side cookie. This is implemented by the ABAP statement import.

The syntax of import is: import Object1 = F ... Objectn = F from data buffer F. The data object (or several data objects) are imported from the specified data buffer F, which must be of type XSTRING. All data that has been stored using export ... to data buffer (see above) in the data buffer F and listed here, is imported. The system checks that the structure for export and import corresponds. In our example the call to restore the persistent cookies is: if PAGE_DATA is not initial. import LAST_STRING_ADDED = LAST_STRING_ADDED STRINGS = STRINGS from data buffer PAGE_DATA. endif.

See also:
You will find this example in the system in BSP application it00 (package SBSP_TEST) on page misc_page_persistence.htm.

Hybrid Forms
Realistically, the situation often arises in applications where neither one or the other model is the most suitable at all times. A typical example of this would be the online store, where browsing and navigating through the product catalog can very well be done in stateless mode, but where the actual ordering operation including first-time registration is, for technical reasons, very often realized in stateful mode. These scenarios are handled by switching the mode can be switched between stateful and stateless at runtime. See also: Stateful BSP Applications Stateless BSP Applications Stateful or Stateless Programming?

Setting Stateful or Stateless
You can classify a BSP application in two types – stateful or stateless:

1. During development in the development environment (transaction SE80):

You can define a BSP application as stateful by selecting the BSP application characteristic Stateful. If the checkbox is deactivated, the BSP application is working in stateless mode.

2. At runtime using the programming interface IF_BSP_RUNTIME (compare Object
Runtime): At any given time, a BSP application can be switched from stateless to stateful (and vice versa). This would make sense, for example, if you wanted to retain the roll area for a few consecutive pages but not for the whole application. You can set this by setting or deleting the attribute KEEP_CONTEXT of the IF_BSP_RUNTIME interface at runtime. The runtime definition overrides any definitions made in the development environment. See also: Stateful or Stateless Programming?

Stateful or Stateless Programming?

As described in Stateless and Stateful Model, the underlying framework supports both stateful (user context in SAP System is maintained) and stateless (user context is terminated and regenerated for every request) modes. This process is represented in the following graphic:

1. 2. 3. 4. 5. 6. 7.

The first user enters the shop. The second user enters the shop. User 1 puts a book in his or her shopping basket. The third user enters the shop. User 3 puts a book in his or her shopping basket. User 1 places his or her order. User 2 performs an action.

In stateless mode, the process looks like this:

you should weigh up the advantages and disadvantages of stateful and stateless modes.The numbers indicate which user performs each action. items in a shopping basket). as this mode avoids unnecessary use of SAP System resources. Alternatively. This is described in the section Setting Stateful or Stateless Mode. stateful mode or the use of client-side cookies is advisable. In stateless mode. When Should Stateful Mode Be Used? When developing a BSP application. It can be switched at any time to stateless by using the command RUNTIME->KEEP_CONTEXT = 0. the user context must not be kept over the entire flow logic of the BSP application. If a status needs to be maintained over a number of pages (for example. Stateless mode is more suitable for applications that do not require any status information. specified by the application class is retained (see also Application Class of BSP Application). The time progression clarifies the sequence of events. stateful mode could just be implemented for the length of time the status needs to be retained. Stateful means that the Object Application. If the application is working with stateful mode. How to Set the Mode When a BSP application is created. this mode can be set by accessing the runtime object dynamically or in the development environment for the whole BSP application. . the object is reset.

the value RUNTIME->KEEP_CONTEXT is set to 0 or 1. . On this page. page2. you can set the initial string of the application class by entering it in a HTML field. Whichever you choose. In stateless mode. which consists of only one attribute of type STRING.This is demonstrated in the example below: A Sample BSP Application A Sample BSP Application There is a sample BSP application called stateful_stateless_sample in your system (package SBSP_SAMPLES).htm. the object is re-generated on page1. On the first page. in stateless mode the string is empty (initial) again. On this page. Depending on what you choose. the string in stateful mode has the value just set. as well as 3 BSPs. Choose to second page to navigate to the next page. It contains the application class thtest.htm.htm. default.htm when the application object is accessed. you choose whether you want to work in stateful or stateless mode. The graphic below illustrates the process. the application navigates to the page page1. This is because in stateful mode the instance of the Application Object always retains its current value in the user context.

for example a BSP can consist of just the layout. or it only contains the layout. OnInitialization and OnInputProcessing. The following cases should be distinguished: • • stateless BSPs stateful BSPs See also: . Since event handler OnDestroy is used infrequently. it is irrelevant here.Control Flow of BSPs Overview The control flow of a page is displayed in the following graphic: You do not have to use all event handlers.

Input for a BSP (Stateless) . The context is always destroyed when the response is sent. processing is the same as described in the following graphic. processing is the same as described in the following graphic. Output of a BSP (Stateless) When creating the input for a page.Interface IF_BSP_PAGE Stateless In the stateless case. the context is created each time that a request is received. For the BSP runtime stateless means: runtime->keep_context = 0 When creating the output of a page.

User action can now take place. event handler OnInputProcessing is called and evaluated. which creates the page object or an instance of it.With stateless BSPs (the default is stateless). The requested page is then displayed in the browser. If a page object already exists (in general. The follows OnInitialization. Navigation Within the BSP When the page is called. If you now navigate from the OnRequest to a different page. there is no further navigation to OnInitialization. Navigating to Other BSPs The processing process is very similar to when you navigate within a BSP. Stateful In the stateful case. There then follows either OnInitialization. the system branches directly to the event handler OnRequest. the system first checks if there is already a page object for this BSP. If this is not the case. The event handler OnRequest then follows. For the BSP runtime stateful means: runtime->keep_context = 1 . and then the layout and so on. and OnInputProcessing if there is user interaction. the context is held by gone request to the next. if there is no user interaction. and then processing begins again. From OnInputProcessing. Processing continues with the layout and then possibly with OnManipulation. just as little as in stateless BSPs). the event handler OnCreate runs. although this event handler is used infrequently. the navigation can be executed either on the same page or on other pages. this does not happen with the first call.

Output of a BSP (Stateful) When creating the input for a page. processing is the same as described in the following graphic. processing is the same as described in the following graphic.When creating the output of a page. Input for a BSP (Stateful) .

Examples • • • • BSP only with Layout BSP with Layout and Initialization BSPs with Layout. that is. there can be three different variants of lifetime: • Up to the page change (lifetime_page) The page is destroyed if a different page is used. Initialization and Navigation BSPs with Layout. • For the duration of the session (lifetime_session) The page is destroyed at the end of the session. Initialization and Input Processing . is only available for the duration of each request. • For the duration of the request (lifetime_request) The page is destroyed after each individual request.With stateful BSPs.

the layout of this BSP looks as follows: <%@page language="abap"%> <html> <body> <center> <% do 5 times. %> <font size=<%=sy-index%>> Hello World! <br> </font> <% enddo. %> </center> </body> </html> See also: tutorial_1 in packet SBOOKSHOP or First Steps with the Business Server Pages… Processing Process The individual steps that are followed when processing this BSP are as follows: • • The user calls a BSP application in the browser or enters an appropriate URL. An HTTP-GET request is sent to the BSP runtime. This layout: • • • has the scripting language ABAP contains static HTML contains server-side scripting In the Web Application Builder. .BSP Only with Layout Overview This simple BSP merely consists of the layout.

This outputs the title. a page attribute and event handler OnInitialization. %> . loop at books into wbook. The BSP runtime then generates a suitable response. Since the BSP only consists of the layout.• • • • The BSP runtime determines the suitable BSP application and the BSP that is called. the page layout that is established there is determined and the scripting code is processed. publisher and ISBN of all books in the database table BSBOOK that were published in the year 2000. and sends it to the browser that displays the BSP. This BSP is as follows in the Web Application Builder: Layout <%@page language="abap"%> <html> <body> <h2> Book list </h2> <table border=1> <tr> <th>Title</th> <th>Publisher</th> <th>ISBN</th> </tr> <% data: wbook like line of books. BSP With Layout and Initialization Overview This simple BSP contains the layout.

<tr> <td><%= wbook-title %></td> <td><%= wbook-publisher %></td> <td><%= wbook-ISBN %></td> </tr> <% endloop. data is retrieved using OnInitialization. Table BSBOOK is read for those book entries that were made in the year 2000. The BSP runtime determines the suitable BSP application and the BSP that is called. . In the BSP. Page Attributes Attribute Name books automatic Typing Type TYPE Reference Type BOOK_TAB Description Booklist The internal table books of type BOOK_TAB is filled in OnInitialization. The scripting code is processed in the layout and the page is rendered: An HTML table is output and filled with content. An HTTP-GET request is sent to the BSP runtime. Processing Process The individual steps that are followed when processing this BSP are as follows: • • • • • • • The user calls a BSP application in the browser or enters an appropriate URL. The BSP runtime then generates a suitable response and sends it to the browser that displays the BSP. %> </table> </body> </html> OnInitialization select * from bsbook into table books where publyear = '2000'.

the next page displays various lists of books in table form./. Depending on the user input for the year of publication.htm" > <select name="sel_publyear"> <option value="2000"> Year 2000 <option value="2001"> Year 2001 </select> <input type="submit" value="Select"> .. Initialization and Navigation Overview This simple BSP applications contains two BSPs with layout.This example can be enhanced by adding a second BSP with navigation: BSP Application with Layout and Initialization BSPs with Layout.htm <%@page language="abap"%> <html> <head> <link rel="stylesheet" href=".. page attributes and the event handler OnInitialization. These BSPs are as follows in the Web Application Builder: Layout of startpage.css"> <title> Selection Page </title> </head> <body class="bspBody1"> Year of Publication: <form method="post" action="page2./sap/public/bc/bsp/styles/sapbsp.

</form> </body> </html> Layout of page2.htm <%@page language="abap"%> <html> <body> <h2> Book list </h2> <table border=1> <tr> <th>Title</th> <th>Publisher</th> <th>ISBN</th> </tr> <% data: wbook like line of books. %> </table> </body> . loop at books into wbook. %> <tr> <td><%= wbook-title %></td> <td><%= wbook-publisher %></td> <td><%= wbook-ISBN %></td> </tr> <% endloop.

htm. . This POST request requests a different page. An HTTP-POST request is now sent to the BSP runtime. since this page only has layout. The BSP runtime then generates a suitable response and sends it to the browser that displays the BSP. page2. year = request->get_form_field( 'sel_publyear' ). Event handler OnInitialization is assessed by this second page. The layout is assessed.htm data: year type int.htm. select * from bsbook into table books where publyear = year. The scripting code is processed in the layout and the page is rendered: An HTML table is output and filled with content. The BSP runtime determines the suitable BSP application and the BSP that is called: startpage. An HTTP-GET request is sent to the BSP runtime. Table BSBOOK is read for those book entries that were published in the year specified by the user. In the pulldown menu. The BSP runtime generates the page and sends it to be displayed at the browser. the user selects the required year of publication and selects the pushbutton.htm Attribute Name books automatic Typing Type TYPE Reference Type BOOK_TAB Description Booklist The internal table books of type BOOK_TAB is filled in OnInitialization. Page Attribute of page2. Processing Process The individual steps that are followed when processing this BSP are as follows: • • • • • • • • • • • • The user calls a BSP application in the browser or enters an appropriate URL.</html> OnInitialization of page2.

Initialization and Input Processing In this example.BSPs with Layout.htm * event handler for checking and processing user input and . Overview These BSPs are as follows in the Web Application Builder: Layout of select. Furthermore there is also user input.htm <%@ page language="abap" %> <html> <body> <h2> Select CDs or Books! </h2> <form method="post" > <select name="sel_category"> <option value="0001"> Books <option value="0002"> CDs </select> <input type="submit" name="OnInputProcessing(select)" value="Select"> </form> </body> </html> OnInputProcessing of select. there is a CD page as well as a book page. The CD page should be aligned with the distribution of CDs. which outputs the book page or the CD page depending on the category that was selected on the selection page.

endcase.htm <%@ page language="abap" %> <html> <body> <h2> All books </h2> . navigation->goto_page( 'cds.htm' ). elseif cat = '0002'. cat = request->get_form_field( 'sel_category' ).* for defining navigation data: cat type string. when 'select'. endif.htm' ). case event_id. if cat = '0001'. navigation->goto_page( 'books. Layout of books.

. %> <tr> <td><img src=".jpg"></td> <td><%= wbook-title %></td> <td><%= wbook-author %></td> <td><%= wbook-publisher %></td> <td><%= wbook-id %></td> </tr> <% endloop. %> </table> </body> </html> OnInitialization of books.htm select * from bsparticle into table books where category = '0001'../bookstore2/<%=wbook-category%><%=wbook-id %>_s./.cds .<table border=1> <tr> <th></th> <th>Title</th> <th>Author</th> <th>Publisher</th> <th>ISBN</th> </tr> <% data: wbook like line of books. loop at books into wbook.

htm Attribute Name books Layout of cds. loop at cds into wcd.htm <%@ page language="abap" %> <html> <body> automatic Typing Type TYPE Reference Type TARTICLE Description list of books <h2> All CDs </h2> <table border=1> <tr> <th></th> <th>Title</th> <th>by</th> <th>Label</th> <th>number</th> </tr> <% data: wcd like line of cds.jpg" border=1></td> <td><%= wcd-title %></td> <td><%= wcd-author %></td> ..Page Attribute of books. %> <tr> <td><img src="./bookstore2/<%=wcd-category%><%=wcd-id%>_s../.

Page Attribute of cds. The ICM server cache provides a dynamic and active content caching technology. resulting in the following advantages for developing BSPs: • • The resources required for creating BSPs are reduced You do not have to repeatedly execute BSPs that are frequently requested .htm select * from bsparticle into table cds where category = '0002'.htm Attribute Name cds automatic Typing Type TYPE Reference Type TARTICLE Description list of cds Caching BSPs Use With the Internet Server Cache (see also ICM Server-Cache) you can considerably increase the performance and scalability of your BSP application.<td><%= wcd-publisher %></td> <td><%= wcd-author %></td> </tr> <% endloop. %> </table> </body> </html> OnInitialization of cds.

note that all of the elements used by the page must not be browser-dependent. you can set the following properties for caching on the Properties tab page: o o o • Expiry date for caching in the Internet server cache Expiry date for caching in the browser (client-side) Flag whether page caching should be browser-dependent Internet Server In your BSP application you can control the behavior of the ICM server cache using response object method calls. You have the following options to control BSP caching: • In the Web Application Builder (Transaction SE80). If you do not set the flag. If you do not enter any data. This algorithm is particularly suitable for long Web URLs as cache keys. a patented indexing algorithm is used to access the cache directory quickly. Performance and Scalability Benchmarking tests for cache hits in the main memory have resulted in latent response times of less than one millisecond per request. Set flag Browser Dependent if you want the ICM server cache to fetch the page from the cache only if the request comes from the same browser type. and a total run of under 3. this means that the cache is not used for the page. Furthermore.000 requests per second on a 4 CPU hardware.The possible performance improvements can be up to factor 20. Functions The features and the architecture of the ICM server cache are described in Cache. The following section describes how you should proceed. These results are based on a strong parallel and multithreaded architecture that supports simultaneous read and write accesses with versioning. Activities Setting Caching Properties in the Web Application Builder You can set the caching properties for the page on the Properties tab page of a BSP: For both the browser cache and the ICM server cache you can determine how long the page should be held in the cache. .

but also according to user input. thus ensuring cache integrity. a banner displaying stock market tickers is updated every n minutes. Setting Caching Properties Using Method Calls in the BSP You have several options here. that is. whilst a product catalog should be updated only every n days or weeks. URI path. it always returns the same page from the cache until the expiry date has passed. You can also activate caching not just for the page in general. In addition to the relative expiry date and browser-dependency. that is. Set the expiry time for an HTTP response with the methods of class CL_HTTP_RESPONSE (see also IF_HTTP_RESPONSE and IF_HTTP_REQUEST): • • SERVER_CACHE_EXPIRE_ABS SERVER_CACHE_EXPIRE_REL Use appropriate automatic expiry times. form fields and BSP application context Prefix of the name (hierarchical wildcards) E-tag.Note that when you use the browser cache. See also: . the entity tag and the unique ID that was assigned at the time of creation You can use method SERVER_CACHE_INVALIDATE_LIST() to invalidate a list of objects (internal tables). • • • • The system automatically forwards this data to other application servers. the client cannot tell when a page has changed. If you use the ICM server cache. You refresh (invalidate) objects asynchronously using the methods of class CL_HTTP_SERVER (see also IF_HTTP_SERVER): • You can use method SERVER_CACHE_INVALIDATE() to invalidate an individual object that can be identified by the following data: Complete name. If the URL is the same. For example. You should avoid too frequent invalidations. so that system-wide transfers to other application servers are avoided. you can specify a final expiry date and invalidate cache entries. by using the invalidation methods you can ensure that the page stored in the cache is upto-date.

The cache entry is invalidated every night at 18. .htm in the event handler OnInitialization: * cache result page in case Plattner's books are searched if 'PLATTNER' cp author. you need some knowledge of following: • • • Page-based programming model HTML Work method of graphical Web design tools Do you have to choose one or the other option? The SAP Web Application Server provides a number of design options for the BSP layout. This function may be useful for things that must be recalculated every day (such as current prices). See also: Further Developing the Online Bookshop Page Layout Prerequisites Before you can choose from the various options available for the layout of your BSP application. The result list for querying the books from Hasso Plattner is only stored in the cache because you know that these are requested especially often.Manipulating Cache Properties Example You can find a simple example in the system in BSP application TUTORIAL_4. endif.00. BSP results. response->server_cache_expire_abs( expires_abs_time = '180000' browser_dependent = 'X' ).

you should think about accessibility with BSP applications that contain tables. From SAP Web AS 6. the Web Application Builder in the development environment has a preview function so that you can check the static layout of a page at any time. you can use BSP extensions HTMLB. The SAP Web Application Server lets you check in Web pages created with such tools and directly edit such pages managed on the server. you can use the BSP extension HTML Business (HTMLB) for BSP applications. tabstrips and tree controls. buttons. such as symbols. A more elegant solution is to design a page with a design tool such as AdobeGoLive5. In particular. .The easiest option is to design a page with pure HTML. pushbuttons and so on have been assigned quick infos. you can add script to the pages.XHTMLB and PHTMLB to structure interfaces with the Tag Browser. input fields or charts into your BSPs.0. This presupposes a good knowledge of HTML and it is usually a lengthy process. Accessibility Use The Accessibility Guidelines (Section 508) established in many countries are intended to enable partially sighted users to use software interfaces.20 you can use BSP extensions as an ideal mechanism for easily integrating interface elements such as tableviews. you should flag the server-side script parts so that a designer can recognize them as such. You either use the text editor in the BSP development environment (see also the documentation on the Web Application Builder) and design the page textually. Dreamweaver 4. all texts on an interface are read out using an external tool. These three types of interface elements are not always easy for Screen Reader to read out. In particular. In the context of BSP applications. Integration When developing BSP applications. you can specify whether or not you want to follow the accessibility rules. provided that all screen elements. WebDAV is supported by the above-mentioned tools (Frontpage together with the WebFolders). Frontpage and so on. In general. This is done by means of the WebDAV access of the SAP Web Application Server (see also Using External Tools). developers of Web applications using the SAP Web Application Server are subject to no design restrictions whatever. The advantage of it is: script can be added immediately to the correct parts of the page. After check-in. Moreover. If the pages checked in to the server are edited again using the tool.0. Thus.

40 SP2. Specify the accessibility in the URL or use the corresponding parameter in the logon application: . 17.The accessibility specification is integrated in the BSP runtime: 6. 2. 18. Query the accessibility in the BSP runtime: runtime->with_accessibility( ) = 'X' Accessibility is activated. BSP extensions HTMLB.?sap-accessibility=X Defining the accessibility is also part of the new system logon for SAP Web AS 6. Note that setting this indicator does not make any statement about that application’s accessibility. XHTMLB undPHTMLB use this flag to change its rendering behavior... which can be used by BSP applications to output additional information in the HTML output stream. This option sets an internal flag in the BSP runtime. These parameters are not used after the logon. ... The indicator merely indicates that additional help is required for that application. runtime->with_accessibility( ) = '' Accessibility is not activated. 1. so that screen reader programs can better present the visual information on the screen. .