Action SAP ABAP Web Dynpro

The UI elements that contain an action are included in this category.Some of these UI elements we have already used (Button, LinkToAction).

Timed Trigger

This UI element triggers automatically and periodically an event.To specify the periodicity,we have to use its delay property. As we have mentioned above, most of the UI element properties can be bound. Hereunder, we show a table with some of the TimedTrigger properties that can be bound and the attribute type in case the property is bindable

Some of TimedTrigger UI element properties

Some of TimedTrigger UI element properties

WD component

WD component

At every 5 s, we trigger an event that uses a Function Module to generate a random number under 1,000.In context view, we create a node named COUNTER,cardinality 1...1,Singleton that has an attribute COUNTER_TT of i type.

View layout

View layout

We have used an action named TRIGGER to specify the action to be triggered after the specified delay 5.

The Function Module GENERAL_GET_RANDOM_INT has an import parameter named RANGE of i type and an exporting parameter named RANDOM of i type. This function returns the random value with 0(RANDOM)(RANGE) At runtime.

runtime fig

runtime fig

Dynamic Programming

RUNTIME CLASS: CL_WD_TIMED_TRIGGER

As we have seen,by using the wdDoModifyView( )Hook method we can dynamically create an UI element. The same properties, events and aggregations as in the View Designer are available.Hereunder,we present a table showing the correspondence between the view designer name and the runtime name, with the proper types,in case of dynamic programming of a TimedTrigger UI element .

Dynamic programming

Dynamic programming

The implementation of a dynamic TimedTrigger UI element contains the following statements.

ButtonChoice

We can use this UI element to choose among the various options offered by the menu. Hereunder, we present a list with some of the ButtonChoice properties that can be bound, and the attribute type in case the property is bindable.

Some of the ButtonChoice UI element properties

Some of the ButtonChoice UI element properties

We create aWDapplication, where we use the ButtonChoice UI element to offer to the end user a menu list with two options: power and divide.To realise these calculations, we have used the methods of the class CL_FOEV_BUILTINS.As we can see in Fig.this class has many calculation methods,from the PLUS method (that performs a simple addition) to functions,in order to obtain the Integer Part or Hyperbola Sinus.

Class CL_FOEV_BUILTINS

Class CL_FOEV_BUILTINS

The structure of the POWER method

The structure of the POWER method

This method has two importing parameters, named IM_ARG1 and IM_ARG2, and an exporting parameter, named EX_RESULT, of float type. The method DIVIDE has the same parameters.

For this scope, we create our context node named CALCULATE, with the context attributes ARG1 of f type, ARG2 of f type and RESULT of f type, required to perform the calculations and to holdthe result.The WD component structure and the view context structure are presented.

WD component structure and view context structure

WD component structure and view context structure

The View layout

The View layout

In the ButtonChoice UI element, we insert two options: menuactionitem1 and menuactionitem2.For the two created options, we set actions(divide and power), and we use the hotkey property to offer to the end user the capability to press the respective key combination to trigger the associated event handler method.

When the user interacts the first time with the ButtonChoice UI element,an action can be selected,and the Framework triggers the proper event handler method. The last selected action remains on the ButtonChoice UI element after the action has been executed. This behaviour is possible through the property repeat SelectedAction.

Some of the ButtonChoice UI element properties

Some of the ButtonChoice UI element properties

The Framework triggers the event handler method onactiondivide when the user clicks the respective choice option button or he presses the CTRL_D key combination. Listing shows the coding of this method.

As we can see, to read the context attributes ATR1 and ATR2, we use the user defined method named ATTRIBUTE_GET that has two exporting parameters.

To pass the result of the division calculation into the context attribute RESULT, we have used the user defined method ATTRIBUTE_SET that has an importing parameter

User defined method required to read the context attributes

User defined method required to read the context attributes

User defined method required to populate the RESULT attribute

User defined method required to populate the RESULT attribute

Runtime for the Divide operation

Runtime for the Divide operation

To rise to power a number (number1 risen to number2), the Framework triggers the event handler method onactionpower (Listing).

We have used the static method POWER, of the calculation class CL_FOEV_BUILTINS, to perform the number1 risen to number2 operation.To read the context attributes ATR1 and ATR2, we call the same user defined method ATTRIBUTE_ GET; to pass the calculation result, we call the method ATTRIBUTE_SET. In this example, we have caught errors that can occur, but we didn’t display their message to the user. The way we can use try. . . endtry, the way we can raise, catch and display exceptions will be detailed described.

Dynamic Programming

RUNTIME CLASS: CL_WD_BUTTON_CHOICE

Hereunder,we present a table showing the correspondence between the view designer name and the runtime name, with the proper types,in case of dynamic programming of a ButtonChoice UI element.

Dynamic programming

Dynamic programming

The implementation of a dynamic ButtonChoice UI element with one mean action item, named DIVIDE, contains the following statements:


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAP ABAP Web Dynpro Topics