Go to start of metadata
How do I know I'm ready for this?
This is number 7 in a series of blogs on ABAP OO for workflow, so you it would be a really good idea to make sure you have worked through the first 6 blogs. The examples we'll use here continue on from those we used in the earlier blogs.Here's the list of the earlier blogs:
- Why use ABAP OO with Workflow?
- Getting started with ABAP OO for Workflow ... using the IF_WORKFLOW interface
- Using ABAP OO with Workflow Tasks
- Raising ABAP OO events for Workflow
- Using ABAP OO attributes in Workflows and Tasks
- Using functional methods in Workflows and Tasks
Which is better ABAP OO or BOR?
Clearly ABAP OO is far superior to BOR - much quicker for development, much more flexible, much less specialized - but if you are still asking this question now might be good time to go back and read the first blog "Why Use ABAP OO with Workflow?"Why would you need to use BOR and ABAP OO together?
The main reason for using BOR and ABAP OO together is to access provided SAP business objects for the content. Although newer workflows are now being written using ABAP OO for Workflow - such as Leave Request/Cancellation, and HR Admin Services forms - much of the existing content was originally written using BOR and has not yet been converted to ABAP OO. Whether BOR content is ever converted to ABAP OO depends on the priorities of the specific development area so you should NOT wait for old content to be converted.A secondary reason is because even though you are mainly working in ABAP OO you still want to raise events using a technique that does not yet support ABAP OO for Workflow. E.g. Status management events do not provide an ABAP OO option as yet (SAP NetWeaver 7.00 - July 2007).
How do you access a BOR object from an ABAP OO class?
The best approach is to access the BOR object as an attribute of your ABAP OO class. For our ZCL_PLANT example we have been using in the previous blogs, there is an older equivalent BOR object BUS0008. To link the BOR object to our ZCL_PLANT class we need to:- Create a constant with a prefilled type for the BOR object
- Create an attribute for our BOR object
- Fill the attribute value at runtime with the key of the BOR instance
- Reference the BOR object in our workflows/tasks
Here you see the constant C_BO_BUS0008 as an attribute of the example class ZCL_PLANT. By pressing the "Direct Type Entry" button we see the initial code: constants C_BO_BUS0008 value . "#EC NOTEXT
We need to change this to match the structure of the dictionary type SIBFLPORB but with the category always set to "BO" (BOR object) and the type always set to "BUS0008" (our chosen BOR object type). Of course the instance is left empty as we will not know the key value of our BOR object until runtime. CONSTANTS: BEGIN OF c_bo_bus0008, instid TYPE sibfboriid VALUE IS INITIAL, typeid TYPE sibftypeid VALUE 'BUS0008', catid TYPE sibfcatid VALUE 'BO', END OF c_bo_bus0008.
The attribute must use the dictionary type SIBFLPORB. Use your constant as the initial value of your attribute.
Note: This initial value is critical to using the BOR object in workflows and tasks. Without it, workflows and tasks will not be able to guarantee what BOR type will be available at runtime, and will therefore only be able to access the generic attributes/methods of the root BOR object OBJECT, instead of the attributes/methods of the chosen BOR object type.
Referencing the BOR object in your workflows and tasks is just the same as referencing an attribute of an ABAP OO for Workflow object. So this is the easy part.
Do I still need to use BOR macros in ABAP OO classes?
You will still need to use BOR macros in your ABAP OO classes if and only if you want to call BOR attributes and methods in your ABAP OO methods.If you need to do this then make sure you include the BOR macro definitions in your class by putting the special include program <cntn02> in the "Macros" section of your ABAP OO class. You can then use the usual workflow macros such as swc_get_property and swc_call_method in your ABAP OO methods. Note: I'm not going to discuss the use of these macros here - there's plenty of existing material and tutorials in the SAP Library help, in published books on SAP Workflow and in SDN blogs and forums.
Should I extend & delegate BOR objects - or do all my extensions in ABAP OO?
Having worked with both BOR and ABAP OO for Workflow for some time now, my strong recommendation would be to do all extensions in ABAP OO. The only exception to this is additional events on BOR objects if you are stuck with using BOR objects for eventing.I have even found it quicker and more effective to rewrite some of the provided SAP content in ABAP OO rather than use the existing content. For example the EMPLOYEET and BUS1065 employee objects both use HR Structural Authorizations, which is often more of a hindrance than a help in workflows where workflow heavily controls access to the data anyway. So I have often created my own ZCL_EMPLOYEE class to provide equivalent functionality using function module BAPI_EMPLOYEE_GETDATA to extract the necessary employee details, and which gives the option of bypassing the HR Structural Authorizations where appropriate.
What do I do about existing workflows based on BOR?
There's no need to convert existing workflows as such. However if you need to create a new workflow or make extensive changes to an existing workflow I would strongly recommend you consider converting to ABAP OO.If you are part of an upgrade project this is always a good time to consider reworking from BOR to ABAP OO, if only to widen the pool of developers able to maintain code called by your workflow - as of course any ABAP OO developer can work with ABAP OO for workflow.
***********************************************************
Go to start of metadata
Unknown macro: {gliffy}
Event An occurrence of a change of state in an object, which is published throughout the system.
An event is an object type component. The list of possible events is defined with the relevant object type in the Business Object Builder. This list can be extended according to customer requirements using the delegation concept. The actual creation of the events added must be catered for. Events can start, terminate or continue tasks and workflows. Examples of events are:
- Invoice entered
- Purchase order released
Event whose occurrence starts a task or a workflow. The event must be entered as a triggering event for the task or workflow that is to be started. The event linkage must be activated. A task or workflow can have several triggering events. Information from the event creation context can be passed in the binding from the event container to the task container or workflow container. The event must be defined as an object type component in the Business Object Builder.
Use of the event
You use an event in a workflow under the following circumstances
- In a task definition or in the version-independent basic data of a workflow as a triggering event.
- In task definiton as a terminating event.(The task is terminated when ever a event is occured)
- In version dependent basic data of the workflow.
- In a workflow defintion for steps of types Event Creator and Wait for event.
Start Workflow by Triggering a event
You can start a workflow when a event is triggered by specifying the business object and its associated event in the basic data of the workflow.
In the Basic data of the workflow we can even specify the name of the class and its related event as the triggering event.
*************************************************************************
What are advantages of SAP Business Workflows?
A business process can consist of several steps. Historically, thetasks have been coordinated manually or by some informal means
of communication (sticky note, e-mail, shouting, and so on).
The common problem in these approaches is :
- Inefficiency
- Each lacks a way to trace where a task is
- Who executed(or is executing it),
- How much time it requires.
- Workflow is a tool for automization of business processes
- Not tied up to any particular application
- Operates uniformly across applications
- Coordinate all participating tasks
- Provide users with active support
- Deadline Management is possible
- Contain a sequence of activities.
- Reoccur in the same or similar forms.
- Involve several people or groups of people.
- Require considerable coordination.
What are the layers in Workflow Architecture?
There are 3 layers in the Workflow Architecture:- Business Object
- Business Process
- Organization Model
How Process, Business Logic and People are linked in Workflows?
- The 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.
- 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.
What is a Business Object?
Business object (BO) is basically collection of Attributes, Methods and Events for a particular business entity. Example of BO: Sale Order, Vendor, Customer, Material etc.BOs wrap around backend tables, application code, change document and other technical information and expose them as Attributes, Methods and Events. Usually methods of BOs refer to BAPIs.
The following diagram explains BO much better:

back to top
What is an Agent and what are different types of 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 that can execute a task during runtime. Defines either in Org Structure or task.
- Excluded Agents: Persons who are excluded from taking action on a task. These are assigned in the workflow definition at the workflow activity.
back to top
What are the capabilities of Workflow Builder?
back to topWhat are Events?
Events are actions that occur in the system and that acts as trigger point for any workflow. Eg. Sales order creation. is an event.Eg; Consider a scenario where any sales order after creation subject to approval from superior. So here a workflow comes into play. The workflow needs to start whenever a Sales order is created. The business object BUS2032 is associated to sales order creation. It has event CREATED. So the trigger point or " START EVENTS " in the workflow is the BUS2032 's event CREATED.
Then bind the event to the workflow so the data flows from event to the Workflow. e.g.: Sales order is created. So for the workflow to proceed it'll need sales order details. With binding the respective values is mapped ito the workflow container.
Then activate the linkage once you are through the workflow creation. This is important as after this only the workflow will listen for the event, in the sense that after this only the workflow is triggered on the event. This is critical also as each active link adds to system load considerably and too many workflows in the test environment can bring the system down. So careful. Deactivate once test is over and workflow is no longer used.
back to top
What are the various methos of creating Events?
The various metods of creating Events are:-- Function module - event creation by calling function module
SWE_EVENT_CREATE or SAP_WAPI_CREATE_EVENT.
- Change documents
- Event creation when change documents are written.
- General status management
- Logistics Information System (LIS)
- Event creation upon status changes.
- Business Transaction Events
- Message Control
back to top
How can an Event be linked with a Workflow ?
Consider the start of any workflow. The START EVENTS tab is taken through the header. The Business Object is specified and binding is generated to the workflow to receive the values and then the link is activated.See the pic below for the Sales Order creation as start event for a workflow.**************************************************************************
Step Types
This Essentials guide does not discuss
the workflow design, but only the A BA P part of workflow programming. Nevertheless,
this section provides a brief summary of Possible workflow steps.
Activity
This step executes a single workflow
task. You usually embed a standard task (task beginning with "TS")
here that refers to a BO R method or an ABAP Objects class method.
A simple example o f this step type is
the sample workflow template WF_Verify038 for BO R
methods and the workflow template WF_Verify048
for
ABAP Objects classes.
Subworkflow
This step is generated as a normal
activity (IB), but a workflow
template (template beginning with "W S") is defined instead o f a standard
task. This changes the icon in the graphical Workflow Builder to H.
A simple example o f this step type is
the sample workflow template WF_Verify039 and the workflow
template WF_Verify020 .
Condition
This step evaluates a condition using
container elements o f the workflow container. This condition has two exits, TRUE
and FALSE.
A simple example o f this step type is
the sample Workflow template WF_Verify022 .
Multiple
Condition
The value o f a workflow container element
determines which branch in the workflow template is selected. Workflow branches
don't have to be defined for every possible value. You can also use a branch for
O
t h e r V a l u e s (O THERS).
A simple example o f this step type is
the sample Workflow template WF_Verify010 .
User
Decision
The SAP Business Workplace provides a
list o f predefined selection options. Each option corresponds to a branch in
the workflow template.
You can find an example o f this
technology in the Workflow template WF_Verify002 .
Undefined
Step
You can use an undefined step as a
placeholder fo r future steps during development (prototyping).
You can find an example o f this step
type in the workflow template WF_Verify002.
Container
Operation
The use o f constants and content o f
the workflow container enables you to fill additional elements in the workflow
container via assignments.
You can find an example o f this
technology in the Workflow template WF_Verify042.
Event
Creator
A n event is generated. The event
container is filled from the workflow container.
You can find examples o f this
technology in the workflow templates WF_Verify0 4 2
and WF_Verify043.
Wait
Step (Wait for Event)
The Workflow Engine waits to complete
this step until it receives a certain event.
You can find an example o f this
technology in the Workflow template WF_Verify043 .
Document
from Template
A document is generated from a
template. During this process, specific placeholders in the text are replaced w
ith workflow container content.
You can find an example o f this
technology in the Workflow template WF_Verify018.
Fork
This workflow step enables you to
generate multiple branches in the workflow template. These branches are
processed in parallel. You have to define the number of parallel branches and
determine how many o f these branches have to be fully processed before the
system closes the parallel area and continues with processing the "norm
al" workflow template. Alternatively, you can formulate an end condition that
completes the parallel area.
Simple examples o f this step type are
the workflow templates WF_Verify008 and WF_Verify009.
Process
Control
This step enables you to manipulate
the execution of a work item or an entire workflow . You can cancel work items or
define them as "obsolete."
Exam p les o f this step type include
the workflow templates WF_Verify012, WF_Verify013 , and WF_Verify014.
Loop
(U N T IL/W H ILE )
A step sequence is processed several
times. The termination criterion is checked either at the beginning (W H IL E )
or at the end (U N T IL) o f the loop.
You can find examples o f these loop
technologies in the workflow templates WF WF_Veri fy023 and WF_Veri fy024.
Send
Mail
The system sends the entered text as
an SAP email. For sending external emails, however, further administrative SAP
Basis activities need to be carried out.
You can find an example o f this
technology in the Workflow template WF_Verify032.
Form
Container elements o f the workflow
container are displayed or entered in a form.
A simple example o f this step type is
the sample Workflow template WF_Verify029.
Block
Blocks enable you to model a group o f
steps collectively and define deadline monitoring for the group's processing.
A rather complex example o f this step
type is the sample workflow template WF_Verify050 for dynamic sequences.
You can find another complex example o
f exception handling in blocks in the workflow template, WF_Verify046.
Local
Workflow
Local workflows are "free"
blocks. The Workflow Builder displays them next to the actual workflow
template. You start local workflow s via events. You can also store them as
modules in you r workflow template so that you obtain a workflow design with
components.
A simple example o f this step type is
the sample Workflow template WF_Verify042.
Web
Activity
Selected container elements are
generated as X M L binding and transferred to a web server. This enables you to
call a SOAP Web service from the Workflow .
The most obvious example o f this step
type is the sample workflow template WF_Verify101.
Ad
hoc Anchor
This step type enables an authorized
group o f persons to intervene in a running workflow. Here, the anchor is w
here one o f several predefined workflow templates is displayed as a subWorkflow.
This is a quite complex workflow
technology and makes sense only in a few revision scenarios.
**************************************************
This page will tell how to implement the three methods in workflow designing.
Screen shots with examples to be updated next
Synchronous methods allow for directly returning export parameters to the calling program, and this program can then evaluate the triggered exceptions.
- Secondary Methods.
- Before Methods
- After Methods.
Screen shots with examples to be updated next
Synchronous methods allow for directly returning export parameters to the calling program, and this program can then evaluate the triggered exceptions.
Asynchronous methods cannot return export parameters, because the responsibility for executing the actual program was handed over to an update task