ECC 6.0 // Excel 2007
Hi all:
Today I found the way to resolve the problem “Excel.exe not terminate after free object” ( of my ABAP Code!! ).
First, I need to say that this is my only second ABAP program about convert internal table as excel file by using OLE2, and these 2 times, the problem “Excel.exe not terminate after free object” caused me lot of time to trace the root cause.
The first time, I learned a lot from Website – need to “free all of OLE2 objects” and then modify my ABAP program…, anyway, the problem solved and works fine. And this time, the issue happened again and I cannot resolve the problem even I free all of OLE2 objects (as I believe)…
So, I trace and trace… again and again…, finally, I found the way to resolve it, please refer to the pic. 1,
*** ABAP Code Sample : The Code added
if lo_interior-handle gt 0.
Free object lo_interior.
endif.
*** ABAP Code Sample
How I found the problem and why ??
In my program, I use a lot of “FORM” to set up different attribute of CELL… and I found that in two of FORM, the OLE2 object not released even I use the free object(local variables) in last line of the FORM…
The strange thing is before I use “free object” the structure of lo_interior is nothing/initial (Pic 2) but was ACTIVE AFTER the command free object (Pic 3)…
<<lo_interior-handle = 0 means the object is initial // lo_interior-handle = -1 after released (FREE OBJECT) // lo_interior-handle = integer means is active >>
I don’t know why this happened, and I tried to add the code
IF OLE2OBJECT-HANDLE GT 0.
Free object Ole2object.
endif.
And now, it works very well, the EXCEL.EXE terminate every time…
As I mentioned, this is only my second OLE2 ABAP program, I don’t know if this can solve your problem, especially when you think you have released all of your objects…. But do really solved mind…
pic1.
pic2
pic3.