Skip to Content
Author's profile photo Paul Bakker

How to ‘logically delete’ workflows

Introduction

 

In this first blog of a 73-part series ‘The Overworked Workflow Administrator’,  I hope to give a definitive answer to the commonly-asked question: ‘How do you logically delete a workflow?’.

 

Note that when I say ‘workflow’ I mean ‘workflow instance’ – for example, a purchase approval for a certain tractor costing $120,000. A ‘workitem’ is a step in that workflow instance that may appear in an inbox.

 

What does it mean to ‘logically delete’?

 

Simply put, when you ‘logically delete’ a workflow, it is set to status ‘Logically Deleted’ (aka CANCELLED) and so are all of its incomplete child workitems. These workitems are then immediately removed from users’ inboxes, and the workflow can be archived.

 

This is quite different from physically ‘deleting’ a workflow. When you ‘delete’, the workflow disappears out of the system completely. You may occasionally want to do this in a Development or Test system (for example if the system has been flooded with test workflows), but please do not delete workflows in a Production system. It can wreck absolutely everything, as Jocelyn D. entertainingly described here.

 

Why would you want to?

 

You may want to logically delete workflows if:

  • a workflow is in error and there is no possiblity / desire to restart it
  • an external event has occurred (e.g. an employee was terminated) that makes an unfinished workflow redundant
  • multiple workflows were generated by mistake, and are embarrassingly clogging up the Manager’s inbox

 

 

How to logically delete a single workflow instance

 

If there is one piece of advice that you remember from this blog, let it be this: we logically delete top-level (WS*) workflow instances only, not (TS*) workitems.

 

When you logically delete a workflow, all of its child workitems are automatically deleted as well, so the whole workflow is finalized in one fell swoop. It gives you ‘closure’. If you foolishly decide to delete a workitem, the top-level workflow remains in status ‘In Process’ and will be a blight on your workflow statistics forever.

To logically delete a single workflow from SWIA:

  • select a line (NB select the top-level WS* tasks only!). These will have status ‘STARTED’.
  • Execute the menu item Edit > Work Item > Logically Delete
  • Refresh

 

To logically delete a single workflow from anywhere:

  • go to the current workflow log (click on the ‘scroll’ button when you’re viewing a workflow in SWI2_FREQ etc)
  • click on the first line (i.e. the top-level workflow header)
  • choose the menu item Goto > Technical Workitem Display
  • choose the menu item Edit > Change
  • click the ‘Logically Delete’ button

 

 

If you then go back into the workflow log, the workflow icon is now a faded cube. It has the status ‘Logically Deleted’, as does the last workitem.

 

How to logically delete a lot of workflows

 

The above manual procedure works fine but can get tedious after a few hours. Luckily SAP has added the ‘logically delete’ function to transaction SWIA (Process workitem as administrator) although – if you are on a SAP_BASIS release before 7.11 – it may not be visible to the naked eye.

 

SAP Note 1286336 (‘New logically delete function for mass processing’) adds the function code ADMC (Administrator Cancel) to transaction SWIA. You can check the SAP Note to see if you already have the requisite support pack; if not, you can use SNOTE to put this note in yourself.

 

So, to logically delete multiple workflows:

 

  • run transaction SWIA, selecting only top-level (WS*) workflows
  • using ‘shift’ (or ‘control’), select all the workflows that you want to delete
  • type ADMC (‘Administrator Cancel’) in the (top-left) function code box, and press ‘Enter’

 

  • click the ‘Refresh’ button

 

 

All selected items should now have the status CANCELLED (aka ‘Logically Deleted’).

 

Any questions?

 

Q: Is it possible to reverse a logical deletion if I change my mind?

A: Unfortunately not. But all the information is in the log to start a new workflow instance with the same parameters, if required.

 

Q: Is ‘logically deleting’ the same as ‘manually completing’ a workflow or workitem?

A: No, not the same at all. When you choose to ‘manually complete’ a workitem (via SWIA), you are forced to choose an outcome for the current workitem. The workflow then continues on from that point.

 

Q: What impact does deletion have on the Universal Worklist?

A: This is another reason to always choose ‘logical deletion’. If you have (say) a million rogue items in the UWL, and you physically delete the workflows, these items disappear from the UWL but will remain in the back-end SWN_NOTIF table. In contrast, if you ‘logically delete’ the workflows, the items in SWN_NOTIF are updated to status ‘L’ and will be removed by normal housekeeping (program RSWNNOTIFDEL).

 

Good luck!

Assigned tags

      51 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Susan Keohan
      Susan Keohan

      Wow, very very nice Paul!  Thanks for taking this and the next 72 blogs off of my 'to-do' list.

      Keep up the great work!

      Sue

      Author's profile photo Jocelyn Dart
      Jocelyn Dart

      Great to see you blogging Paul! Looking forward to the next 72 😉

      Author's profile photo Alexander Sperling
      Alexander Sperling

      Excellent blog and great commitment to go for 73 blogs around a workflow administrators daily sufferings. Looking forward ... 😉

      Author's profile photo Rick Bakker
      Rick Bakker

      Good job! But I would add that, depending on your version, it can be even easier to logically delete multiple workflows:

      - go to SWIA

      - select a number of top-level workflow workitems using Ctrl or Shift

      - Edit > Work Item > Logically Delete

      - Refresh

      Author's profile photo Stefano Cataldo
      Stefano Cataldo

      Thanks for your comment 🙂 . Was very helpful - even after 7 years. I'm not joking.

      Author's profile photo Anjan Paul
      Anjan Paul

      Paul, Very nice information.

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Thanks for all the encouraging comments. I was always daunted by the idea of blogging but it's actually quite fun.

      I think Rick Bakker should stop lurking and do some as well.

      If the 'sophomore syndrome' doesn't hit, I'll post the second epistle next week. 🙂

      Author's profile photo Susan Keohan
      Susan Keohan

      Paul, Sorry, but Rick Bakker is a notorious lurker!

      Looking forward to more!

      Author's profile photo Adil Bouhamidi
      Adil Bouhamidi

      Good work. Thanks
      I still have a question as I still a beginner in SAP.
      I habe more item that has the status "completed".
      How can I delete them.
      Thank you!

      Author's profile photo Florin Wach
      Florin Wach

      I like that ADMC 😉

      Author's profile photo Former Member
      Former Member

      Thanks Paul.

      Author's profile photo Former Member
      Former Member

      I did not get this memo when it came out. Makes my utility... now obsolete.

      Thanks!

      Rick

      Author's profile photo Former Member
      Former Member

      Very helpful! Thank you very much.

      Author's profile photo Praveen Nenawa
      Praveen Nenawa

      Just when I needed it .
      I wanted to stop continoue reminder mails about an approval process.
      This blog came to rescue.

      Thanx a Lot .

      Prav Kr.

      Author's profile photo Former Member
      Former Member

      Thanks Paul. Really very helpful.

      Author's profile photo Margaret A Hilsbos
      Margaret A Hilsbos

      Thanks Paul. I found this blog quite useful recently. Also this topic came up in a discussion on Linked In and I gave a link to this blog.

      I'm looking forward to the next 72 installments. 🙂

      Author's profile photo Murali Krishna
      Murali Krishna

      Thanks for sharing good information Paul.

      Regards,

      Murali.

      Author's profile photo Former Member
      Former Member

      any user exit while doing logically delete

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      I don't know, but you could add an implicit enhancement to function module SWW_WI_ADMIN_CANCEL (which is called from SWIA when logically deleting).

      cheers

      Paul

      Author's profile photo Ramakrishna Thoodi
      Ramakrishna Thoodi

      HI Paul, Thanks for sharing >>

      Author's profile photo Former Member
      Former Member

      Hi Paul Thanx for the tutorial.Is it possible to logically delete a wf from report ( calling the SWIA)? at the moment i'm justing completing programmatically one of my workitem, that completes my wf not "delete it".

      Regards.

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Andre,

        Yes, you can logically delete workflows from a program by calling the function module SAP_WAPI_ADM_WORKFLOW_CANCEL.

      cheers

      Paul

      Author's profile photo Anil Dandi
      Anil Dandi

      Thanks for the ADMC trick.

      Author's profile photo Former Member
      Former Member

      Hi Paul,

      Very helpful article.

      Thanks for sharing the knowledge.

      Regards,

      Siddhant

      Author's profile photo Cristian Gonzalez
      Cristian Gonzalez

      Thanks Paul,

      I used ADMC once a couple of years ago, but I forgot it. So, thanks for the reminder.

      Regards, Cristian

      Author's profile photo Tammy Powlas
      Tammy Powlas

      This blog just saved me a great deal of work - thank you so much.

      Author's profile photo Jürgen L
      Jürgen L

      you too? I just finished a 30 hours marathon of blood, sweat and tears

      Author's profile photo Tammy Powlas
      Tammy Powlas

      I was asked to clean up workflows from 2009 from an inbox...fortunately I stumbled on this, and it seems to work in our Q box....next will try production 🙂

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Delighted to hear that, Tammy! Huh, I think this was my first-ever blog.

      cheers

      Paul

      Author's profile photo shamsudheen k
      shamsudheen k

      Well said !!!  thanks Paul

      Author's profile photo Biman Ghosh
      Biman Ghosh

      This is a very nice article and you have explained it very nicely. Thank you Paul. 🙂

      Author's profile photo Former Member
      Former Member

      A very good document specially the "ADMC" technique . Thanks for sharing.

      Author's profile photo Nic Teunckens
      Nic Teunckens

      Was in need of such functionality. Great to see this was addressed by SAP. Thanks for this informative blog!

      Author's profile photo Former Member
      Former Member

      Ok, nice explanation, but I have one question related to this:

      we logically delete top-level (WS*) workflow instances only, not (TS*) workitems

      What about tasks like TS00008068 or TS20000051? this is not WS but it is on top level, can I logically delete it?

       

       

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Andrej: Yes, you' are right: if the workflow consists of a single TS item, then it is of course the top-level item (and is ok to logically delete).

      Author's profile photo Walter Abhishek
      Walter Abhishek

      Hi just small attempt from my side to explain the step by step process for logically deleting any workflow in SAP.

      https://thesharpturtles.wordpress.com/2017/06/17/how-to-logically-delete-any-workflowworkitem-in-sap/

      Author's profile photo Reza Ejersbo
      Reza Ejersbo

      Hello Walter,

      Thanks for information,

      When I try the first method I get a program error.

      https://answers.sap.com/questions/320432/error-when-perform-logically-delete.html

      To be sure I would like to know. If I use the second method. It works as the first one? I would like logically delete this work item.

      Br

       

      Reza

      Author's profile photo Former Member
      Former Member

      I want to  "complete manually" the workflow items but it is not available for multiple items in bulk. the system is allowing me to do one by one item individually. Pl suggest how to "complete manually" multiple items

       

      Author's profile photo Jörg Sauterleute
      Jörg Sauterleute

      maybe this SAP note could help?

      1081189 - Multiple selection in transaction SWIA (LINK

      Author's profile photo Jörg Sauterleute
      Jörg Sauterleute

      thanx for this blog, Paul ... I found it during a search for a real MASS deletion of top-level workflows and i wanted to avoid creating a report without doing a "google"

      Did anyone ever considered doing a "logical delete" as a background task (SM37)?

      My problem is that i have to delete the workflows of the last 6 month, as our external delevoper switched on the IDOC-workflow for event "INPUTSUCCESS" - well, there exist now ~150.000 workflows in status ERROR for each month!

      meanwhile we are searching for a better start-event filter, but yet there is no conclusion ... 😛

       

      Author's profile photo Rahul Joshi
      Rahul Joshi

      I am facing the same issue . I want to schedule this logical deletion

      our business case is as follows:

      Workflow item was triggered,but resulted into an error.

      Due to business criticality,  the user has already completed the business transaction, outside of the workflow, hence the workflow is now sitting in user inbox but in error status, We have thousands of workflow items like this sitting in user inbox. We wan to schedule a batch job which can look for speciic tasks and delete the jobs where the start date 180 days in past.

      There do not seem to be any standard option.

      As Paul mentioned, only a custom development seem to be way out. 🙁

       

      Thanks Paul for the nice post.

      Author's profile photo Rob Dielemans
      Rob Dielemans

      Hi,

      There shouldn't be thousands of workitems in error, you should model the workflow in such a way that errors rarely occur.

       

      Author's profile photo Rahul Joshi
      Rahul Joshi

      the workflow is already been configured in production system. This issue occurs only when the business transaction fails and the user post the transaction without using the workflow workitem.

      Over a period of time, the workitem starts accunulating and result into a sizable number.

      Ofcourse we can do a periodic logical delete, but thats going to be a manual activity. If there is any stndard job ( somehow), it would help in development errorts.....

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Using SWIA and 'ADMC', you can easily handle thousands of manual deletions  (but maybe not hundreds of thousands :-).

      That should do the job until you can fix the workflow. As Rob commented below, the completion of the task outside the workflow should trigger a terminating event, so the workflow can exit cleanly.

      It's better to spend time developing that fix, rather than building a logical deletion program. As they say in the classics, we should treat the cause, not the symptom...

      cheers
      Paul

      Author's profile photo Rahul Joshi
      Rahul Joshi

      Thanks Paul ?

      treating the underlying cause ... that is the choice.... but thanks for the suggession of investing time on rectifying the workflow than buildin gthe custom solution.:)

      Author's profile photo Rob Dielemans
      Rob Dielemans

      Hi,

      When I model business process with SAP workflow and some users are permitted to influence the process outside of workflow then I have to change my models accordingly.

      Usually every self contained process is modeled where it either expects the user to execute the workitem or a parallel branch is waiting for an event telling the workflow the step is executed outside of the workflow. You can also use terminating events on a task, which is how SAP has modeled the SAP standard PO release workflow.

      Kind regards, Rob Dielemans

      Author's profile photo Rahul Joshi
      Rahul Joshi

      Yes, this will be a way forward..... Thank you for the guidance 🙂 We will have to either 'live-with-the-thing' or invest in modifying the existing  workflow 🙂

      Than you to you for replying promptly.

      Author's profile photo Mayank Malik
      Mayank Malik

      Hello Paul,

       

      Thanks for the really nice article and the great discussion. I have a requirement to delete old Items from Inbox (over past 5 years).

      I have tried deleting the Workflow Items using SWIA – ADMC method and they do go to CANCELLED Status on the SWIA screen. However, When I go to the user’s Inbox, the executable task is still sitting there. After I click on that task, it goes into error status and upon refresh, I see that Item go away from the Inbox.

      Is there a back-end method to sync the User Inbox to Items, so I would not have to click each deleted Items to get to to disappear from the Inbox?

       

      Thanks

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Hi,

      It sounds like the workitem is 'gone', but the inbox just needs refreshing.

      I'm not sure what type of inbox you are using, or what the refresh rate is. Do a refresh manually before you start executing items. Or wait a few minutes.

      cheers
      Paul

      Author's profile photo Chi Su
      Chi Su

      Dear Paul,

      I have reference number 000001647962, the CASE_GUID is 0050569CEE411ED992D67D87589408A5, PersonID is 10353215. the Status is 'started' in table T5ASRPROCESSES.

      1. I try to find workflow item by SWI6 with ABAP clase CL_HRASR00_WF_PROCESS_OBJECT and give GUID as object key, it shows: there are no workflows that have already worked with this object type. I can't find workitem ID to cancel the workflow.

      2. For another reference number , the Status is 'started' in table T5ASRPROCESSES also. I can get work item by SWI6, but all workitems status are completed.

      My question:

      User still find the WF is 'in process' status by searching reference number. Could you please give me some suggestion, What should I do so that I can logical delete this kind of WF ?

      Thanks.

      Author's profile photo Saroj Kumar Meher
      Saroj Kumar Meher

      Hi Paul,

      When we do logical deletion, is there any possibility to update the Custom table (Uses for reporting purpose).

      Is there any exit available we can use?

       

      Thanks,

      Saroj