How to archive SAP workflows

How to archive SAP workflows

Introduction

In this, the sixth blog in a 73-part series (‘The Overworked Workflow Administrator’), I hope to definitively answer the commonly-asked question: ‘How do you archive SAP workflows?’.

As a workflow administrator, I always knew I had to eventually archive some workflows, but it never reached the top of my ‘To Do’ list. Until now: we are preparing to migrate to a new system, and need to reduce our SAP table sizes. It’s also nice to do a spring clean after 7 years of operation.

How to archive SAP workflows

Note that when I say ‘workflows’, I mean workflow instances – for example, an approval workflow for an $11,000 tax refund. A ‘workitem’ is a step in that workflow instance, which may appear in an inbox.

What does it mean to ‘archive’ a workflow?

Simply put, when you ‘archive’ a workflow, it is removed from the SAP instance and placed offline (i.e., in a file on your application server).
The workflow (and all its workitems, attachments, log history etc) is still available for read-only access, but its data disappear out of many large SAP database tables. This makes the Basis people very happy .

You archive in two separate steps: writing a workflow to an archive file, and then deleting the workflow from the SAP system.

Note that you can only archive workflows that have status COMPLETED (or CANCELLED).

Why would you want to?

You may wish to archive workflows if:

  • Your Production system has been running for a few years
  • Your critical SAP workflow tables (like SWWWIHEAD, SWNCNTP0) are growing fast, impacting performance and slowing down Basis tasks
    (like system backups)
  • You are migrating to a new system and want to reduce the amount of database table data

The business users are nervous about this ‘archiving’. What are the impacts?

I’ve been told that many archiving projects never get off the ground, because of the ‘D’ word (deletion). Business users fear that the deleted workflows – and the legal audit trails they contain – will disappear forever.

As far as I can tell, the risks are small. This procedure has been around for years, and is (presumably) used routinely by thousands of large SAP customers. You don’t ‘delete’ the workflows until after the ‘write’ process’ has completed successfully. And yes, the workflows are physically deleted from the Production system, but they live on in the archive files.

Of course, you do need to be very careful with those archive files; it now becomes the responsibility of the Basis team to keep them safe and properly backed up.

How to archive workflows

Let’s assume that general archiving has already been set up in your system, and that the necessary configuration has been done for archive object ‘WORKITEM’. (If this is not true, please follow the instructions in SAP Note 2157048. This note contains a beautifully clear document by Eddie Morris called ‘Work Item Archiving for SAP Business Workflow’).

In the example below, I am archiving all eligible (COMPLETED / CANCELLED) workflows in our Test system, which were created between 2009 and
2012. There are about 450,000 workflows to be archived

How to archive SAP workflows

Step 1: Write the Workflows to Archive

  • Transaction SWW_SARA
  • Click on the ‘Write’ button
  • Create a new variant: enter a variant name (e.g., 2009_2012) and click ‘Maintain’
  • Choose the workflows that you want to archive; for example, all those with creation dates between 2009 and 2012. Choose ‘Production Mode’ (to actually write the archive file)

How to archive SAP workflows

  • Save and return to the previous screen
  • Set up the archiving job: set the ‘Start Date’ (Immediate) and the ‘Spool Parameters’ (Send to SAP Spooler Only for now)

How to archive SAP workflows

  • Once all the lights are green, you can hit ‘Execute (F8)’.
  • Then click the green ‘Job’ button to view the progress of the archiving job in SM37.

Step 2: Confirm that archiving was successful

  • Check the SM37 job logs to make sure they completed without errors

Step 3: Delete the archived workflows from SAP

  • Transaction SWW_SARA
  • Click the ‘Delete’ button (yes, it’s safe – nothing is deleted yet!)

How to archive SAP workflows

  • Click the ‘Archive Selection’ button, and choose all the archive files written in the previous step

How to archive SAP workflows

  • Set up the deletion jobs: set the ‘Start Date’ (Immediate) and the ‘Spool Parameters’ (Send to SAP Spooler Only for now)
  • Once all the lights are green, you can hit ‘Execute (F8)’.
  • Then click the green ‘Job’ button to view the progress of the deletion jobs (one for each archive file) in SM37.

How to view the archived workflows

The archived workflows can be browsed via the ‘Read’ button in SWW_SARA. The ‘Archive Explorer’ (via the ‘Information System’) allows you to search by date, task id, and so on. You can even search by BOR object, or class instance.

How to archive SAP workflows

You can also locate the archived workflow for an individual business object via the GOS (Generic Object Services) tool. For example, if you want to view the approval workflow for a FICA refund document, just select ‘Archived Workflows’ from the GOS menu in the FPE3 (Display Document) transaction.

How to archive SAP workflows

Top Tip: Clean up your old workflows first

My very first attempt at archiving did not pick up as many workflows as I had hoped. Thousands of old items still remained in the system. This is because – as mentioned above – archiving is restricted to workflows with status CANCELLED or COMPLETED.

We found a few hundred workflows in status ERROR, as well as many thousands in status STARTED.

The ERROR workflows were old instances that ran into errors and – for whatever reason – were not restarted. It would be dangerous to revive them now(!), so we decided to logically delete them. This sets them to status CANCELLED.

The STARTED workflows were, in most cases, workflows that had completed successfully, but were waiting for the user to acknowledge the outcome (e.g., ‘Your leave has been approved’). The workflows that fit this pattern were also logically deleted.

We decided, however, that if a user had reserved a workitem, then we would not archive the parent workflow.

Leave a Reply

Your email address will not be published. Required fields are marked *