Skip to Content

SAP Workflow as ABAP++ : Don’t program it, workflow it


In this blog, the second in a 73-part series, we discuss the use of SAP Workflow as an extension of ABAP: a kind of ‘ABAP++’.

/wp-content/uploads/2013/01/plus_plus_176611.jpg Plus-Plus building blocks

Workflow is often thought of as ‘simply’ a tool for collecting approvals: approve a Purchase Order, reject an employee’s leave request, etc.  It’s usually all about decisions, inboxes, agent assignment and so on.

But workflow can also serve as a rich programming tool for deftly handling complex sequences of background steps. We can in fact use it when there is no human interaction at all.

Let’s start with a real-world example from one of our recent clients, a state tax office.

Talking with the Taxman about Processing*

We all pay tax. Let’s say you appealed against a harsh assessment of your 2012 return, and the tax office reduced your tax bill by $1000. That’s called a ‘reassessment’, and while it’s great news for you, it‘s a practical burden for the tax office. A reassessment requires significant post-processing:

  • reverse any write-offs; also reset clearing, cancel interest and remove dunning locks
  • change the due dates on existing debts
  • run clearing again (and wait for it to finish)
  • adjust any existing ‘payment plan’ to use the new, reduced amount

Can you imagine a tax officer doing all that manually, and in the right order? I can’t. So we decided to automate it. The tax office liked this idea a lot, but had some strict stipulations:

  • the above tasks have to be executed _immediately_ when the reassessment is posted: not in some overnight batch job
  • a detailed audit trail of the adjustments is required, in case there is an appeal
  • if the process stops halfway (due to an error), we should be able to safely restart it
  • if the process stops due to a locking error, it should restart itself

Can you imagine a clever ABAP program doing all of this? I can’t. When do we trigger the program? Where do you keep this audit trail? What about restarts and locking errors? 

OK, maybe it could be done. But to any workflow developer, the above requirements clearly spell out the word ‘W-O-R-K-F-L-O-W’.


The Workflow Solution

What seems like an impossible set of requirements is really no problem at all, once you approach it from a workflow perspective.

  • We break the problem down into objects, events and methods (E.g. event Reassessment.Posted, method PaymentPlan->Adjust).
  • We use the workflow builder to create an intuitive flow diagram of the process steps. This diagram can also be used in early discussions with the business analyst.
  • We employ terminating events to wait for external processes to finish before proceeding.
  • We can also use complex forking logic (although not required here)

The use of SAP workflow technology then provides the following snappy features for free:

  • By raising a Reassessment.Posted event, the processing can start immediately
  • We have a detailed log of everything that happened, including the data values at the time (which are stored in the workflow containers)
  • Using GOS (Generic Object Services), users and auditors can easily find and view the processing log for any given reassessment
  • If a step halts due to a temporary locking error, workflow will automatically retry the step three times, 20 minutes apart
  • If a step halts due to an application error, we can examine the containers (even possibly adjust them) and resume the workflow from that point on. See transaction SWI2_DIAG.

Returning  to our tax office client, the above workflow was successfully implemented and now handles hundreds of reassessments a week. This saves the tax officers many hours of drudge work, and ensures that all steps are done correctly and in the right order.  Errors are very rare, especially after we sorted out a few issues with temporary error handling. 

The Results

Once they felt the power of workflow, our client embraced the idea. We now have ‘ABAP++’ workflows handling processes such as:

  • Client registration checks across multiple systems (R/3 and CRM)
  • The updating of FACTS on contract objects
  • Initiating refunds

I’m sure many other people have explored this same concept; I just haven’t seen many examples of it yet. I’d love to hear your stories..

* obscure 80’s music reference

You must be Logged on to comment or reply to a post.