Try this from %Library.Routine: 
https://docs.intersystems.com/iris20243/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25SYS&CLASSNAME=%25Library.Routine#Delete
with flag=2

classmethod Delete(rtnname As %String, flag As %String = 0, supressbackup As %Boolean = 0, nsp As %String = $namespace) as %Status

Delete the routine rtnname. If the rtnname is not fully qualified we will resolve this into a fully qualified name first and then proceed with the rest of the delete. For example if you specify 'test' and there is a 'test.mac' it will resolve to this, if there was only a 'test.obj' it will resolve the name to this. The parameter flag specifies how much to delete. The options are:

  • 0 - Delete entire routine, for a MAC routine this will delete MAC, INT, OBJ. For an INT routine it will delete INT and OBJ, for a INC routine it will only delete the INC, for a BAS routine it will delete the BAS and the OBJ code.
  • 1 - Delete just the named routine, for example for a MAC routine it will only delete the MAC and it will leave the INT and OBJ if present.
  • 2 - Delete all the source code but leave any OBJ code.