Start of Content Area

This graphic is explained in the accompanying text Controller: Methods  Locate the document in its SAP Library structure

You can create methods for all controller types. To do this, choose the Methods tab page.

Caution

You should always call methods with the reference variable WD_THIS.

Define the type of the method in the Method Type column.

      Method:

Individual functions of the processing logic can be encapsulated and reused.

      Event handler:

Event handlers react to events that were triggered by other controllers, and also to actions and inbound plugs of the same view. To be able to react to an external controller, a usage must first have been declared for the external controller.

      Supply function:

A method of type Supply Function is always called the first time a controller is called, and is used to provide the controller context with initial data.

Some methods are created automatically when a controller is created (see also Methods of the Local Controller Interface in the Programming Manual).

All controllers have the following two methods:

      WDDOEXIT:

Cleanup method of the controller. This method is called automatically when a controller is exited. In the case of the component controller, this method has an optional importing parameter (REASON) through which the reason for exiting the component can be passed. This parameter is only filled when there is a session timeout. If the component is exited regularly (for example, using an exit plug), the parameter is set to initial.

      WDDOINIT:

This is the initialization method of the controller. It always runs automatically the first time the controller is called.

The component controller is also equipped with the following methods:

      WDDOBEFORENAVIGATION:

Error handling before the navigation through the application.

      WDDOPOSTPROCESSING:

Handling of errors that occurred during the context validation.

A view controller automatically receives the method

      WDDOMODIFYVIEW:

Method for modifying the view before rendering.

This is the only method in which dynamically modifying the UI controls is permitted. The reference to the view and the information whether this view is displayed for the first time are passed to the method.

All methods are created and can be programmed accordingly if necessary. They are all called at a defined point (see Phase Model).

Visibility of Methods and Embedding a Method in the Interface of a Component

The visibility of methods usually extends to the visibility framework of the entire controller. The visibility of methods of the component controller can, however, be extended beyond the limits of one’s own component. If you want to make a method of a component controller available to the component interface, select the relevant checkbox in the Interface column. The Interface column is only displayed by the controller editor if you are editing a component controller.

Parameters of Methods

      Individual methods can have any parameters.

      Event handlers that react to a controller event always inherit the parameters of this event. If the parameters of an event were subsequently changed, the parameters of the event handler method can be updated using the Compare Parameters function.

If, on the other hand, an event handler reacts to an inbound plug, individual import parameters can be defined.

Event handlers of actions always have the import parameter WD_EVENT of type CL_WD_CUSTOM_EVENT.

      Like WDDOINIT, the parameters of predefined methods are similarly defined like the parameters of the supply functions.

For individual methods you can specify class-based exceptions on the interface.

 

End of Content Area