FREE is a keyword used in SAP ABAP programming.
This tutorial covers its introduction & syntax details.
FREE
FREE –
Reset to correct initial value for type,
including release of
resources
Basic form
FREE f.
Effect
Like CLEAR f ,
FREE f resets any data object f to the correct initial value for its
type.
In contrast to CLEAR , however, FREE also releases any resources
connected with the data object f . This may be relevant with internal tables,
structures with tabular components as well as table work areas (created with
TABLES ).
After FREE f , you can address the data object f again at any
time, but this may involve reallocating resources.
Note
If f is an
internal table with a header line, the FREE f statement refers to the table
body, but the CLEAR f statement refers to the header
line.
Note
Performance
The runtime required to execute the FREE
statement is about 5 msn (standardized
microseconds).
FREE – Release an area in ABAP/4
memory
Basic form
FREE MEMORY.
Addition
…
ID key
Effect
Releases an area in ABAP/4 memory previously defined
with EXPORT TO MEMORY , i.e. an additional IMPORT … FROM MEMORY sets the
return code value of SY-SUBRC to 4.
Note
FREE MEMORY deletes the
entire ABAP/4 memory , including data exported with EXPORT TO MEMORY ID key
.
Addition
… ID key
Effect
Releases only the ABAP/4 memory
for the ID key .
FREE – Release memory occupied by an
external object
Basic form
FREE OBJECT
obj.
Effect
Releases the memory needed for object obj . The object
cannot be processed afterwards.
The return code value is set as
follows:
SY-SUBRC = 0 Object was released successfully.
SY-SUBRC =
1 Error during communication with SAPGUI .
SY-SUBRC = 2 Error during function
call in SAPGUI .
The OLE function modules are only implemented in
Windows.
FREE OBJECT
Example
Release an EXCEL
object:
INCLUDE OLE2INCL.
DATA EXCEL TYPE OLE2_OBJECT.
CREATE
OBJECT EXCEL ‘Excel.Application’.
FREE OBJECT EXCEL.