Show TOC

Lifetime ManagementLocate this document in the navigation structure

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.

Caution

When you specify the lifetime of a control, it may be shorter, but never longer, than that of its container.

Note

An instance of a screen is defined as follows:

An instance is created when a screen is placed on the screen stack (for example, using call screen 100 (starting at...), or call transaction), or when it is the defined next screen in a screen sequence (whether set statically or dynamically).

An instance is destroyed when the next screen is a screen other than that of the current instance ( set screen 200 or set screen 0).

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.