Show TOC

Class CL_BSP_CONTROLLER2Locate this document in the navigation structure

Use

Class CL_BSP_CONTROLLER2 is used to create controllers, and is used byComponents. Every controller class automatically inherits all methods and attributes from this central basic class.

Note

If the basic class of your controller class displays CL_BSP_CONTROLLER instead of CL_BSP_CONTROLLER2, change the inheritance hierarchy accordingly.

Class CL_BSP_CONTROLLER2 makes it possible to:

  • Retain a list of subcontrollers

  • Create unique IDs for the subcontrollers, where the subcontroller 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. Process Flow provides details on the most important methods.

The individual methods can be separated into different categories:

Functions where overwriting is required

DO_REQUEST is the central method in a controller class.

Caution

You must overwrite this method.

In DO_REQUEST you specify the request processing, that is, this method is called for every request. This method does the "main work"; in particular it should branch to the correct view.

DO_REQUEST can be used in two different areas:

  • If it is the top-level controller of a component, then this method handles both input and output processing.

  • If it is a sub-controller of a component, then this method only handles output processing.

Functions where overwriting is recommended

You should overwrite these methods in order to determine input processing.

Method

Description

DO_HANDLE_DATA

Reaction to user input. Processes data input for this component.

DO_HANDLE_EVENT

Reaction to user input. Processes events if the component contains them.

Exactly one view controller is called to handle the event, which contains an event such as a save button, for example.

DO_FINISH_INPUT

Ends the input processing.

Functions where overwriting is possible

You can overwrite these methods in order to determine input processing.

Method

Description

DO_INIT

This method is called once at the start and is used for initialization.

This method behaves like a constructor method.

DO_INITATTRIBUTES

This method is called with every request and is used to initialize the attributes. The parameters are read from the request. In this method, you can also execute initializations that are required for each request.

You can also use this method to set additional attributes. This method is not absolutely necessary, since you can use DO_REQUEST to solve everything that you can (theoretically) handle here.

Service functions

You can call these methods:

Method

Description

CREATE_VIEW

Creates or fetches a view instance. Use either the name of the view, or the Object Navigation.

Note

A view must always belong to the same BSP application as its controller.

CALL_VIEW

Calls the request handler of the view instance.

CREATE_CONTROLLER

Creates or fetches a controller instance.

CALL_CONTROLLER

Calls the request handler (method DO_REQUEST) of the controller instance.

GET_ATTRIBUTE

Returns the specified page attributes. Generic method for reading an attribute value.

GET_LIFETIME

Returns the lifetime of this page (only for the top-level controller).

GET_PAGE_URL

Returns the URL of the page or the current controller.

SET_ATTRIBUTE

Sets the specified page attributes. Generic method for setting an attribute value.

SET_LIFETIME

Changes the lifetime of this page (only for the top-level controller).

TO_STRING

Creates a formatted string.

WRITE

Writes a formatted string in the output.

GET_OUT

Fetches the current output writer.

SET_MIME_TYPE

Changes the MIME type of the page or the content type of the header field.

INSTANTIATE_PARAMETER

Instantiates the parameter from the request using the request data.

SET_CACHING

Changes the caching values.

There are two types of caching:

  • Broswer cache

  • Server cache

See also Caching BSPs.

Note

You can only use limited caching here.

Note that the server cache is not user-specific.

If you change the page, you should reset the cache that may be set.

DISPATCH_INPUT

Dispatches the input processing (only for the top-level controller).

For each input, DISPATCH_INPUT calls the correct methods in the correct sequence.

Note

This method does not have any attributes.

GET_ID

Calculates the ID from the specified ID and the component ID.

SET_MODEL

Creates and registers a model instance.

CREATE_MODEL

Creates and registers a model instance.

GET_CONTROLLER

Gets a subcontroller.

CONTROLLER_SET_ACTIVE

Sets a controller to active/inactive. This is relevant with input processing, since you can use it to hide a controller.

See also ‎Lifetime.

DELETE_MODEL

Deletes a model instance.

FILL_MODEL_DATA

Fills the model data.

DELETE_CONTROLLER

Deletes a subcontroller.

GET_MODEL

Gets a model instance.

IS_TOPLEVEL

Is this controller a top (main) controller (0: no, 1: yes)?

IS_NAVIGATION_REQUESTED

Has a controller requested a navigation (0: no, 1: yes)?

Framework features

These methods are provided as part of the framework and are only included here for the sake of completeness. They are not usually relevant for application development.

Method

Description

IF_BSP_DISPATCHER~REGISTER

Registers a subcomponent

IF_BSP_CONTROLLER~FINISH_INPUT_PROCESSING

Processes or dispatches: Ends the input processing.

IF_BSP_CONTROLLER~FILL_VALUES

Processes or dispatches: Handling values

IF_BSP_CONTROLLER~HANDLE_EVENT

Processes or dispatches: Handle event

GET_FIELD_COMPONENT

Finds components for a field name.

GET_FIELD_MODEL

Finds model for a field name.

Note

Methods DO_DESTROY and SUBSCRIBE are not relevant.