The UC4 function REMOVE_OBJECT() exists with error 4006507
To detect the return code it needs to be printed in the script with a :PRINT command:
:set &ret1# = remove_object(&objektname#)
:print &ret#
Release : 12.1,12.2, 12.3
Component : Automation Engine