NOTE: While I work with ASE and SRS, I do not work with SAP applications so fwiw ...
I have no idea what 'HADR mode' is or what the SAP scripting is attempting to do, but from a purely SRS perspective a few issues that the SAP script may be running into ...
1 - primary database (PDB) was not completely cleaned up from the uninstall
1a - make sure repagent is stopped (sp_stop_rep_agent)
1b - make sure repagent is dropped/disabled (sp_config_rep_agent/disable)
1c - make sure the secondary trunc point is removed (dbcc settrunc(ltm,ignore))
2 - replicate database's (RDB) maintuser still exists
2a - drop the maint user from the replicate database (sp_dropuser)
2b - if the maint user is aliased to the dbo then drop the alias (sp_dropalias)
3 - if there are lingering elements in the repserver then things get a bit more complex
3a - if no routes into/out-of your repserver, and you're looking to rebuild the repserver from scratch, then shutdown the repserver and drop/create the RSSD
3b - if you're rebuilding the repserver from scratch and said repserver is not your ID server, then make sure the repserver (you're dropping) and all connections managed by said repserver are removed from the ID server
3c - if routes exist and/or you need to keep the RSSD up (eg, you're *not* rebuilding the repserver from scratch), then you'll need to track down and drop all leftover items (eg, subscriptions, repdefs, logical database (LDB) connections, maintusers)
3d - if keeping the RSSD and all subs/repdefs/logical-connections have dropped, then you need to make sure the PDB/RDB/LDB connections are dropped
3e - if the PDB/RDB/LDB connections have been dropped, make sure the PDB/RDB/LDBs have been dropped from the ID server