Skip to Content

UN-DATA command for local variables

Nov 28, 2016 at 11:04 AM


avatar image


I try to follow the programming paradigm, that the lifespan of variables should be kept as short as possible. I miss an UNDATA-statement to kill a local variable after use. It should make code much better: After you are done, the variable is killed. The variable name hereby becomes available for reuse.

This looks so simple to realize. Why does it not exist? Note, that my focus is not on reducing memory, but to shorten the lifespan.

Any reply from the SAP ABAP-developers? Thank you in advance, / Ulrich

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sandra Rossi Nov 28, 2016 at 01:29 PM

If I remember well, Horst Keller said a few weeks ago that it could soon arrive (7.52?)

Show 7 Share
10 |10000 characters needed characters left characters exceeded

Huh, did I? Point me there, what it was about. For the time being the request can be fulfilled with data reference variables.

var = NEW i( 123 ).

... var->* ...

CLEAR var.

oh sorry then, but maybe you can talk to the ABAP/kernel guys :D

Didn't you talk about kind of start/end blocks within the procedures, where the declared data may only be used there, or something like that?


Hmm, no currently I'm not aware of such plans. The visibility/usability of data objects in ABAP is in fact kind of queer. You know that: statically visible behind declaration, dynamically usable in whole context. Even the new inline declarations or the LET expressions rather enhance the queerness instead of offering real local visibility. Therefore ...


Thanks for correcting me Horst :) Anyway, 7.40+ is so cool (and I'm impatient to know what comes in future releases...)


We'll be upgrading to ABAP 750 next year, yayyy!!!

I have already started my planning to use Test-seams ;-)


Did you mean that? Kinda different ...


Nope, I didn't think to “static single assignment”. Probably it was a dream and I thought it would become real :D