Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Explicitly destroy an object in ABAP

Former Member

Hi,

i like to destroy an Object explicitly. After the paricular statment the object must be destroyed.

if i set the reference of the object to null.when the object will be deleted? immediately or during automatic garbage collection.

Thanks and regards,

Prakash.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi,

you can use FREE.

<b>data: G_GRID TYPE REF TO CL_GUI_ALV_GRID.</b>

<b>CALL METHOD G_GRID->FREE.</b>

Regards

Vijay

6 REPLIES 6

former_member188685
Active Contributor
0 Kudos

Hi,

you can use FREE.

<b>data: G_GRID TYPE REF TO CL_GUI_ALV_GRID.</b>

<b>CALL METHOD G_GRID->FREE.</b>

Regards

Vijay

former_member188685
Active Contributor
0 Kudos

Hi,

you can do in OLE also.

INCLUDE OLE2INCL. 
DATA EXCEL TYPE OLE2_OBJECT. 
CREATE OBJECT EXCEL 'Excel.Application'. 
FREE   OBJECT EXCEL.

in OO ABAP

FREE OBJECT <b>OBJ</b> .

here OBJ is object reference to some class.

Regards

Vijya

0 Kudos

DATA EXCEL TYPE REF TO OLE2_OBJECT.

.

.*populate the reference EXCEL

.

.

FREE OBJECT EXCEL.

This is what my scenario?.i getting the syntax error for this? can you help me in this issue?.

syntax error:""EXCEL cannot be a table, a reference, a string, or contain any of these objects."

0 Kudos

Hi Prakash,

check this code(copy +paste),...

INCLUDE OLE2INCL.

DATA EXCEL TYPE OLE2_OBJECT.

CREATE OBJECT EXCEL 'Excel.Application'.

FREE OBJECT EXCEL.

Do that and check it once.

Regards

Vijay

0 Kudos

INCLUDE OLE2INCL.

<b>*DATA EXCEL <b>TYPE REF TO</b> OLE2_OBJECT.</b> "wrong

DATA EXCEL TYPE OLE2_OBJECT. "Correct

CREATE OBJECT EXCEL 'Excel.Application'.

FREE OBJECT EXCEL.

Regards

Vijay

Former Member
0 Kudos

Hi,

FREE OBJECT <Obj_Name>.

Regs,

Venkat Ramanan