Lifetime Management
Use
The lifetime management controls the lifetime of a custom control at the frontend. When a control reaches the end of its lifetime, the SAP system automatically destroys it at the frontend. The methods free and finalize are called by the system for the control. However, you can also destroy a control yourself by calling these methods in your program.
Features
You set the lifetime of a control when you create the control instance. There are two possible settings:
-
my_control->lifetime_imode: The control remains alive for the lifetime of the internal session (that is, until a statement such as leave program or leave to transaction). The statements set screen 0. leave screen. only destroy the internal session if no more screen instances exist (for example, created using call screen). Afterwards, method finalize is called.
-
my_control->lifetime_dynpro: The control is active as long as the dynpro instance exists, meaning it is included in the dynpro stack. Afterwards, the method free is called.
Usage of this mode automatically controls the visibility of controls. Controls appear only if the dynpro on which they were generated is active. If another dynpro is active, the controls are automatically set to invisible.
-
my_control->lifetime_default: If the control is created in a container, it inherits the lifetime of the container. If the control is not created in a container (for example, because it is a container itself), the lifetime is set to my_control->lifetime_imode.
The lifetime of a control is specified in the attribute my_control->lifetime.
You can use the method is_alive to find out if an instantiated control still exists at the frontend. The method get_living_dynpro_controls returns a list of all controls that currently exist on the frontend.