Professional Documents
Culture Documents
SAP ABAP Workflows Day 2
SAP ABAP Workflows Day 2
SAP ABAP Workflows Day 2
Workflow Template
▪ The workflow templates are models, which you can copy and then adjust to represent your own
processes in the workflow.
▪ It is a design time version of the workflow. Whereas workflow instance is the run time version of the
workflow.
▪ Container Operation
▪ Used for calculation with the help of workflow containers
▪ Activity
▪ Business process / task to be executed
▪ E.g. Approval of purchase order
▪ Standard Task / Customer Task
▪ Condition
▪ A single condition check with two outcomes (True/False)
▪ Multiple Condition
▪ Multiple condition checks with multiple outcomes (Case / Switch)
▪ Loop
▪ Repeat the workflow steps till the condition is satisfied
▪ Fork
▪ Used when parallel processing is required which may or may not be based on any condition
▪ Process Control
▪ Wait
This step is used when we to wait for an event to happen or a condition to get satisfied so that we can proceed
further in workflow
▪ Wait for condition –
This step is complete when the specified condition is satisfied
▪ Wait for local event
Stops the execution of branch till the specified local event has occurred
▪ Wait for event
Stops the execution of the branch until the defined event of a particular object occurs
If event arrives it completes all the steps that are waiting for this event
▪ Wait for event using workflow
In this case an event can complete only one step. In case of multiple wait steps for the same
event, it completes the oldest wait step
▪ Event Creator
▪ To implement a BO event or a local event after the workflow has started
▪ Form
▪ To display the container elements at the time of execution
▪ Allows editing of the values in elements
▪ Local Workflow
▪ Model the part of the workflow that is started by local event
Workflow Tasks
▪ A task can be defined as an activity that can be executed within a workflow definition or
independently.
▪ Background Task
▪ Refers to automatically executable methods
▪ Does not require any user intervention for execution
▪ E.g. Email Sending Method, Automatic PO creation
▪ Dialog Task
▪ Requires user intervention for the execution of task
▪ E.g. Approval of leave, Approval of Shopping Cart
Agent Determination
▪ Types of agents
▪ Possible Agents
▪ People who can execute the task
▪ Defined at the task level
▪ This is the pool of agents that will be considered later to become an agent of the work item
▪ Responsible Agents
▪ People who are supposed to execute a particular work item
▪ Assigned at workflow step level (Can be assigned at task level too)
▪ These are determined at run time by using expressions or rules
▪ In expressions – agent data should be stored in container elements
▪ In rules – agent data is dynamically determined
▪ A Responsible agent can only process a work item if they are a possible agent and if they are not an
excluded agent.
▪ Types of agents
▪ Excluded Agents
▪ People who should not receive the work item for execution
▪ Always assigned by expression in workflow step
▪ Cannot be an agent of the task even if they are listed as a responsible and/or selected agent
The Selected Agents of the work item will be the ones that are
at the intersection of the Possible Agents and Responsible
Agents and are NOT included in the intersection of Excluded
Agents
This woman is in the pool of Possible Agents but she is not one
of the Responsible Agents so she will not be able to process
the work item.
▪ Agent Assignment
▪ Agent Assignment at the Workflow step level
▪ In case an agent is assigned at workflow step level then it’s a responsible agents.
▪ Agent can be assigned as a User, Role, Job etc.
▪ Further an agent id can be determined and stored in workflow container element and the container element
is assigned as expression in agents
▪ Agent Assignment
▪ Agent Assignment at the task level
Workflow Rules
▪ Transactions:
– PFAC_INS (Create).
– PFAC_CHG (Change).
– PFAC_DIS (Display).
– PFAC_DEL (Delete).
▪ Rule Resolution :
The following types of Rules can be resolved:
▪ Essentially, there are 4 types of rules that you can use in the Activity step type.
▪ The rule using organizational attributes is not used in the SAP R/3 component.
▪ Three of the four rules only require system settings; for the fourth solution, a customer-
specific function module must be defined in the system.
©La rsen & Toubro Infotech Ltd. Privileged and Confidential 25
Workflow Rules - Using Function to Be Executed
▪ 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.
▪ Scenario: Create a rule which will find the superior for any user/agent.
▪ Design:
▪ Create a custom table ZTEST_USERS which will contain the names, positions
of each user along with their superiors’ name.
▪ Source Code:
FUNCTION ZTEST_FIND_SUPERIOR.
*"--------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" AC_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" NOBODY_FOUND
*"--------------------------------------------------------------------
INCLUDE <cntn01>.
ENDFUNCTION.
▪ Exception- Go to the exception tab of the Custom Function Module and enter
the exceptions as required. Here we have added the Exception
NOBODY_FOUND.
▪ Go to the Container tab and create a container element for the agent/user
which will be passed to the function module by clicking the Create Button and
enter the values as shown.
▪ The rule is now created and we can test this rule in the PFAC transaction by
clicking the “Simulation” button on the application toolbar. Enter the user
name in the Container Element value section and press enter.
▪ It displays the name of the superior for the agent/user and the Agent Found is
displayed in Green color.
▪ Procedure:
▪ Go to PFAC_ INS/PFAC_CHG transaction for create/change rule.
▪ On the Rule Definition tab page, choose the category Agent Determination:
Responsibilities, and assign an abbreviation and a name for the rule.
▪ The Rule Container must contain the container elements whose values you
want the system to check when the rule is executed. At runtime, binding fills
the rule container with data from the task or workflow container.
▪ To create the rule container, you therefore need to know the definition of the
task or workflow container.
▪ Go to the Container tab and Choose.
▪ The Create container element dialog box appears. Make entries in the
Element, Name, and Short Description fields.
▪ Create either an object reference or an ABAP dictionary reference for the
container element.
▪ As a guide, you can use the data type reference of the container element of
the workflow or task container from which the container will be filled at runtime.
▪ On the Properties tab page, set, if required, the Obligatory and/or Multiline
indicators.
▪ Repeat steps 1 to 4 until you have defined all the necessary elements for the
rule container.
©La rsen & Toubro Infotech Ltd. Privileged and Confidential 42
Workflow Rules - Responsibilities
▪ Creating a Responsibility
▪ With a responsibility you define the container element values that you want to
trigger processing by the same users. In the responsibility, you define values or
value ranges for the container elements of the rule container. If you wish, you
can assign a priority to each responsibility.
▪ Go to the Responsibilities tab. Choose.
▪ Enter a single value or a value range for the container elements whose content
you want the system to check during rule resolution. If you want to check
several single values or value ranges for one container element, you can
create new entry rows.
▪ Position the cursor in a row with the container element for which you need a
new row, and choose
▪ Note:
– If you do not want to check a container element for a particular responsibility,
leave this line blank. The status of the responsibility is set to Responsibility
incomplete, in order to draw your attention to unchecked container elements.
– If you wish, give the responsibility a priority.
– The responsibilities with the highest priority are evaluated first.
Responsibilities with lower priorities are only evaluated if this is defined in the
rule definition.
▪ Enter a single value or a value range for the container elements whose content
you want the system to check during rule resolution. If you want to check
several single values or value ranges for one container element, you can
create new entry rows.
▪ Position the cursor in a row with the container element for which you need a
new row, and choose
▪ Note:
– If you do not want to check a container element for a particular responsibility,
leave this line blank. The status of the responsibility is set to Responsibility
incomplete, in order to draw your attention to unchecked container elements.
– If you wish, give the responsibility a priority.
– The responsibilities with the highest priority are evaluated first.
Responsibilities with lower priorities are only evaluated if this is defined in the
rule definition.
▪ Enter a single value or a value range for the container elements whose content you want
the system to check during rule resolution. If you want to check several single values or
value ranges for one container element, you can create new entry rows.
▪ Position the cursor in a row with the container element for which you need a new row,
and choose
▪ Save it.
Note:
• If you do not want to check a
container element for a particular
responsibility, leave this line blank.
The status of the responsibility is set
to Responsibility incomplete, in order
to draw your attention to unchecked
container elements.
• If you wish, give the responsibility a
priority.
• The responsibilities with the highest
priority are evaluated first.
Responsibilities with lower priorities
are only evaluated if this is defined
in the rule definition.
Deadline Monitoring
▪ E.g. If you are designing a workflow and the requirement is that a particular
Task, for example approval of employee’s leave request should be
completed by the manager within a given time frame then we can set a
deadline for the task. Once the deadline is reached, we can then apply
further logic using escalation functionality in order to escalate the approval
task(work) to their superior manager or any other agent/user as required by
the process.
▪ Following are different deadlines that can be monitored against each workflow
step:
– Requested Start
– Latest Start
– Requested End
– Latest End
▪ These can be defined at Workflow Step Level
▪ Requested Start
– This is Earliest point in time at which the work item can be executed.
– E.g. Even if the employee submits their travel request to the manager, the
company policy requires that a 2 days waiting period is required before the
manager can actually approve the request.
– A dialog work item (approver task) appears in the Business Workplace of the
manager when the requested start is reached if the work item is already available
for processing.
– If the dialog work item is not created until after the requested start, it appears
immediately in the Business Workplaces of its recipients.
– With background work items, execution starts when the requested start is reached
at the earliest.
▪ Latest Start
– Deadline by which one of the recipients of a work item must have started to
process it.
– E.g. If the employee submits their performance appraisal then it is required that the
manager should START reviewing the appraisal document within a certain period of
time.
©La rsen & Toubro Infotech Ltd. Privileged and Confidential 53
Deadline monitoring
▪ Requested End
– Deadline by which the processing of a work item should be terminated.
– E.g. In the above case of performance appraisal, the appraisal approval by
manager should complete within a given time period.
▪ Latest End
– Latest point in time for the processing of a work item to end
▪ In all practical cases Requested End and Latest End behave the same way, just that
if a user opens a work item ( Reserves the work item ) then the Requested End date
deadline will not kick in. Only the Latest End date will be valid. Hence usually its is
advisable to set Latest End greater than Requested End.
• Workflow Creation: Here you specify the time within which work item
should be executed after the creation of the workflow
• Expression: Here you can specify the date and time when the work item
should be executed. Container elements can be used to hold the date/time.
– Modeled
• In this case a local workflow event can be triggered which in turn may
execute a series of steps
©La rsen & Toubro Infotech Ltd. Privileged and Confidential 57
Deadline monitoring
Programming exits
▪ Program exits are like user exits given by SAP in SAP Workflows which can
be used to tweak standard workflow functionalities. Program exits are the
hooks given in SAP Workflows where we can execute additional methods
that are programmed when predefined events occur.
▪ Exit technology enables user-defined reporting/logging.
▪ Programmed response to the start and end of a workflow
▪ Programmed response to any change in the status of a work item
▪ Exit technology allows workflow designer to save data to their own tables at
set times while the workflow data is executed. You can then use this data to
create an application-specific reporting function based on unrestricted
application-related data, rather than on the technical status of the workflow
system.
▪ The exit class is called by the Work Item Manager (WIM) every time the status of the
work item is changed. When this happens, it receives the time (symbolic name) and the
work item context as parameters.
▪ You can also use the context object to query the following:
– The values of the properties saved in the step at the definition time
– The entire work item header
– The workflow container and the container of the current work item
▪ The exit class evaluates this information and fills a database specifically created for this
purpose (Reporting or User status table).
▪ While the workflow is being executed, you can read the status table using a user-defined
report.
▪ Currently the interface IF_SWF_IFS_WORKITEM_EXIT contains one method
▪ only: "event_raised". This method is called by the workflow system every time the status
is changed. Therefore, it must internally separate the possible calling times and respond
appropriately to each required time (for example, by calling a suitable private method).
▪ See the class CL_SWH_WORKITEM_EXIT. as a sample implementation.
▪ The parameter IM_EVENT_NAME contains the time when the exit class is
▪ currently called. Symbolic constants for all possible times are contained in the type pool
SWRCO.
▪ Below scenario explains the use of Program Exits in SAP Workflows to tweak
the SAP Work item functionality without making major changes at workflow
level.
▪ We are taking example of Journal Entry workflow which is triggered when
accounting document is parked.
▪ In Example Journal Entry workflow, the work items are sent to designated
approvers for approval for posting. Based on approval limits, the work items are
sent either for approval or for forwarding. Issue was that the work items were
moving out of the inbox, allowing the approver to approve even though
document was kept opened by another user, which was not correct. The
requirement was to stop the user from approving the work item if document was
being edited by another user and throw an error message.
▪ Pre-requisite:
▪ Custom ABAP classes are required to be put in program exit tab of SAP
Workflows.
▪ The ABAP Class used in program exits must support the interface
IF_SWF_IFS_WORKITEM_EXIT and this class must not have any call to the
RFC function modules also there shouldn't be any commit or roll back
statements in it. ©La rsen & Toubro Infotech Ltd. Privileged and Confidential 66
Programming exits - Example
▪ In Order to control the work items sent through decision steps above, we
introduced program exits in both the decision steps. For program exits, we
need to create ABAP Class