Escolar Documentos
Profissional Documentos
Cultura Documentos
Uses
All BSP applications that you created with SAP Web AS 6.10 can also be executed without MVC.
In general, you do not need to change anything.
The previous BSP implementation model gives you the option of controlling event handling and
navigation using redirects.
The MVC design pattern provides you with various advantages, so that you can consider
converting to MVC in the following cases:
A controller can assemble a page from several views. As a result, the layout is
componentized.
A controller offers great flexibility, especially during input processing, since you
can create and call new methods.
If the system cannot decide which page comes next until input processing, we
recommend that you let the controller branch to different views.
• If redirects using navigation can lead to performance problems (such as slow diversion)
• If visualization logic is fairly important, 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, such as by a generating program
or an XSLT processor
• In an application, there may be pages with flow logic as well as controllers and views
• Redirects from pages to controllers and back can take place with the help of redirect
using the navigation methods.
• In the page layouts you can use the <bsp:call> element or the <bsp:goto> element
to call a controller. You cannot use these elements to call pages.
Process
• Use the top controller as a point of entry to your BSP application and its process flow.
First create a controller (see Creating Controllers).
• Then a call a view from this top controller. Next create a corresponding view (see
Creating Views).
• Now test your controller.
• Then call the controller or the sub-controller (see Calling Controllers), and then the view
(see Calling Views).
• If necessary, you can also create error pages.
Creating a Controller
Use
You create a controller to use a Model View Controller design pattern in your BSP application.
You can use a controller for the initial access (see also Testing Controllers).
Prerequisites
You are in a system from SAP Web AS 6.20.
Procedure
1. Use the Web Application Builder in the ABAP Workbench (Transaction SE80) to create a
controller object as a sub-object of your BSP application.
In doing so, you determine the controller name and the class name of the controller. The
URL is automatically inserted from the name of the BSP application and the controller
name.
2. In the Class Builder (Transaction SE24), create the class that is derived from
CL_BSP_CONTROLLER2.
If you create your class directly from the Web Application Builder by double-clicking on
the class names, then the inheritance of CL_BSP_CONTROLLER2 has already been
configured.
Example
You can find examples of controllers in BSP application ITMVC2.
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.20.
Procedure
1. 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. Specify the layout and any attributes that may be required.
3. Save and activate your view.
Example
You can find examples of views in BSP application ITMVC2.
Testing Controllers
Use
You can use a controller as an initial point of entry to your BSP application. In the BSP
programming model without MVC, you have always used a central page as the initial page that
you called start.htm, for example. Use the main controller instead in connection with the MVC
design pattern.
Prerequisites
Procedure
1. Place your cursor on the top controller in your BSP application.
2. Click on (Test/Execute) in the application toolbar.
Result
The selected controller is started in the browser.
Calling (Sub) Controllers
Use
Sub-controllers can be instantiated and called by a subordinate controller (main controller) or by a
view or a page.
Prerequisites
• You are in a system from SAP Web AS 6.20.
• You have crated at least one controller for your BSP application, or at least a main and a
sub-controller.
Calling a Controller
1. Create the controller instance. You have the following options:
or
l_ctrl->do_initattributes( ).
call_controller( l_ctrl ).
Calling (Sub) Controllers
1. Instantiate your sub-controller.
Create your sub-controller in method DO_INIT:
subcontroller = create_controller (controller_name = ‚name.do‘
controller_id = 'id' ).
Example:
flightdetails ?= create_controller( controller_name = 'flightdetails.do'
controller_id = 'fld' ).
or
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>
<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.
or
Note that you can call views only from your own application.
or
l_view->set_attribute( name = 'hugo' value = 'Hugo-Text' ).
call_view( l_view ).
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:
...
Select the page or the controller for your BSP application.
Example
The BSP application BSP_MODEL in the system contains an example of how to
implement and use an error page.