Dirty assign of cl_gui_alv_grid object is possible in ABAP?

800 Views Asked by At

The new requirement which MIGHT be easily solved by the trick mentioned in the topic needs to be verified.

Besides the dirty kind of realization the consultant said, that he allows us to use dirty assigns.

So I started, inside a BADI method, and got two dirty assigns to work properly.

One is assigning an object which has no references to GUI objects and the other assigns only a data table. Both reside in the same, other program.

Now I want to get a fieldsymbol to be assigned from one of the same program's ALV grids.

SY-SUBRC returns 0, but the fieldsymbol later on points to INITIAL. I can imagine, that this is, in terms of security, not allowed.

Anyway I just ask in here to get the confirmation or correction for my assumption.

2

There are 2 best solutions below

0
szako On

It is not related to security as far as I know. There are techniques to avoid the possibility of dirty assign, but that's another story. When defined as global the references to GUI controls still stay there as a normal, reachable, variables, but those can be initialized after some time.

Looked up the official CFW documentation for backing me up and there they write:

The lifetime of a control is regulated by the lifetime management. Lifetime management automatically destroys controls at the frontend when they are no longer needed. The application program of course also supports an explicit destruction of controls.

So that means references to GUI controls on server side can be cleaned, initialized either by the handling program explicitly or automatically by the system itself (kind of "garbage collector").

More information about controls lifetime here.

0
lichtbringer On

using dirty assigns is in general a very bad idea, as it breaks at least two principles of software design (Encapsulation and Interfacing) and therefore might damage the domains of security and robustness. For some Explanation of what can went wrong when using dirty assigns you can read this blog of me Agreements must be kept