Tuesday, June 10, 2008

Free Methods in Application Development Web Dynpro ABAP

As an application developer, you can create and implement your own methods for each controller. These self-defined methods are typically used to read and edit data. These methods can be called within the controller by other methods that are also implemented by the application developer. Locate the document in its SAP Library structure

This graphic is explained in the accompanying text Example

In the following example, the GET_FLIGHTS method has been implemented to read data from the back end for the current controller. This data is to be used in the second method of the same controller.

method GET_FLIGHTS .

.

.

endmethod.

method FILL_CONTEXT_NODE .

data: FLIGHTSTRUC type SPFLI.

MY_NODE type ref to IF_WD_CONTEXT_NODE.

FLIGHTSTRUC = WD_THIS->GET_FLIGHTS( ).

MY_NODE = WD_CONTEXT->GET_CHILD_NODE( ‘MY_CONTEXT_NODE’ ).

MY_NODE->BIND_STRUCTURE( NEW_ITEM = FLIGHTSTRUC ).

endmethod.

The WD_THIS reference variable is used to call the GET_FLIGHTS controller method and to pass the return value to the FLIGHTSTRUC internal variable.

In the next step, the MY_CONTEXT_NODE context node is passed to a second internal variable, MY_NODE, of the type IF_WD_CONTEXT_NODE (see above, under WD_CONTEXT).

In the last step, the FLIGHTSTRUC internal variable is bound to MY_NODE.

Parameters of Free Methods

Free methods in application development can, like event handlers, have mandatory or optional parameters. Note that the ABAP IS_SUPPLIED command is not supported for parameters in Web Dynpro ABAP.

Free Methods in the Component Interface

Each free method you created and defined for the component controller can be added to the interface of the component. To do this, you can check the Interface checkbox of the Methods tab page of the component controller in the table. Each method for which you checked the checkbox is a part of the component’s interface controller and is available for use by controllers of other components (more information: Cross-Component Programming).

No comments:

Archive