2001 ASUG Fall Conference, New Orleans

Workflow/WebFlow Track
“Where making your work flow is our business”

Testing and Debugging Workflows

Susan Keohan Massachusetts Institute of Technology October 21, 2001

My name is Susan Keohan. I am the primary workflow developer and administrator at the Massachusetts Institute of Technology. We have had workflow up and running for several applications since 1997. I am also the ‘owner’ and administrator of the SAP-WUG listserv, and the Workflow Track Leader. My experience with workflow began with implementing a Req Release workflow. Then MIT developed several types of FI release workflows, and some single step background tasks. We have used workflow as the delivery mechanism for notifying our customers that they have workitems, by sending notification emails. This is not the most sophisticated method of notifying users, but one which fit our culture and infrastructure. Since implementing our workflows, we have upgraded from 3.1 to 4.5, and from 4.5 to 4.6. I have also converted our WFs to WSs.

1

2001 ASUG Fall Conference, New Orleans

Testing and Debugging workflow can be a very challenging task. My goal here is to help you identify the tools to complete that task.

2

2001 ASUG Fall Conference, New Orleans

Testing and Debugging Workflows
• Business object builder
- Attributes - Methods

• Events
– Event linkage - Event test tools - Event check FMs, receiver type FMs

• Roles • Workflow analysis
– Diagnostic tool

My intent is to use a bottom-up approach here. I have found that one of the first things you do as a workflow developer is to look at the business object to see if it has what you need in the way of attributes and methods. In every workflow project I have worked on at MIT, I have had to add attributes or methods to extended business objects, so that seems like a good place to start. Once you have debugged your attributes and methods, (assuming you then build your workflow) you will need to know about linking it to an event (this is the most commonly used means of triggering a workflow) Then you will want to know why your workflow didn’t get to the right person. At the end of it all, there is the very powerful tool provided by SAP which allows you to perform a variety of tests from one transaction.

3

2001 ASUG Fall Conference, New Orleans

Debugging With BOB

Pick the attribute or method you need to debug, and push the ‘Program’ button to get to the ABAP code…

The Business Object Builder (as it is called in 4.6c) used to be called the Business Object Repository (BOR) and is accessed via transaction SWo1. It is from this point that you will create a subtype of an existing SAP object type, and give it your own specific attributes and methods. It is inevitable that you will need to add attributes or methods to business objects. These enhancements will reflect your organization’s view of the business object being worked on. For example, it may not be relevant to the rest of the SAP world that there is a Fund Center which can be linked to a requisition, but at MIT, we can’t live without it. It controls the entire flow of requisition release, even as far as determining which req release workflow will be called. You may find that you need to create an attribute of an object which uses the object key to derive a value from another object, or document. Or, you may have customized tables which hold values that you want in your workitem text. At any rate, once you have defined your attribute, or method, it is helpful to step through it in the BOB before you try to add it into a workflow.

4

5 . I have found it helpful to have any macro calls (SWC…) early in the code.2001 ASUG Fall Conference. and set my breakpoint after the macro call. and set the breakpoint there. New Orleans Locate the portion of your attribute or method that you want to test.

2001 ASUG Fall Conference. New Orleans Debugging With BOB Set the debugger on and use the wrench BOB comes with a test bed from which you can execute the ABAP code that underlies your attributes and methods. This turns on the ABAP debugger. After you have set your breakpoint in the ABAP code. Then. 6 . use the wrench tool to start the debugging process. go to Settings>Debugger On/Off and switch the debugger on.

7 . you will need to enter an object key for the BOB debugger. New Orleans Debugging With BOB Push ‘Instance’ From this screen. Just push ‘Instance’ and fill in the values with a document you have already created.2001 ASUG Fall Conference.

2001 ASUG Fall Conference. New Orleans Debugging With BOB After you push ‘instance’ you should get a pop-up screen where you can enter the key values for the object. 8 .

2001 ASUG Fall Conference. you will also see all the methods which are linked to that object. This enables you to quickly view whether the values are as you expected. The circling arrows icon will indicate which attributes are virtual attributes. If you scroll down on this page. New Orleans Debugging With BOB The BOB will display all the attributes for that object. The pretty green and yellow ring indicates that this attribute is also an object reference in its own right. 9 .

10 . New Orleans Debugging With BOB Just push the ‘go’ icon for the method you need Testing methods – push the go button for the method you are interested in. turned the debugger on. you would have set the breakpoint in the method code.2001 ASUG Fall Conference. Remember. and filled in the object key for an instance to be worked on. at this point.

New Orleans Debugging With BOB Don’t forget to push the Debugging Button This screen shows the input elements that are required for the method. You don’t necessarily need to fill these in. and the exceptions. don’t forget to push the debugging button again.2001 ASUG Fall Conference. but you can. 11 .

as the BOB does not have the context of the workflow to derive container values from. much as you would any other ABAP program. for instance. Simply fill these in as you go along. you can step through the code. You may need to fill in some elements manually.2001 ASUG Fall Conference. Some of them. SWC_GET_ELEMENT CONTAINER 'ReleaseCode' PRELEASECODE. Watch to see if you get a SySUBRC =8 after any macro call. From here. Will not be able to get the value. 12 . New Orleans Debugging With BOB You will be brought into the ABAP code behind the method. There are some differences though.

when getting an element from the workflow container) • You can then step through debugging the attribute or method as you would any other ABAP code • You probably want to step OVER the macro calls. New Orleans Debugging With BOB • Set a breakpoint in the code of attribute (or method). before things really get ‘interesting’ • If you have calls to macros (swc_get_element. 13 . etc) you *may* need to set the values of the result elements inside the debugger (for example. and it serves no purpose to go there. They can be mildly disturbing.2001 ASUG Fall Conference.

from the workflow to the event. You need to know how to look at the event linkage to the workflow from both sides. does not necessarily mean it will be triggered. but failed immediately. to check what happens if you know the event has been triggered but for some reason your workflow did not start. They can be used to start and end workflows and workflow tasks.2001 ASUG Fall Conference. that is. but the most commonly used is via events. and from the event to the workflow. New Orleans Debugging Events • • • • • • Event linkage in the workflow Event linkage (SWETYPV) Event creation (SWUE) Simulate event (SWU0) Check the event log (SWEL) RFC queue (SM58) There are multiple ways to trigger and control the flow of a workflow. You also need to know how to check that the event is actually being triggered (just because an event is listed. and to see if your workflow did start. 14 . It could be linked to some obscure customizing!) You will want to be able to simulate the event.

A green light to the left of the event means that your linkage is active.2001 ASUG Fall Conference. New Orleans Event Linkage in the Workflow Definition This is the event you want this workflow to start with Always check your binding to the event Go into the workflow builder (PFTC_CHG in 4.e.: it’s not green yet) you will be given some binding messages. The panel should show you all the events that your workflow is linked to. Always check your binding to the event. 15 . When you press the gray button (i. A workflow CAN be linked to more than 1 event.6c) and check the Triggering Events’ tab.

However.2001 ASUG Fall Conference. well. as well as if the linkage is active. New Orleans Event Linkage With SWETYPV The checkbox tells you this event is linked to a workflow. sort of… In SWETYPV you get to look at the event/workflow linkage from the event side. event. you cannot rely on this table alone to tell you what workflows are linked to an event. You must have GOOD DOCUMENTATION! 16 . and the receiver. You will be able to see the object.

in this case. In effect. you would need to double-click on this event to see that in reality. then it is reasonable to assume that the workflow (identified by ‘receiver’) is going to be triggered by this event. and you see the receiver FM SWW_WI_CREATE_VIA_EVENT. this is a dummy entry. there is a receiver type function module which will determine which of several workflows will be called when this event is triggered. But don’t forget to document! 17 . If you drill down on the event. New Orleans Event Linkage With SWETYPV Workflow Name Note that this is ACTIVE for example. and no receiver TYPE FM.2001 ASUG Fall Conference.

: It’s not the correct document type) • A receiver type FM can be used to dynamically determine which of a number of workflows should be called based on object attributes (much more efficient than many check FMs!) 18 .2001 ASUG Fall Conference.E. New Orleans Check FM or Receiver Type FM ? • A check function module can be used to simply abend if the object does not meet the criteria for your workflow (i.

you will have to know this. you can use the test tool SWUE to create the event. New Orleans Event Triggering With SWUE Fill in the Object Key of the object you are working with Use this flag to start the ABAP debugger You will probably need to test whether a workflow will be triggered by the event without always having to go through the business process of creating a new object instance every time. After you fill in the object key. (However. so don’t think you are getting off scot-free).2001 ASUG Fall Conference. then push the ‘Create Event’ button 19 . and click on the ‘Trigger Receiver FM Synchr’ flag. For these purposes.

20 . New Orleans Event Triggering With SWUE This screen shows you the event and the receiver when a breakpoint has not been set. It can be a quick test to see that the workflow will be triggered.2001 ASUG Fall Conference.

you will get to your breakpoint But.2001 ASUG Fall Conference. and you will have the necessary parameters and object elements to proceed with debugging your FM. then when you check ‘Trigger FM synch’. Back out and go into SWUE and fill out the prerequisite key. New Orleans Event Triggering With SWUE Set the breakpoint in your receiver FM first. if you can’t tell why your workflow is not triggered. you will need to go a little deeper. you get into your function module at your breakpoint. 21 . Remember to check ‘trigger receiver FM synchr’. Go to SE37 and set a breakpoint in the receiverFM. checkFM. or receiver type FM that is being called. When you push ‘Create Event’.

It can also tell you what other workflows may (or may not) be linked to the event 22 .2001 ASUG Fall Conference. New Orleans Event Simulation With SWU0 The Event simulator is a quick way to tell if your workflow is a candidate for starting.

This tool is a very informative overview of what could happen if this event were to be triggered.2001 ASUG Fall Conference. New Orleans Event Simulation With SWU0 Check the statuses of the workflows. Note to self: clean up old linkages! 23 . You must examine the individual statuses of the workflows to determine the cause for the problem.

I have always found the event log to be helpful. find out why. But you are advised not to leave it on for an extended period of time. and perhaps. Once you get your workflow to start once or twice from the event. and you want to just let that puppy run. you will need to have the event log switched on (swels) for a while. and this can overburden the database system. 24 . if your workflow fails to start. whether linked to a workflow or not. you have this report on the event log to go back to. you can have the event log turned on.2001 ASUG Fall Conference. This way. New Orleans Using the Event Log SWEL Object Key Workflow Not necessarily! In the development system. When a new workflow goes into production. is logged in this file. as every event that occurs in the system.

25 .2001 ASUG Fall Conference. Sometimes they will be indicative of other types of errors. New Orleans Errors in the Event Log (SWEL) Here is an example of what errors look like in SWEL. such as errors in configuration. But please note: not all of the red indicators are errors from a workflow perpective.

at least I know where to begin debugging again I guess from here. New Orleans Errors in the Event Log (Drill Down) Now. and use SWU0 to create the event again. 26 . I would go back to SE37. set a breakpoint in my FM.2001 ASUG Fall Conference.

You could check this transaction if your event log merely shows an exception as the receiver type. New Orleans SM58 (or Program RSARFCRD) Another reason your workflow may not have triggered. could be an error in the Remote Function Call processing.2001 ASUG Fall Conference. 27 .

New Orleans Errors in the RFC Queue By running SM58.2001 ASUG Fall Conference. and there was no master data in the PD Org structure to support the req release workflow. In this case. the user had changed a four year old requisition. you should get a better idea of why the receiver did not start. 28 .

and specify your username as the RECEIVERTYPE and the Receiver FM as SWE_EVENT_MAIL. New Orleans What Is the Event Passing ? Specify your username Specify SWE_EVENT _MAIL I only just learned about this neat trick. but cannot tell what is being passed to your workflow. create an entry in via SWETYPV. and I hope you will enjoy it.2001 ASUG Fall Conference. Then raise the event. If you know the event is being triggered. 29 .

New Orleans You will get mail in SAPOffice ! 30 .The Event Manager Sends You SAPOffice Mail… 2001 ASUG Fall Conference.

New Orleans What Is the Event Passing ? These are the container elements passed by the event And it includes all the information that the event passes! This is really cool.2001 ASUG Fall Conference. 31 . and I can’t wait to have a bug so that I can use it.

In this case. and what their statuses are. 32 . but the workflow still did not start. • Use the event simulation transaction (SWU0) to see which workflows are linked to the event. New Orleans Workflow Did Not Start • If the event was triggered. it is likely the object does not yet exist in the database.2001 ASUG Fall Conference. you may need to use other methods to get the object information into your workflow (while the database commit gets performed).

33 . you can debug the role. then have the whole world get the workitem! While you can specify the job. New Orleans Role Resolution – Who’s Got the Workitem ? This icon will simulate the role Function Module to be executed to determine who the agent of this workitem is I like this. And often this will mean that you need to have a custom ABAP function module to fill that role. more often. there is a need to determine the agents for a workitem via a standard role. because I’d rather get an error. including the parameters which it must pass to your function module. position. or org unit that is supposed to get the work item.2001 ASUG Fall Conference. Once you have defined your role and your role resolution function module.

However. for more detailed debugging (when your role uses a Function Module) you will have to use the test bed from SE37 34 .2001 ASUG Fall Conference. New Orleans Simulating the Role Resolution Fill in your object attributes (required import parameters) Then push the wrench to see if your role returns any agents This is a quick way to see if your role resolution is returning any agents.

2001 ASUG Fall Conference. New Orleans Debugging the Role Resolution FM • Go to SE37 and enter your function module name • Choose the wrench (‘test/execute’) tool • On the next screen. push ‘debugging’ • You will be taken into the ABAP debugger • Note: you will not have the ‘workflow context’ 35 .

2001 ASUG Fall Conference. New Orleans Debugging the Role Resolution FM You will need to set these values after control returns from the macros 36 .

SWUD The current workflow to be analyzed List of test options Last 10 workflows At last we come to one of the most powerful testing tools available. ‘Workflow is hanging’) 37 . New Orleans The Diagnostic Tool. SWUD is your single point of contact for performing diagnostics from the most basic (is the workflow customizing set up correctly) to more complex (‘Task does not start’.2001 ASUG Fall Conference.

and provides a consistency check for the workflow components. refresh the org environment. Workflow is hanging checks for all instances of the task. Task does not start takes you to another screen from which you can find all instances for a task. The test environment is where I end up going the most… 38 . and ensuring that the RFC destinations are configured correctly.2001 ASUG Fall Conference. and run a consistency check on your tasks. SWUD The options from here are: • Verify workflow customizing • Problem: task does not start • Problem: workflow is hanging • Test environment Verify Workflow Customizing will take you to the screen where the most basic (and often most crucial) parts of workflow customizing are done. checks the RFC logs. checks the ABAP dump analysis. such as maintaining the workflow administrator. New Orleans Using the Diagnostic Tool.

including enabling the workflow trace. New Orleans Using the Diagnostic Tool.2001 ASUG Fall Conference. and turning on the container monitors. SWUD From ‘Text Environment’ you have a wealth of diagnostic options. 39 .

. This consistency check for components (including sub-workflows) can even show you binding errors. New Orleans SWUD. 40 .2001 ASUG Fall Conference.Consistency Check for Components Even experienced workflow developers make binding errors This is just an example of one of the tests that you can get from SWUD.

When a task is executed. You can turn the container monitor off from the dialog box. New Orleans The Container Monitor The container monitor can be switched on from SWUD. the contents of the container are shown in a dialog box. This is useful if you can’t determine exactly what is being passed from one task to the next. and then you can start the workflow. 41 .2001 ASUG Fall Conference.

and so forth.2001 ASUG Fall Conference. Double-clicking on a CONTBINDEXECUTE step will show you the details of the binding.) This trace gives you a very detailed picture of what is going on inside your workflow. or from SWU8 (you would use SWU9 to display the trace. 42 . New Orleans The Workflow Trace The workflow trace can be turned on from SWUD. from workflow to task.

Again. New Orleans Workflow Trace Here is another view of the workflow trace. dialog or background. 43 . The difference is. you can drill down for details on the binding.2001 ASUG Fall Conference. and will live for the duration of the workflow. the Workflow Trace will track all steps. It is advised that you do NOT have the workflow trace turned on (or leave it turned on for any length of time) in a production system. and you will see information similar to that of the Container Monitor.

2001 ASUG Fall Conference. for one • Try inserting code into your check function modules. receiver type function modules. you still can’t tell why a workflow is/is not being triggered • Or. methods. role resolutions. etc 44 . but immediately fails • There may be synchronizations problems with the database. the workflow is triggered. New Orleans Debugging Workflow (the Hard Way) Also Known As ‘If All Else Fails’ • Sometimes.

2001 ASUG Fall Conference. New Orleans Utility Program ZWFLOG00 45 .

New Orleans Definition of Table ZWFLOG 46 .2001 ASUG Fall Conference.

2001 ASUG Fall Conference.com/services/support/ 47 . New Orleans Summary • • • • Read (and re-read!) OSS note 322526 Use the diagnostic tools that SAP provides! Subscribe to SAP-WUG ! http://www.sap.

2001 ASUG Fall Conference. New Orleans Any Questions ? 48 .