Abap Workflow
Abap Workflow
Contents:
Introduction to Workflow
Creating Workflow.
Important T Codes
Conclusion
ABAP WORKFLOW :-
Real Time scenarios for Workflow Uses:A workflow management system facilitates the electronic processing of structured processes that :
Include a number of activities
Always occur in a similar or identical form
Involve several people or departments, and
Require a high degree of coordination
Workflow management systems control processes according to a predefined model and are particularly
suitable for structured organizations
For Management
Better control over
Information
Deadlines
Service levels
Process costs
Flexibility in changing
Processes
Organizational structure
Underlying technology
For Enterprises
Increases production
Backlog reduction
Distribution of information and work
Speeds up processes
Cash discounts more often
Better/faster reaction to errors
Increases customer satisfaction
Processes completed more quickly
Better information flow
Scenario:After Creating Purchase order, a customized table should automatically get updated with
required values.
(This document explains steps to create workflow in 4.6 versions.
There are small modifications is ECC6.0 and later versions)
Step 2:Create a function module which will fetch data from EKKO (Purchase Document Number) table and
update created table.
Step 3:Please check whether the client and server which you are working on have a Prefix Number
Entry in tableT78NR.
To check these go to transaction SPRO. Reach out to pathBasis Components >Business Management ->SAP Business Workflow > Basic Settings->Maintain
Prefix Number
If the table does not have entry please create an entry with unique number not already used in
the table.
Step 4:Create one Customizing Transport Request and one Workbench request using Transaction SE10.
Now we are ready to create Workflow and Related Objects.
Creating Object Types:Go to Transaction SWO1 and search for Object or Interface Type Related to Purchase order.
E.g. BUS2012
Check whether the object or interface type contents required event in current scenario its
Create.
Fill in all fields and then press enters which will create a new subtype of BUS2012 and will inherit
all the Attributes, Methods and Events of Super Type.
Now in this Subtype we can add our own Interfaces, Attributes, Methods and events.
Reference diagram from SAP AG explaining Relationship between Super type and Subtype
Here I have added a new method named FILL_DATA and an Event Created for my Subtype.
Now let us go to detail of how to create new methods or events or Attributes.
Point the Cursor on the place where you want to add new functionality. E.g. Methods
Click on create button which will give you Popup window
asking
Method Name
Name and Description
If you want users to execute this method select dialog or if you want it perform as a background
task leave it blank.
Synchronous:
Instance independent:
Switch to tab ABAP. Select function module radio button and give name of function module you
created before which will fetch data from EKKO and update in custom table.
If you want to see program keep cursor on method created and press button
You will see window like this.
Note: This is old ABAP Editor. There is no workaround for this to make it in normal editor as of
now.
Its nothing but FM call. So now we have to give Import parameter as Key of the Object Type which
we have created.
Here I have created task called ZT_WFTRN. And in the Object Method gave Object type as our
created Object type and Method for which this task is implemented.
We can have different setting is all the tabs available in Task Creation.
Basic Data I have already shown above.
Description is nothing but Documentation about the task
Alternating methods: here we can define any alternating method than the given default method in
Header data section (It might be useful when we want to use same task to work differently on
different conditions.)
Triggering Events and Termination Events:
As names suggest these are the starting and ending conditions for out task.
. This will activate the Event but before that it will ask
you to save this event linkage. Use your Customization task and save it.
Terminating event can be used to stop execution of the Event in certain conditions
Now save the task and press Container button.
Click on create button and create new container with Our Object type created for Workflow.
Save it and come back. Save Task Again.
Now we are ready with Task remaining part is Creation of workflow and linking this task to
Workflow.
Before that lets take a insight on Container.
Containers are nothing but the Variables in the Workflow that hold the values in the workflow.
They can be simple variables or structures or even objects of any class. So they are best treated
as the variables.
Also we can select other checkboxes which are Executable as form means which will run in
foreground and If confirm end of processing is checked then it will ask for user input while ending
task.
Please change status of task to Released without fail before saving.
Creating A WORKFLOW
Now we are ready with all the basic need to create our main Workflow.
So now we will go to T-Code SWDD. (Work Flow Builder)
Click on new button and you will see screen like this
At the right hand side bottom we can see all the types of Activities we can do.
Double click on undefined task white arrow in workflow and pop up occurs.
Which list all the steps which we can select Activity Giving customized created task as execution step for workflow
Condition and Multiple Condition Like IF ELSE statement and Case statement
Fork- is for running two tasks concurrently and then upon successful execution of both the tasks
move forward for the next step. (Same as Linux FORK () and Child ())
Give created task in the format of TSXXXXXXXXX where xxx is your task number which we have
created in the section above.
This binding will bind the Task Container and Workflow container so that task gets executed with
the values which are exported from Workflow.
After this go to Agent assignment where we can see button with apple on it.
Agent can be Expression, Role, Organization Unit, Job, User, Or Work center.
Before that go to
And maintain entry for the Change Document related to Purchase Order i.e. EINKBELEG by clicking
on new entry.
(This is a Cross client table) (We can find Change document related to Purchase order searching in
define workflow properties)
header button
Here we can see one more column which I did not explain before now we will see what this is. Its
nothing but a condition specification column. Here we can give some more conditions to be
checked before executing workflow after event has occurred.
Press Agent assignment button again here and then press generate. Come back to workflow. Save
and Activate workflow.
Now we are ready with All the Required Objects ready and workflow ready.
Execution
Whole purpose of this Scenario was to update a Customized table just after creating Purchase
order.
So we will now create a purchase order and then check our customized table.
Give Event Name in Filter or Object name which we created and then execute which will give a
report.
We can see event did occur
And in the receiver type the name was given as Workflow which we created. Also Green Square
shows that event was successful.
So we are sure that event was fired and data was properly given to the workflow so now we can
check whether the problem was in workflow and task.
Double click on event and we will be on the screen
Click on List of technical details and check whether error occurred anywhere. In this case since it
was successful execution nothing will be in Error.
Conclusion
So here we are ready with out first workflow.
We can add any number of tasks in this workflow. Also we can trigger same workflow from
different events such as changed, display.
Useful Transaction Codes
Area Code SWLD lists all transactions associated with Business Workflow.
SWDD - Main Workflow Builder
PFTC - General task maintenance
SWO1- Business Object Builder
SBWP- The Business Workplace SWDM - Business Workflow Explorer
SWELS - Switch Event Trace On/Off
SWETYPV - Display/Maint. Event Type Linkages
SWUS - Test Workflow
TASK/TASK GROUPS
PFTC_INS - Create
PFTC_CHG - Change
PFTC_DIS - Display
PFTC_COP - Copy
PFTC_DEL Delete
T-codes Related To Events
Events Creation
BSVW - Status management
NACE - Message Control
AWUW - Logistics Information System (LIS)
Event Linkages
SWB_COND - Workflow Start Conditions
SWW_WI_POPUP_FOR_COMPLETION
SWW_ADDR_KEY_CREATE_FROM_USER
SWW_WI_DELETE
SWW_WI_CREATE_VIA_EVENT
SWW_WI_DEADLINE_CHANGE
SWW_WI_COMP_EVENT_RECEIVE
SWW_WI_REJECT
SWW_WI_EVENT_RECEIVE
SWW_WI_DISABLE
SWW_WI_ENABLE
Methods and Events for a particular business entity. Example of BO: Sale Order,
Vendor, Customer, Material etc.
Business Process: Business processes are defined in Workflow builder.
Each and every small work process is called as an activity in the workflow
builder. Each activity consists of a single step task, which can be a standard task
or a workflow template.
Organization Model: Organization model mainly has four important
elements: Org unit (O), Job (C), Position (S) and Person (P). Rules and the Tasks
are used to map these elements to the different agents.
small work process is called as an activity in the workflow builder. Each activity
consists of a single step task, which can be a standard task or a workflow
template.
Associated Business Logic is built in Business Objects. i.e. ABAP code will
be in Business Object. Business Objects consist of attributes, methods and
events. Methods consist of ABAP code. Each and every standard task is
associated with a Business Object and a method.
People / Group of people responsible for taking actions are defined in
organization structure. Person responsible for taking an action is called actual
agent. It is defined in the workflow activity.
Who is an Agent?
An agent is a person or a group of persons who can take an action during
workflow runtime. Action can be approval of some business document, creation
of some document or sending email.
There are basically three types of Agents:
Actual Agent: One who actually takes the action. This is provided in the
workflow Activity.
Possible Agent: All possible persons/entities who are authorized
organizationally to start a task and execute the relevant work item.
A single-step task cannot be processed as a work item if there are no possible
agents. The possible agents always form the set from which the selected agents
are determined.
It is not necessary to specify the possible agents of a single-step task if the
respective task has been classified as a general task.
The possible agents of a multistep task are those employees in the company
who are authorized to start the respective task in dialog.
A work item which is displayed via the workflow outbox, workflow log, or
selection report can be executed by its possible agents (not only by its actual
agents).
Excluded Agents: Persons who are excluded from taking action on a task.
These are assigned in the workflow definition at the workflow activity.
Excluded agents are determined at runtime so that information from the
environment for executing the workflow (agent for previous steps) or from the
context of the processed application objects can be taken into account.
System checks Actual Agent defined in workflow runtime with the Possible
Agents defined in the task and the Excluded Agents. Actual Agent should be a
subset of Possible Agents minus the Excluded Agents, else Agent resolution fails.
Rules to Determine Agents?
The possible rules to determine agents are:
required.
Organizational attributes (OOAW): You can use organizational attributes in
the SAP applications EBP and CRM.
What are all the Different ways of creating Events?
Events are actions that occur in the system and that acts as trigger point for any
workflow. Example: Creation of Sales order.
The possible ways of creating events are:
Through
Function
module
- SWE_EVENT_CREATE
or
SAP_WAPI_CREATE_EVENT
Single Step Task: This include Standard Task (TS Cross client/time
independent) and Customer task (T Client Specific/time dependent)
Multi Step Task: This include Workflow Template (WS Cross client/time
independent) and Workflow Task (WF Client Specific/time dependent)
What are Step Types?
A step types are the entities used in the workflow which gives the predefined
results whenever executed.
The Step Types appear in the Objects section of the workflow builder or simply
right click on the builder and choose insert option. Step Types that can be
inserted in the workflow are:
Activity, web activity, Send Mail, Form, User Decision, Document from Template,
Condition, Multiple Condition, Event Creator, Wait, Container Operation, Process
Control, Loop(Until), Fork, Block, Local Workflow etc.
What is Deadline Monitoring?
Delegation: Its a process of creating sub type from the super type by
inheriting all the properties of super type and adding your own methods, events
and attributes to your sub type.
Container: Its a storage place where all the values associated with variables or
structures are stored (import or export).
Binding: Assignment between the elements of two different containers (Event
Container/ Workflow Container/ Task Container/Method Container/ Rule
Container) is referred as Binding.
Basic Function Modules in Workflows?
SWW_WI_POPUP_FOR_COMPLETION - Shows the completed status of a workflow
SWW_ADDR_KEY_CREATE_FROM_USER - Display the address of the user or
recipient
SWW_WI_DELETE - Delete work item
SWW_WI_CREATE_VIA_EVENT - Create work item as result of event
SWW_WI_DEADLINE_CHANGE - Change of deadline attribute of work item
SWW_WI_COMP_EVENT_RECEIVE - Complete workitem using events
SWW_WI_REJECT - Reject work item
SWW_WI_EVENT_RECEIVE - Retrieve event for a workflow
SWW_WI_DISABLE - Lock workitem against execution
SWW_WI_ENABLE - Remove lock against execution of workitem