Using Pushbuttons
Prerequisites
You must already have created a dynamic document and added a form to it using the add_form method.
Context
You can use pushbuttons on forms to allow the user to choose different functions from a dynamic document. When the user clicks the pushbutton, an event is triggered. You must register a handler method for this event in your ABAP program.
Procedure
-
In the declaration part of your program, declare an object reference variable with the type REF TO cl_dd_button_element.
-
In a local class in your program, write a handler method for the clicked event of class cl_dd_button_element. It does not matter whether it is a static method or an instance method. The method should contain the processing logic for what will happen when the user clicks the button.
-
Call the add_button method for the form instance with which you are currently working.
The method returns an object reference to the button, which you should assign to the reference variable you declared in step 1.
-
Use the object reference to the button to register its clicked event.
Results
When the user clicks the pushbutton on the dynamic document, your handler method will be called.