SAP® Business Workflow Tutorial
SAP® Business Workflow
Tutorials ("How-to-do" documents):
Building a simple Workflow application using the steps "User Decision" and "Mail". (More details)
Including Custom text in the step "User Decision". (More details)
Creating a container element and using it in the step "Mail". (More details)
Inserting data from Internal Table into the step “Send Mail” (More details)NEW
Using "Condition" step (more details)
Using "Multiple Condition" step (more details)
Using "Container Operation" step (more details)
Demo on working with step "Loop (Until)" (More details)
Using the step "Form" in Workflow (Simple example) (More details)
Using the step "Form" (Detailed example) (More details)
Triggering Events Programmatically (more details)
Deadline Monitoring - Working with Latest end (more details)
Deadline Monitoring - Working with Requested Start (more details)
Dynamic Parallel Processing in Workflow (More details)
Personal Substitute for Workflow (More details)
Adoption of a Substitute (More details)
Notification of Work Items to an external email (More details)
Filtering the Work Items in the SAP Inbox (More details)
Adding Logo to the Work item preview (More details)
Tracing the events triggered during the execution of a transaction (More details)
Sending recursive mails upon reaching the deadline until the task is completed (More details)
Ad Hoc agent assignment in Workflow (More details)
Trigger a workflow to send an email whenever a material is created (More details)
Defining custom rules to use in Workflow definition (More details)
Maintaining Translations for the Work item text and Outcome Names (More details)
Raising exceptions in a method and handling the same in the workflow (More details)
ALE - Error handling through Workflow (More details)
Using ABAP Classes in Workflow (More details)
Using Document Template in Workflow (More details)
Demo on Workflow Wizard (More details)
Steps to transport agent assignment from one system to another (More details)
Creating rules using Responsibilities (More details)
Using the "Start Conditions" in Workflow (More details)
Using "Check Function Module" in Workflow (More details)
Retrieving the Work item details of the deleted users (More details)
Transporting Organization structure from one system to another (More details)
Configuring events for HR Workflow (More details)
Starting Workflow from Messages (More details)
Triggering Workflow using Business Transaction Events (More details)
Triggering of an event using Function Module Enhancement (More details)
Passing a hyperlink in a Work item (More details)
Working with Business Objects (More details)
To instantiate any Business object in a Workflow (More details)
Raising events based on changed document (More details)
Debugging SAP events (More details)
Sending workflow notification to Requestor in HTML format (More details)
Registering WEB DYNPRO/BSP Application with a Workflow Work item (More details)
Working with Dynamic Task Submission in Workflow (More details)
Archiving SAP Work items (More details)
Delegate a Subtype to Supertype (More details)
Demo on Workflow using Classes (More details)
Sending multiple attachment in user decision step of workflow (More details)
Demo on working with “Nested / SubWorkflows” (More details)
Call instance method from workflow using class (More details)
Display Dynamic Attachments in Work Item in Workflow (More details)
Modify the run-time value of workflow containers (More details)
Capture Rejection Reason Text from User Decision in Workflow (More details)
Process a User Decision Programmatically at Background (More details)
Forward a work item to your own currently logged in SAP ID (More details)
Simplified Business Workplace – Workflow Inbox in SAP R/3 (More details)
Program Exits in Work Item for Workflow (More details)
Consistency and Extended Checks for Workflow Template and Tasks (More details) NEW
How to Trigger Class based workflow? (More details) NEW
Offline Workflow Approval in ECC R/3 without SAP Logon from E-Mail (Outlook) (More
details) NEW
Passing multi-line parameters from an ABAP Class event to a Workflow container (More
details) NEW
Concept of Re-evaluate agents for active work items in SAP Workflow (More details) NEW
You might also be interested in: Workflow Scenarios configuration:
Determine of release code of PO and PR (More details)
Purchase Order Release Strategy (More details)
Purchase Requisition Release Strategy (More details)
PO List Retrieval for which Workflow isn't triggered due to Event Linkage deactivation (More
details)
Triggering of events/Workflow upon status changes (More details)
Quality Notification Configuration (More details)
Triggering a Workflow whenever a PO is changed (More details)
Configuration of Leave request workflow for ESS/MSS (More details)
Display Workflow overview of one object (Purchase Order) in another (Purchase Requisition)
(More details)
Trigger workflow when a record is created in a database table (More details) NEW
Triggering approval workflows only for Purchase Orders belonging to a particular purchasing group (using startup conditions) (More details) NEW
Advanced Features in SAP® Workflow from version 6.40
Exception Handling in Workflow (more details)
SWITCH in "Multi-condition" step (more details)
Demo on "Local Workflow" (More details)
SAP Workflow customization settings (How to do) (More details) NEW
Developing a simple application using steps "User Decision" and "Mail"
By Suresh Kumar ParvathaneniBasic terminology used in the workflow:
The workflow definition is the set of rules that determine the path that the process takes. For example, how a purchase requisition is processed, from the initial request to the creation of the purchase order A Workflow Instance, which is often simply referred to as the workflow, is a single workflow run. For example, the processing of a single purchase requisition for computers.
The Tasks are the steps in the process, which have to be performed either by people or automatically by the software. For example, to check for the availability of the spare computers in the company.
A Work item is the task instance that is performed as a single workflow step. For example, check that there are no spare computers available in the company.
Agents are the people who process the tasks (via the work items). For example, requisitioner and a
member of the purchasing department.
Container is the place where all the data used in the workflow is collected.
Binding is the set of rules that define which data is passed to which part of the process.
Building a simple workflow application
The central tool for creating, displaying and processing a workflow is the workflow builder (Transaction SWDD). Within the workflow builder you can create all components of a workflow, including all the containers you need for getting the data from one step to another.
Generally, most of the workflows are started by an event (for example, when a material is created or when a new purchase requisition arrives). You define which data from this event needs to be passed to the workflow via binding.
However you can also start any workflow directly. Let us create a simple workflow and start the workflow directly, using the testing tools.
Call transaction SWDD. When the workflow builder is called for the first time, a newly created initial workflow definition appears or else last created workflow appears. In such cases you can opt to create a new workflow by pressing “Create New Workflow”(ctrl + shft + F5). The following screen appears.
The initial workflow screen has the following parts:
a. The start of the workflow definition, indicated by .
b. The end of the workflow definition, indicated by .
c. The area in which you insert the new workflow definition is indicated by . Now select the undefined step and select Create step or double click the undefined step. Now among
Developing a simple application using steps "User Decision" and "Mail"
Previous
Now enter the title for the user decision “ Please make a decision”. Also enter the decision texts as Approve and Reject. On pressing enter, the outcome values default to the Decision texts but you can specify your own names, if desired. Now we need to select the agent. Agent is the person to whom the work item needs to be sent.. Since this is just a beginning, we would hardcode the user name. Select the User from the drop down list and enter the user name to whom the work item needs to be sent. In general, this type of agent assignment is not done. Agents are generally assigned using the expression, agent assignment rule or organization object (job, position etc.).
Now we need to include a mail step to be sent to the requestor. Now select the line “Approve” and do a right click. Different options on shown on the context menu. Select Create.
Now select the step “Send Mail” from the list.
Developing a simple application using steps "User Decision" and "Mail"
...Previous
Now enter the subject and the body of the message for the mail to be sent.
Do not change the recipients. Our mail is intended for the persons who triggered this workflow.
&_WF_INITIATOR& contains the value who executed the workflow. Since this is a test object, we are using &_WF_INITIATOR&. But we wouldn‟t be using this variable in real time scenarios. We would discuss about this in the coming documents.
Now select Transfer and to graphic button.
A popup appears requesting for the abbreviation and the name for this task. Enter the same and press enter.
Now enter the package as local object and press enter.
Press SAVE to save the workflow application. You need to enter an abbreviation and name for your
workflow as shown below. You can change any of these at any later point. After saving, a number is assigned to your workflow starting with WS, as shown below.
Developing a simple application using steps "User Decision" and "Mail"
...Previous
To execute the workflow, activate it by choosing the activate button.
Test the workflow by choosing Test. The following screen appears.
Now choose Execute to start the workflow.
Now execute the work item by pressing “Execute”. The following screen appears:
Choose one among Approve or Reject as part of the user decision. He can select the third option to retain the work item in his inbox and make the decision later. Now suppose that the recipient has chosen one of the first options. Now a mail would be sent to the requestor with the status of his request.
Including custom text in the step "User Decision"
Whenever we create a step “User Decision” (For creation of User Decision step, click here) and provide with our own options like approve or reject, the work item would appear as follows:
As marked in green in the above screenshot, the description available in the work item is a default one provided by SAP. In case we need to add our own text, do the following:
1. Identify the task being used in the step “User Decision”.
In the tab “Control”, the standard task that is being used is displayed. In this case, the standard task that is being used is “TS00008267”.
2. Go to transaction PFTC_COP to copy the standard task. Select “Standard task” in the task type and
Click on “Copy task”.
3. Enter the abbreviation and the name as required.
Click on “Copy Task”.
4. Enter the package name as required.
5. A new task would be created. Please note the task number that is created now.
6. To change the task description, you can use the transaction PFTC.
7. Now go back to workflow definition, transaction SWDD.
8. Click on “User decision” and then click on the tab “Control”.
9. Here replace the standard task number with the custom task created above.
10. Do the agent assignment and generate the same.
It is always advisable not to change any of the standard texts. The change would reflect in all the workflow definitions the task is being used.
Creating a Container element
By Suresh Kumar ParvathaneniThis document details about creation of a container element in workflow and using it in the step "Mail".
Pre-requisites:
It is assumed that the reader of this Tutorial is aware of creating a workflow definition with the step “Mail”. If not, please go through the document on creating the same available, by clicking here.
Steps:
1. Create a workflow definition using the transaction SWDD.
2. Let‟s create a container element for Carrier id. Click on the “Workflow Container” on the left side of
3. Now double-click on “Double-Click to Create”
4. Enter the details pertaining to CARRID here.
5. Click on tab “Properties” and select “Import”.
6. Click on “Confirm (Enter)”.
Creating a Container element
Previous
1. Create a “Mail” step by double-clicking on “Undefined” step in the workflow.
2. Enter the recipient details in the “Recipients” box.
4. Select the element “Carrid” from the list.
5. Similarly enter the content in the “Body” area.
6. Save and activate the application.
Testing the Workflow application:
7. Test the workflow by clicking F8.
8. Enter the value of the Carrid as shown above and press execute.
Inserting data from Internal Table into the step "Send Mail"
By Sandeep Jape, Yash TechnologiesPurpose: The purpose of this document is to insert multiple lines of an internal table in “Send Mail Step” in workflow.
Business Scenario: This tutorial can be used wherever you need to insert multiple lines of an internal
table in “Send Mail Step” through workflow for example PR, PO rejection text.
Process: This demo creation will involve the following steps
Create custom workflow
Create container element
Fill Data in above created container element
Create Send Mail Step
Insert above container element in send mail step
Pre-requisites:
You should have the basic knowledge about workflow that how to create a workflow & how to include Send Mail Step. (Please check other tutorials on SAPTechnical.COM for your reference)
Workflow configurations using SWU3 is already done
Note: We are not going to fill this DIS_TXT at run time instead we will create test data in “Initial Value” section which will be used at the time of testing. Refer the below screen shot, append lines using “Append Row” Button & press confirm button >>
Step 3: Create add step “Send Mail” which will look like the following >>
Note:
Add subject & mail text & press OK button & give the name to step as follows & save in a request.
Inserting data from Internal Table into the step "Send Mail"
..Previous
Go to Transaction PFTC put your task & press change button >>
Note: Do not modify any standard mail step task, always copy & do the changes & use the same in your custom WF.
Maintain properties for above element as shown below & save the task & exit >>
Step 4: Go back to workflow & send mail step >>
In mail step put your cursor on description & click o button Insert Expression
Select last option “All lines with line break”. It will look like this –
Note: For demo purpose I have included all 3 types
Press OK button & save the Workflow & activate
Step 5: Test the Workflow by pressing Test button as shown below
You will get following screen where press on execute button –
Now got to Transaction “SBWP” & click on Inbox & you will see our mail. Open it.
So we have successfully inserted multiple lines of an internal table in send mail step & displayed in “SBWP”.
Condition Step
By Suresh Kumar Parvathaneni
Agenda:
This document details about the steps “Condition”.
Pre-requisites: It is assumed that the reader of this document has a preliminary understanding of
workflow and has worked with the container elements earlier. If not, please go through the first two Tutorials of workflow available in this site. (More details)
Procedure:
1. Create a new workflow definition.
2. Create a container element, CARRID (as demonstrated in tutorial 2). 3. Now click on undefined step and create the step “Condition”.
4. Enter the step name of your choice.
5. We would have the following condition here:
If carrid = „AA‟. Do this. Else. Do this.
Double click on “Carrid”. Next click on “=” and enter the value “AA” in the constant field and press ENTER.
Enter the outcome names of your choice as shown above. Click on “Transfer and go to graphic”.
As shown above, there are two branches here. One navigates to true, if CARRID = „AA‟ else the control takes the branch “False”.
Test the above scenario by inserting mail steps in the above 2 branches and by passing different CARRID values.
Condition Step
By Suresh Kumar Parvathaneni
Agenda:
This document details about the steps “Multiple Condition”.
Pre-requisites: It is assumed that the reader of this document has a preliminary understanding of
workflow and has worked with the container elements earlier. If not, please go through the first two Tutorials of workflow available in this site. (More details)
Procedure:
1. Create a new workflow definition.
2. Create a container element, CARRID (as demonstrated in tutorial 2). 3. Now click on undefined step and create the step “Multiple Condition”.
4. Enter the step name of your choice.
If carrid = „AA‟. Do this.
Elseif carrid = „AH‟ DO this. Elseif carrid = „SQ‟ Do this. Else. Do this.
Select the “CARRID” using the F4 help for the comparison basis field.
Enter the values of the carrid under the Comparison values with the corresponding outcome name (of your choice)
Double click on “Carrid”. Next click on “=” and enter the value “AA” in the constant field and press ENTER.
Click on “Transfer and go to graphic”.
As observed above, there are different branches for each value of CARRID mentioned above. Test the above scenario by inserting mail steps in all the branches and by passing different CARRID values.
Using "Container Operation" step By Suresh Kumar Parvathaneni
Agenda: Usage of step “Container Operation”.
Pre-requisites: It is assumed that the reader of this tutorial has worked in the concepts that are dealt in earlier tutorials. (click here for more details)
Scenario: In this tutorial, we would deal about how to work with the step “Container Operation” with an example of calculating the available seats by subtracting occupied seats from themaximum seats at the workflow level.
Procedure:
1. Create a new workflow definition using the transaction SWDD.
2. Create two container elements MaxSeats, Occ_Seats with the “import” property set. You can use the
reference fields sflight-seatsmax, sflight-seatsocc for this.
3. Create another container element AvailableSeats without setting either import or export property as
this is calculated within the workflow and used within the workflow. You might use any of the above reference fields as data types.
4. Define a new step “Container Operation” in the workflow definition by double-clicking on the
“Undefined step”.
I would recommend entering all the container elements from the F4 help instead of typing them manually.
6. Return to the main screen.
8. Test the above functionality by passing some values to the maximum and the seats occupied.
Demo on working with step "Loop (Until)"
By Avinash Palavai, StraVis IT Solutions
Prerequisite : Should have basic idea of worklow and usage of container elements, container operation and Send Mail Steps.
1) Go to the t.code SWDD ( Workflow Builder ). By default, it opens the last developed workflow. So
click on create to create a new Workflow. Below screen appears.
2) Double click the below shown item in the workflow container to create an element called Counter.
5) Now the following screen of step “Loop Until” opens and set the condition as below, i.e. the loop runs until
Demo on working with step "Loop (Until)"
...Previous
7) Then create a “Send Mail” step on the “False” branch of step “Loop Until” as shown below,
8) Enter the following details in “Send Mail” step and click on Transfer and to graphic .
10) Now your workflow would look like below,
11) Then create a “Container operation” step on the same “False” branch of step “Loop Until” after the Send Mail step.
12) Build the below condition, to increment the counter element.
14) Save and activate the entire workflow and test it .
15) Click on in the below screen,
16) Go to your Business workplace (SBWP) and check the inbox. You will find two mails, as the counter is initially set to „1‟ and loop runs for two times until Counter gets incremented to „3‟ to satisfy the condition that was set in container operation.
Using the step "Form" in workflow
By Saumik Bhattacharya, CapgeminiForm is an important step type of workflow builder. We can use forms to enter data for processing in Business Workflow, or to display and edit data.
Using the Forms step type we can generate a form from the workflow system with a structure that is saved in workflow container. This form can be used for displaying and editing the form data. It can also contain additional control elements that can be used, for example, for the approval of form content. First of all we are creating a workflow container element in transaction code SWDD. You can use a form to display or edit data of a container element of the workflow container that refers to a structure.
The element should be of type reference to an ABAP dictionary.
Here we have to insert form type and action. Action can be of four types:
Now according to our requirement we are just using the material number & material description in the form layout.
For e.g. we are using the material number as input value and description field as output only.
After completing this, we will execute this workflow and will get the form:
Using the step "Form" in workflow
By Sai Kumar B, Enteg InfotechIn the need of input from the user other than mere clicking of accept and reject actions, we can use the Form Step in workflow. The form step presents the user a form (User interface) thus by enabling the workflow developer to capture the required input from the user. The form used here is just like classic Dynpro screen, which can be designed in Screen Painter (SE51).
To Begin with lets start with Workflow builder, SWDD. In this tutorial I was just showing how to include a form step inside a workflow.
1. Right click on the activity and select create.
3. In the next screen provide Step Name and agent assignment 4. Select the form type and action
5. Then click on Create (Before clicking on Create make sure that you have declared a structure in container which can be used as the structure for the form / Screen you are going to include.
6. If you have not created the structure, you can do so by double clicking the container.
7. Then give name for the container element and type of the element, and if you are using this structure for changing of some values be sure to check export and import check boxes in properties tab.
8. Coming back to the form step click on the create button.
10. Give your form a name and select the structure for which you are building the form . 11. And click on continue.
Using the step "Form" in workflow
...Previous
14. Now you can change the form as per your need. You can use the form as it is, as the logic will be handled automatically. The changes that were made in the form at runtime will directly reflected in the container element. If you need more complex logic you can modify the form as per your requirements by clicking on change button.
16. If you need to change the flow logic you can go there by clicking on flow logic, where you can change the flow logic.
17. If you want to control the data in PBO and PAI level you can double click the module to be navigated to the function modules generated by sap system. Even though SAP recommends not to change the modules you can change them with due caution to meet your requirements.
Triggering Events Programmatically
By Suresh Kumar ParvathaneniPurpose: This document details the procedure in triggering the business object events programmatically. Pre-requisites: It is assumed that the reader of this document is aware of the business object concepts
and good in ABAP.
Procedure:
In this document, we would take an example of the business object BUS1001006 (Material) and the event CREATED. In general, this event is triggered whenever a material is created using a standard procedure like MM01 or any others. Now we would trigger this event from our own programs.
Following are the screenshots of the business object BUS1001006 and the event CREATED. Go to transaction SWO1 for more information of the business object.
In order to trigger an event programmatically, we would use the function module SWE_EVENT_CREATE.
Following is the sample code to trigger the events programmatically:
REPORT ZDEMO_TRIGGER_EVENT.
DATA: KEY LIKE SWEINSTCOU-OBJKEY.
KEY = '1163'. “ Material Number (hard-coded)
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING objtype = 'BUS1001006' objkey = KEY event = 'CREATED' * CREATOR = ' ' * TAKE_WORKITEM_REQUESTER = ' ' * START_WITH_DELAY = ' ' * START_RECFB_SYNCHRON = ' ' * NO_COMMIT_FOR_QUEUE = ' ' * DEBUG_FLAG = ' ' * NO_LOGGING = ' ' * IDENT = * IMPORTING * EVENT_ID = * TABLES
* EVENT_CONTAINER = EXCEPTIONS OBJTYPE_NOT_FOUND = 1 OTHERS = 2 . IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
WRITE 'Event Triggered'.
ENDIF.
COMMIT WORK.
In order to test whether the event is getting triggered or not, we can make use of Event Trace. Switch on the event trace using the transaction SWELS.
Press „Switch On”.
Now execute the program developed earlier. Now switch-off the event trace using the same transaction SWELS.
Now go to transaction SWEL. Here you can list out the events triggered in the particular period of time. Here is the event-trace list:
Deadline Monitoring in SAP Workflow (Working with Latest end)
By Suresh Kumar ParvathaneniA major advantage of workflow is the ability to monitor the workflow steps according to a predefined schedule. Following are different deadlines that can be monitored against each workflow step:
Requested Start
Latest Start
Requested End
Latest End
In this example, we will define a deadline to the User Decision example created earlier (click here). Following is the screenshot of the application developed using the User Decision example:
We would extend this example to the deadline monitoring. In the User Decision step, click on the “latest end” tab.
By default, No deadline monitoring is active (as seen in the above screenshot).
Choose the “Work Item Creation” from the list box.
After selecting “Work Item Creation”, chose an offset of 5 minutes. This means that the work item must be executed within 5 minutes of the creation, if not this would trigger.
Deadline Monitoring in SAP Workflow
...Continued
Enter recipient details to whom the message to be escalated, if the work item is not executed with in 5 minutes after work item creation.
Save and activate the workflow definition. Testing the workflow application:
Execute your workflow.
Check for the work item in the SAP Inbox. This time do NOT execute the work item.
Wait for the deadline to be triggered. After that, a deadline message is delivered to the recipient mentioned in the “Latest End” tab. See the screenshot below.
Don‟t worry if the deadline message doesn‟t appear immediately after 5 minutes. This depends on various factors including how the deadline monitoring program is scheduled and also on the availability of the background processors.
For example, assume that our work item has been created at 09:10 hrs and the deadline message is expected to trigger at 09:15 hrs. From the above screenshot, it is understood that the background program is scheduled to execute for every 3 minutes. Assume that the last run of the program is at 09:14hrs and the next run is expected at 09:17hrs. So even our deadline expires at 09:15, the deadline message would appear only at 09:17hrs after execution of the background program.
Some more points
In our above example, we have used the deadline on the “Work Item” creation time. i.e., 5 minutes after creation time, the deadline message would be sent. Now we would check the other option “Expression”. Here we can mention the date and time, when the deadline message should appear irrespective of the work item creation date/time.
As seen in the above screenshot, we can provide the target date and time by which the task should be finished. Container elements could be used in this case. Please refer to our example on creation of container elements (click here).
Deadline Monitoring in SAP Workflow (Working with Requested Start)
By Ravi AswaniIn this tutorial, we would look into implementation of “Requested Start” in the step “User Decision”. This is common for the step “Activity” and others as well.
Go to transaction SWDD and create a step User Decision. Click on the tab “Requested Start”.
For demo purpose, we would be choosing the Requested Start as 2 minutes from the work item creation. Choose the “Work Item Creation” from the list box.
Choose an offset of 2 minutes. This means that the work item shall be created after 2 minutes. Save and activate the workflow definition. Execute the workflow definition.
In SAP inbox, you can observe that the work item is not yet delivered.
Following is the status of the workflow instance. You can observe that the work item is in the status “Waiting”.
The status of the work item would convert to Ready after 2 minutes (as per the time mentioned in the Requested Start).
Dynamic Parallel Processing in Workflow
By Punit Jhanwar, YASH TechnologiesThis blog is a step-by-step approach for using dynamic parallel processing in Workflow (For the concept of dynamic parallel processing, please click here).
For our demo purpose, we have taken a simple example. A multiline element „Material‟ is passed on to workflow and our step „Activity‟ has to be executed n times (n denotes the number of materials in the multiline container element „Material‟). In simple words, if 10 materials are passed to the workflow, then 10 work items are to be generated. Following is the step-by-step approach in achieving the same:
1. Create workflow using the workflow builder.
2. Create a Multiline container element for Material number .
3. Create a step „Activity‟ in the workflow definition.
4. Click on the tab „Miscellaneous‟.
In the field “Multiline Element”, click on F4 and select MATNR.
5. Now go back to the tab „Control‟. From the list box, select „Create task‟
Enter the abbreviation and name for the task.
6. Let us have the material number displayed in the work item text. For this, we need to create a container element for the Material (not a multiline element).
Dynamic Parallel Processing in Workflow
...Previous
In the properties, click on Import.
7. Insert the container element MATNR in the work item text .
8. Choose the business object and the corresponding method for the material display (we have chosen a dummy method for our demo purpose).
Click on Save and come back to the main screen of step „Activity‟.
9. Define the binding between the activity and the task.
As seen in the above screenshot, there are two MATNR in the workflow container. One representing the multiline element that we have created for the workflow container and the other is an index of a MATNR. Since we have defined MATNR for the dynamic parallel processing, this step „Activity‟ would execute for each entry in this multiline element MATNR. So MATNR() represents the index of the material during runtime.
11 . Activate the workflow .
12. Execute the workflow. Test run your workflow definition by providing some test data
Personal Substitute in Workflow By Suresh Kumar Parvathaneni
Requirement: Need to have at least one substitute who can act upon work items in your absence. Important: The appointed substitute would be able to see all your work items. A substitute cannot be
assigned for only particular area of organization or any other item. So need to ensure that the substitute have the necessary authorizations to act upon the work items.
Procedure:
1. Go to SAP Business Work Place (TCode: SBWP)
2. Now from the menu bar, select Settings Workflow settings Maintain Substitute
3. Highlight/Select the name on the window, in this case SAPDEV02 and click on “Create
Substitute”.
5. Select the required substitute user name. Following screen appears.
Validity field describes about the period in which the setting would be active. Note that the dates on the screen would range from the current date to 31st Dec 9999.
Regarding the checkbox “Substitution active”, it is advised to leave this checkbox unchecked for system performance reasons. A check in this box indicates that the substitution is “permanent” and if left unchecked it is treated as “as-needed”. A permanent substitute will automatically receive the primary users work items in their own box. In the case of “as-needed”, substitute must manually adopt the work items from the primary user‟s inbox.
7. Click Enter to leave the screen.
Adopting a Substitute in Workflow By Suresh Kumar Parvathaneni
If you have been designated as an “as-needed” substitute, you must manually adopt the substitution. If you are designated as a “permanent” substitute, the work items would automatically appear in the inbox. Before adopting a substitution, there are 19 work items in the inbox. See the screenshot below:
To adopt a substitution, select Settings Workflow settings adopt substitution.
Select the corresponding User-id (if you have been assigned as a substitute for multiple people, then this option would allow you to select the user name of whom you would to check the work items)
The corresponding user‟s work items would appear in our inbox now.
You can end the substitution, by selecting settings Workflow settings End substitution.
Note: Substitutes can only adopt work items that are directly routed to the person for whom they are a
substitute. If you are a substitute for a user (SAPDEV02) who has been made a substitute for another user (SAPDEV01), you will only see work items for user SAPDEV02 and not of the user SAPDEV01.
Notification of Work Items via e-Mail
By Suresh Kumar ParvathaneniSAP provides us with a facility of notifying the user via the email address of your choice when there are any pending work items in the SAP Inbox..
1. Go to Transaction SO13.
2. Click on Automatic Forwarding tab.
3. Click on Create icon .
4. Enter the details in the above screen.
5. Click ENTER to complete the entries.
6. Now the notification would be received at the provided email address if there are any pending work
Filtering the Work Items in the SAP Inbox using BADI
This document details about the procedure in filtering some of the work items from the SAP inbox using a BADi.
Following is the screenshot of the SAP inbox, before implementing BADi:
The BADi that is used in filtering the work items is WF_BWP_SELECT_FILTER. To implement the BADi, go to transaction SE18. From the menu, select Implementation Create. (See the screenshot below)
Enter the implementation name and press ENTER
Enter any meaningful short text for the implementation and click on the tab “Interface”
The implementing class, ZCL_IM_BWP_SELECT_FILTER, is automatically proposed. Double click on the implementing class name.
You are now navigated to the class builder. Now double-click on the method name shown on the screen (see the snapshot below)
Now let us filter out the work items belonging to the task TS2000066. See the code below:
Activate the method and also the implementation. In the state of active, you wouldn‟t be able to make any changes. To make any changes, we need to deactivate it and then make the changes.
Now check the inbox and would notice that the work items related to that task are no more appearing.
To notice the differences, try activating and deactivating the BADi implementation.
Inserting the logo in the Work item preview To upload the logo:
1. Go to transaction SMW0
2. Select “Binary data for Web RFC applications”.
3. Execute the transaction (No need to fill any values on the selection
4. Click on “Create”. The following screen appears. Enter the “Obj. Name” and
“Descriotion”.
6. Your entry is now available in the table control on the
screen.
Embedding this logo in the Work item preview
1. Create a workflow definition with a simple step “User decision”.
2. Now in the step “User decision”, go to tab “Work item
display”.
3. Click on “Demo Function
Modules”.
The function modules shown above need to be used as a template for defining the logo as per the requirement. Using the function module “SWL0_PREVIEW_DEMO_GIF_ONLY”, we can only display the
logo of the company. Using “SWL0_PREVIEW_DEMO_TEXT_AND_GIF”, we can display both logo and our own text below the logo. The FM “SWL0_PREVIEW_DEMO_TEXT_ONLY” is used to display custom text only. For our demo purpose, we would use the FM “SWL0_PREVIEW_DEMO_TEXT_AND_GIF”.
Inserting the logo in the Work item preview
Previous
5. Copy the function module “SWL0_PREVIEW_DEMO_TEXT_AND_GIF” to a „Z‟ function module.
6. Now change value of gif-id” to the object-id created in “SMW0” (Logo id) and
Save and activate the function module.
7. Now in the workflow builder and in the tab “Work item display”, mention the name of the „Z‟ function
module created
earlier.
8. Execute your workflow definition. In your SAP inbox, you can see the logo and the custom text in the
Tracing the events executed in a transaction
By Suresh Kumar Parvathaneni
In the article triggering events programmatically, we learned about triggering the events programmatically in our custom programs. But SAP has already provided with many events in almost all the standard SAP transactions like:
1. When a material is created, a standard event is triggered
2. When a Purchase Order is created, an event is triggered.
3. When the status of a production order is changed, an event is triggered.
We can link the events to either standard workflows or custom workflows to carry out our business requirements. Before linking the business workflows to events, we would need to trace the events that are triggered in a transaction. This document explains the procedure in tracing the events for the Material Master transaction (MM01). We would trace the events that are triggered when a Material is created using MM01.
1. Go to transaction SWELS. A pop-up screen as shown below would
appear:
2. Click on “Switch on”. The event trace would be on
now.
4. Now go to transaction SWELS and click on “Switch Off” to switch off the event
trace.
5. Go to transaction SWEL to get the list of events triggered during the Material
creation.
6. Click on
The list of events that are triggered are shaded in green. A workflow object (shown in yellow) is also triggered as it is attached to the event CREATED belonging to the business object BUS1001006.
Sending recursive mails upon reaching the deadline until the task is
completed
Recently, we encountered a scenario where-in we need to send recursive mails for every xx hours, when the deadline is reached, until the task is completed. I am presenting the same here, with a simple example, hoping that this would be useful to you all.
Start a new workflow and define a "User Decision" step. For steps on how to define a User Decision step, click here.
In the step "User Decision", switch to tab "Latest End" and provide the details as shown below:
In the action, select "Modeled" from the list. Enter the name of the outcome.
Click on "Transfer and to Graphic" (Green tick button).
You can notice that there are 3 branches now. Two belong to the User Decision Step (YES/NO) and the other one is of Modeled deadline. So whenever a deadline is reached, this branch executes. When the user completes his task, it would either take YES or NO branch accordingly.
Now assume that we need to send repetitive mails to the agent for every 3 minutes, until he completes the task (in this case, acting on User Decision step).
Using "Loop (Until)", we would be sending emails repetitively for every 3 minutes. To keep the loop open continuously, lets define a condition which would never be met.
Enter a step name and then click on "Click here to create a new condition".
The above screenshot is of the step "Loop (Until)". Now double-click on the "Undefined" step above and create an email step.
Enter the recipient name and other details as shown above.
Sending recursive mails upon reaching the deadline until the task is
completed
...Previous
Now we need to send mails once every three minutes until the task is finished. To achieve this, we would need to create a business object (or use an existing one) and create a dummy method (with no code in it). Ensure that the check box "dialog" is unchecked in the properties of this method.
Now create a step "Activity" by double-clicking on undefined step after the email step in the Modeled branch.
Provide the details as shown below:
Don't forget to check the checkbox "Background processing". SAVE and click on Back button.
Using the above step, we are restricting the LOOP to send mails for every 3 minutes only. Save and activate your workflow.
Test run the workflow. Do NOT execute the work item and wait for the alert mails.
Work item in inbox:
Ad Hoc agent assignment in Workflow
By Sathis Kumar R, Quintegra SolutionsThis Article is about the Adhoc Agent Assignment for workflow. The workflow initiator assigns a recipient to the steps in the workflow at runtime.
Scenario:
Assigning Adhoc Agent for the task " create the leave form". Step by step:
Create the new workflow named as "wf_4adhoc "
Now create a new task for leave form.
In that give your own abbreviation and name for the task. Object Category : BOR Object
Object Type : FORMABSENC. Method : CREATE.
Click ok (Tick mark) button.
You don't fill any agent for this task. You leave it as empty as shown in the figure. Now we move to the Task properties. Click the agent assignment icon.
Ad Hoc agent assignment in Workflow
....Previous
Now choose the task and click the attributes button.
Choose the General Task and click the Transfer button.
You go back to the workflow builder now the Agent Assignment was active.
Click the Ok button.
Now Go to the Extras -> Ad_hoc functions -> Enable the Adhoc Agent Assignment. Now the enable the Adhoc Agent Assignment Wizard will be opened.
Click the Continue Button.
Now it shows your Task Number and Name and check whether the "insert the workflow constructor and workflow destructor" will be selected or not. If not means now you select that option.
Click the Continue Button.
Ad Hoc agent assignment in Workflow
....Previous
Now the wizard was completed click the Complete Button.
You check the task it will automatically filled the agent name as: &Agent_0001.Agents& Now you can Save the Workflow and activate it.
Execute the Workflow.
You click the Ad_hoc Agent tab.
You enter the name of the user who wants to do this task . In my Example I entered Developer2. And then click the Check Agent Button. It automatically creates the random key for that user and it will be assigned to the Agent_001.
Now again click the execute Button.
Triggering workflow to send an email whenever a material is created
By Chandrasekhar V, EDS
This example focuses on triggering a workflow whenever a material is created using MM01. TCode SWDD(Workflow builder) -> Click on “Create” button
Drag and drop the “User decision” step. Enter the following details
Select the agents “Workflow initiator (expression)” and click on “Transfer and to graphic” (tick mark button).
Following screen appears.
Drag and drop “Activity” step into branch YES,
To get “&_WI_OBJECT_ID.MATERIAL&” in above screen, click “insert variable” icon (above that yellow icon).
Save in local package.
Go to “Additional data” menu “Agent assignments” -> “Maintain”.
Select it and click on “Attributes” from application toolbar and select “General task” radio button, click “Transfer”
Click on back 2 times.
Triggering workflow to send an email whenever a material is created
....Previous
Click on “continue”.
To create the workflow container
Again open user decision, which was already created, and make changes as bellow In Parameter1 click F4 and select Material number as bellow
Click on “transfer and to graphic”
Click here to continue...
Triggering workflow to send an email whenever a material is created
....Previous
Double click on “send mail”.
Click on “Transfer and to graphic”
Save in a local package
Enter the details as in bellow screen
Click on ok
Save, activate and execute.
Go to TCode “MM01” to create the material
Enter the details in MM01 and click on “Select view” -> “Basic data1” Enter the details in Second screen as below:
Check your inbox by using TCode
SBWP.
Defining Custom Rules for use in SAP Workflow
By Raghava Vakada, Mouri Tech Solutions“I would like to explain about creating custom rules in SAP Workflow. The rules can be created or changed using the standard SAP transaction PFAC. Once the rules are created you can call these rules
in any workflow via the rule container”.
In this article I am creating a rule, which will find the users based on Position id. I have created a custom function module ZWF_FIND_USERS which will return me back a position under Asset Analyst (HRP1001-SOBID). The custom function created should have the same interface as that of the SAP standard function module RH_GET_ACTORS. The following table parameters have to exist in the custom function module.
“ACTOR_TAB STRUCTURE SWHACTOR” “AC_CONTAINER STRUCTURE SWCONT” Following is the function module code: FUNCTION ZWF_FIND_USERS.
*"--- *"*"Local Interface:
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR *" AC_CONTAINER STRUCTURE SWCONT *" EXCEPTIONS
*" NOAGENT_FOUND
*"--- INCLUDE <CNTN01>.
DATA : POSITION_ID LIKE ZBUSAREA-OBJID,
LT_HOLDERS TYPE STANDARD TABLE OF SWHACTOR, LWA_HOLDERS TYPE SWHACTOR,
LWA_USERS TYPE STANDARD TABLE OF HRP1001, WA_USERS TYPE HRP1001,
NUM_LINES TYPE I.
*Read values assigned to the rule criteria
SWC_GET_ELEMENT AC_CONTAINER 'POSITION_ID' POSITION_ID. SELECT * FROM HRP1001 INTO table LWA_USERS
WHERE OBJID = POSITION_ID. IF NOT LWA_USERS IS INITIAL. REFRESH LT_HOLDERS[].
loop at LWA_USERS into WA_USERS. Condense WA_USERS-SOBID.
LWA_HOLDERS-OTYPE = 'US'.
LWA_HOLDERS-OBJID = WA_USERS-SOBID. APPEND LWA_HOLDERS TO LT_HOLDERS.
APPEND LINES OF LT_HOLDERS TO ACTOR_TAB. endloop.
ENDIF.
DESCRIBE TABLE ACTOR_TAB LINES NUM_LINES. IF NUM_LINES IS INITIAL.
RAISE NOAGENT_FOUND. ENDIF.
ENDFUNCTION.
Creating a rule using the PFAC Transaction
Assign the function module ZWF_FIND_USERS in the "Rule Definition Tab"
Go to the "Container Tab" and create a container element for the “Position id” which will be passed to the function module
Our rule is created now. You can test the rule within the PFAC transaction by clicking the "Simulation" button on the application toolbar. Now this rule is ready to be used in any workflow according to your requirement via the rule container of the workflow.
Enter the Position Id, which is created in (PPOCW)
Maintaining Translations for Work item texts and Outcome names
In this tutorial, we would look into a simple method of translating Work item texts and step names to the desired language.Let us open any existing workflow definition.
You can observe that the text remains in the English language, whereas “Workflow Started” is translated as “Workflow gestartet” (As the SAP has already provided translation for this)
Now to translate the text to German, Click on Extras -> Translation -> Translation (As shown in the screenshot below):
Following pop-up appears: Select German from the list box.
Now a screen with all the workflow steps and outcome names are displayed for maintaining the translation.
For our testing purposes, let us maintain the German text for the first two step types.
Save and activate.
Now logon in German Language and check the workflow definition. You can observe that for the two step types, the text is available in German.
Raising exceptions in a method and handling the same in the
workflow
By Suresh Kumar Parvathaneni
This document details the procedure in defining exceptions in a method and using the same in a workflow.
Let us first look at raising exceptions in a method:
Go to Business Object Builder (Transaction SWO1). Create a business object.
Now create a method.
Now select the method you have created and click on button “Exceptions” available on the toolbar. Following screen appears:
Now click on Create. Following popup screen appears:
Enter the information as shown above. The error type “Temporary error” is chosen in the case wherein the record is locked by somebody else or some required resource is not available. The error type “Application Error” is to be chosen when there is no authorization for the document you are processing. The error type “System error” is to be chosen if there are no values passed for the mandatory parameters.
Click on continue.
Go back to the main screen.
Save the business object and release the same.
Try executing the method by clicking on Test/Execute (F8). The exception would be raised as shown below:
Capturing the exception raised by the method in the workflow:
Go to Workflow Builder (TCode: SWO1). Create the step “Activity”
Create a task and provide the following details in the new task:
Save your entries and return to the previous screen.
Click on “Outcomes” tab. Here you can observe the exception you defined in your method:
As observed in the observe screen, the outcome is not active by default. If we do not handle the exception, the work item might go into the error status. Activate the outcome:
Save your entries and go back to the main screen of Workflow builder. Please ensure that you have done the agent assignment for this task.