First of all do not delete any workflow template with running instances in a production system. even inactive workflow templates which had been active once should not be deleted. Well, you might say: “I don’t need this workflow any more, I have made a new template which works much better or has a completely new logic and I don’t what to be confused by the old one”.
The problem is that although the workflow system has a very good version management and every time you transfer a workflow template to your production (or QA) system a new version is automatically created, once you delete the workflow template,it doesn’t work and the system handles the workflow like it never existed. Any active workitems will be stuck (not immediately but when a user does something with them) and a restart after error will simply not work because of the missing workflow template.
What can you do to solve this if it happens? well you must create a new workflow template with the same number as the deleted one, even an empty one will do, once you transfer the workflow template, the version management will resume like this is a new version of the deleted workflow and all the old versions will now reappear.
In order to do so you need to reset the workflow number range:
Go to transaction SNRO the workflow template number range is HRSOBJECT,
Standard object type is WS, change the status of the number range,
Change the current number so the next template to be created will be with the same number of the one that was deleted.
You might want to remember the current number so you can return it to where is was after you recreated the missing workflow.
There is one more thing you need to do, although the template itself can be empty, the workflow container elements must me restored (same name, same type), since the version management doesn’t work for the container as well. this might be a bit more difficult, but you can use the older versions help you do so by
using the import/export to xml option (Workflow->import/export->Export to XML File in the workflow builder) to transfer the missing container elements back to the development system (QA->DEV).
This behavior of the system also means that it’s a bad idea to ‘only’ delete container elements of active workflows as well, since older version will stop working even if you didn’t delete the workflow template. If you did delete a container element, simply recreate it and the older versions will work again.