Alternate Workflow

119
SAP Business Workflow

description

Alternate Workflow training

Transcript of Alternate Workflow

  • SAP Business Workflow

    IBM Global Services

    Course Content

    IntroductionWorkflow architectureWorkflow Definition and workflow TemplateWorkflow steps in detailsTaskBusiness Objects and MethodsContainer Structure and Container ProgrammingEventsOrganisational structure and role resolutionDifferent types of AgentWorkflow and ALE

    IBM Global Services

    SAP Business Workflow

    SAP Business Workflow is a cross-application tool that makes it possible to integrate business tasks/processes between applications. This tool was introduced in R/3 Release 3.0A, and received a substantial facelift in the Enjoy Release, 4.6A,which warranted the new name Workflow Builder.

    IBM Global Services

    Need of Workflow

    Hmm ! Time to put in a purchase requisition request

    1

    3

    I guess Id better send off some inter-office mail to ask the approvers to approve my requisition.

    2

    I wonder who

    approves buying this stuff?

    5

    Time drags on . . .

    Meanwhile, in

    Mr. Managers office . . .

    What shall I do next?

    4

    TIME IS MONEY!!!

    1. In order to perform our demolition services, we need a regular supply of dynamite.

    2. Our project manager has run out of dynamite. So, he creates a purchase requisition for 20 cases. Since the cost of these cases is rather high, our requisition must be approved by two different managers.

    4. The first approving manager must be found. She needs to know that a requisition is waiting for her approval. The manager also needs to know which specific requisition is awaiting approval.

    5. The manager logons to the system and locate the requisition.

    6. If the manager chooses to reject the requisition, she will use manual means to inform the requisitioner (voice mail, e-mail, or in person).

    6a. When the requisitioner receives this notification, he will logon to the system, locate the requisition, and delete the line item and create a new one.

    7. If the manager chooses to approve the requisition, she will use manual means to inform the requisitioner (voice mail, e-mail, or in person).

    8. Then, the cycle will be repeated to find the second approver who will execute the same process.

    IBM Global Services

    Drawbacks

    Inefficiency.
    Each lacks a way to trace where a task is. Who executed or is executing it.How much time it required.

    IBM Global Services

    Why SAP Workflow

    Workflow ensures that the right work is sent to the right person at the
    right time in the right sequence with the right information. Tool for the automization of business processes Not tied up to any particular application Operates uniformly accross applications Coordinate all participating tasks Provide users with active support Intelligent routing

    IBM Global Services

    SAP Business Workflow Architecture

    IBM Global Services

    Workflow Architecture

    Organisational

    Level

    Process Level

    Business Object Level

    The key term here is 'workflow': the right agent doing the right work at the right time.

    The right work: Whatever you want to execute within a workflow. This work must be implemented as a method of a business object type in the Business Object Repository. Methods can be implemented as BAPIs. You can then call them from outside the system. BAPIs have an established static interface. The tool for maintaining business object types is the BOR (Business Object Repository).

    At the right time: The process level describes the business process in a sequence of individual steps. Together, these steps form the workflow definition. An individual step can refer to a method in the BOR, but it can also be used to control the process, for example, to allow loop processes, to query conditions or to fill the interface (= container) with values. The tool for maintaining the process level is the Workflow Builder.

    The right agent: The organizational level establishes the link to the organizational plan.
    - Each task that can be executed within a workflow has a group of possible agents.
    - By making further entries, this group can be restricted to the agent in the workflow step.

    - At runtime, selected agents receive a work item in their Business Workplaces.
    - If the work item is executed, the system starts the relevant method of the business object type.

    IBM Global Services

    Workflow Definition

    IBM Global Services

    Workflow Definition

    Workflow definition consists of

    Basic Data Information about triggering events Initial Values Containers Bindings

    A workflow definition describes the workflow process

    A workflow template contains:
    - The basic data of the workflow: this includes information about buffering reporting data, automatic forwarding, and so on.
    - Information about triggering events. If the specified event enters the system, the workflow starts if the event is actively linked to the workflow.
    - Initial values
    - Information about the interface (workflow and event container)
    - A link to the corresponding workflow definition, that is, information about the individual workflow steps that are to be executed.

    The binding identifies the relevant data required to execute the workflow. It establishes the connection between the input data required to execute a task and the output data as the result of the task, which has to be transferred to the next step in the workflow.

    IBM Global Services

    Workflow Builder

    The workflow definition is created in the Workflow Builder and displayed graphically in a network.

    Transaction: SWDD

    Menu Path:

    Tools Business Workflow Development Definition tools Workflow Builder.

    The Workflow Builder is subdivided into the following areas:
    - The abbreviation, version and status display of the workflow definition that is currently displayed.
    - Steps: A tree structure containing the workflow step sequence. Double-click a step to call the relevant step definition.
    - Step types: All step types available for Drag&Drop into the workflow definition.
    - Containers: These are workflow interface variables. You can use the context menu to create, change, display, delete and rename container elements.
    - My workflows and tasks: You can display tasks and workflows that are relevant for your workflow and double-click them to transfer them to your workflow definition.
    - Document templates: Create and display existing document templates.
    - Workflow Wizards: Display wizards to model steps and workflows.
    - Workflows of this definition: Display the runtime instances that are currently available.
    - Overview: Displays the entire workflow definition.
    - Message: All messages generated in the where-used lists and workflow tests are displayed here.

    The following areas are disjointed in the display: insertable step types, containers, my workflows and tasks, document templates, Workflow Wizards, and workflows of this definition. You have to choose one each time.

    IBM Global Services

    Workflow Definition - Steps

    A workflow definition is made up of individual modular steps.

    When you create a step in a workflow definition, you must specifiy the step type first.

    The following step types exist:
    - Steps that relate to business activities: Activity, user decision, document from template, Web activity, send mail, and form.
    - Steps for internal process control and process monitoring: Condition, multiple condition, loop, fork, container operation, event creator, wait for event, ad hoc, and anchor.

    The steps can be arranged in series or in parallel processing (fork).

    The processing sequence of the steps depends on the result of each preceding step.

    The possible results of a step are usually derived from the relevant business function and are specfied in the workflow step on the 'Outcomes' tab. The system adds another branch to the processing chain for each possible outcome.

    Depending on their type, all steps and events have certain symbols in the graphical display.

    IBM Global Services

    Example: Workflow Definition

    Whenever an employee creates a notification of absence( Event)

    The HOD should decide where or not to approve the request( Activity Approve Request)

    If Approved , the create of the notification of absence receives a message ( Activity Send Mail)

    If not Approved , the create of the notification of absence is asked to withdraw or change ( Activity Decision about request).

    If change request is send through a change request step

    The scenario is to be repeated Resubmit Step

    IBM Global Services

    How are Workflows Created in a System

    Within workflow templates, there is a key with the following structure:
    - A WS task abbreviation for the workflow template
    - An 8-digit sequence numberFrom the structure of the 8-digit number, the system knows whether the template is a standard template delivered by SAP or one created by the customer.
    Customer-defined templates start with the prefix number that was defined in Customizing for the system and client.

    IBM Global Services

    Working with Workflow

    IBM Global Services

    Workflow Design

    You have selected a business process and divided it into individual steps that can be executed in a workflow.

    Find the suitable object types in the Business Object Repository. Check that all required methods, attributes and events are available. If not, you need to enhance the object type.

    Check whether there are already tasks in the system for your desired steps. If not, you need to define new tasks.

    Organizational level agent assignment:
    You have determined organizational responsibilities and found the corresponding entries in your organizational plan. An agent can be an SAP user, an organizational unit, position, job, or activity.
    You may need to create the specific workflow units additionally in your organizational plan, or, using the organizational management, you may need to create links to existing units.

    Agent assignment:
    In the definition of the tasks you have to enter the largest possible agent group (= possible agents).
    In the workflow step used by the task, you reduce the possible agents according to demand. The intersection between the possible agents and those recognized in the workflow step forms the selected agents.

    IBM Global Services

    How workflow gets executed

    IBM Global Services

    Workflow Toolbox - SWUS

    Transaction: SWUS.
    Menu Path: Tools -> Business Workflow -> Development -> Runtime Tools-> Start Workflow (Test Environment).

    In the productive system, workflows are usually triggered by events. You can start a workflow for testing

    Transaction SWUI displays a list of small sample workflows. (toolbox principle)

    You can start the workflows and test them 'live'.

    Call the Workflow Builder and view the technical details for the workflow.

    Unlike transaction SWUS, which makes system workflows available to each user it can call, transaction SWUI only shows the user workflows in which he or she is explicitly named as the agent, or those workflows created as a general task.
    In the basic data of a workflow, you can use the 'Agent assignment for task' icon to maintain the possible agents of a workflow.

    IBM Global Services

    Workflow Steps

    IBM Global Services

    Workflow definition steps

    Workflow definition is made up of individual steps. When creating a step in a workflow definition, the step type must be specified first.

    There are

    Steps which refer to business activities (activities & user decision)

    Steps which are used for internal process control and monitoring (condition, multiple condition, loop, etc)

    IBM Global Services

    Business Activities Steps

    Activity

    Can be a single step task with basic business functionality

    Can be a multi-step task, which reference to a workflow definition

    User Decision

    This provides an opportunity for user interaction with the system.

    The response to this decides the selection of the subsequent step.

    Document from template

    PA document is created from a document template using variables in the text that are filled during program execution.

    Web Activity

    Selected container elements are posted using http protocol in XML or SOAP message

    Subworkflow

    An activity which refers to a workflow rather than a task

    IBM Global Services

    Internal process control Steps

    Condition

    Branch on the basis of control information from the runtime dependent context of the workflow.

    An attribute of this object can also be accessed for condition evaluation

    Condition evaluation can be done by

    Field comparison e.g constants , object attribute, system fields

    Multiple condition

    In contrast to condition, multiple condition makes it possible for the workflow definition to branch in more than two branches.

    For evaluation of the multiple condition, the value of the basis of comparison is checked at runtime against the comparison values and branched accordingly.

    IBM Global Services

    Internal process control (contd.)

    WHILE Loop

    Steps are processed repeatedly until the conditions contained in the WHILE step no longer apply.

    Until Loop

    Steps are processed repeatedly until the condition contained in the UNTIL step is true.

    Fork

    Used for parallel processing branches.

    Only a part of the parallel processing branches actually has to run to continue the workflow.

    Dynamic parallel processing is also possible

    IBM Global Services

    Internal process control (contd.)

    Send mail

    Text entered in this step can be used to send a mail to the agent assignedContainer operationsUsed to perform arithmetic operation of value assignment to workflow container elements using constants and data in the workflow container .

    IBM Global Services

    Internal process control (contd.)

    Event Creator

    An event is created when this step in the workflow is reached.

    Other workflows can be started as a reaction to the event created in this step. This event must be the triggering event of the relevant workflow tasks and/or templates.

    WAIT for event

    Used to stop the whole execution of the workflow until the event is created in the system.

    Used to wait for events for parallel processing

    IBM Global Services

    Task & Workflow Definition

    IBM Global Services

    IBM Global Services

    n (1) (11) Event creator fills event container using container macros; no binding.

    n (2) Binding between triggering event and workflow containers. This binding is essential.

    n (3) (8) Binding between workflow container and role container for setting the role input parameters. This binding is essential. (This only applies if the role was entered in the step definition. In the case of a default role in the task definition, the parameters are supplied from the work item container.)

    n (4) (7) (9) (13) Binding between workflow container and task container (work item container) for setting the input and reading the output parameters of the task. For this binding, it is irrelevant whether the underlying task is synchronous or asynchronous. The workflow builder generates a proposal for this binding in the step definition.

    n (5) (6) (10) Binding between task and method containers. For synchronous tasks, there is a binding for both the import and export parameters (5) and (6); for asynchronous tasks, only for import parameters (10). If this binding is not defined in the respective task, the task container is copied to the method container at runtime.

    n (12) Binding between event and task containers. This binding is necessary if the event contains data that was not previously contained in the task container (for example, with events from create methods).

    IBM Global Services

    IBM Global Services

    Similarities and differences of task types

    Customer Task (Type T)Standard Task (Type TS)

    Workflow Task (Type WF)Workflow Template (Type WS)

    Created by customer Created by SAP and customer

    With validity period Without validity period

    Client-dependent Client-independent

    Must be linked to its possible Must be linked to its possible

    agents when it is defined agents when it is defined

    SAPs recommendation is that all new tasks should be of type TS (see OSS 114811 for more details).

    Standard tasks and customer tasks are "single-step tasks" which describe business activities from an organizational perspective. These tasks describe what is to be done on a business object and also who is to do it.

    Single-step tasks refer to one object method and are linked to their possible agents in the organizational model.

    Standard tasks (object type TS) are supplied by SAP and can also be created by the customer, are client-independent and do not have a validity period. Of course, they do not come with possible agents assigned - you must assign them!

    Customer tasks (object type T) are created by the customer, are client-dependent and have a validity period.

    Roles may also be specified in single-step tasks. Rules are defined at task definition time using the roles, which are then used to determine the agent at runtime taking into account the runtime-dependent data. (Example: Determining the supervisor of the user who created the task; this user is not known until runtime.)

    SAPs recommendation is that all new workflow templates should be of Type WS (see OSS 114811 for more details).

    Multi-step tasks are designed to combine multiple single-step tasks into a flow. They come in two forms: workflow tasks and workflow templates.

    Workflow tasks and workflow templates describe a complete process. The business activity described by a multi-step task generally includes several steps which may have a complex arrangement. Examples of a multi-step task are:

    Process a job application

    Approval of an invoice

    Workflow templates (object type WS) are SAP supplied examples of commonly used multi-step tasks in executable form. They can also be created by the customer.

    Workflow templates are client-independent, and have no validity period. SAP-supplied workflow templates cannot be edited, but can be copied to an editable customer workflow template. Templates can only use standard tasks within their steps. Workflow templates can be used as examples for the implementation of business processes. In a workflow template, for any given step, the workflow agent definition is limited to the role and expression (container) types.

    Workflow tasks (object type WF) are client-dependent, have a validity period, and are created by the customer to implement their own specific business processes. Workflow tasks may only use customer tasks within their steps.

    IBM Global Services

    IBM Global Services

    Single-step tasks

    Single-step tasks describe elementary business activities.Single-step tasks operate on an object and refer to one object method each Single-step tasks are linked to their possible and permitted agents whose organizational assignments are described in the organizational plan of the enterprise.Executable single-step tasks are represented by work items at runtime.

    IBM Global Services

    Workflow definition - Multistep tasks

    A workflow definition has a modular structure consisting of individual steps which are linked together. The multistep tasks form the business framework for a workflow definition and each references one workflow definition.A step in a workflow definition can be an activity. An activity always refers to one task (= single-step task or multistep task).An activity with one simple triangle refers to a task.
    An activity with three triangles refers to a workflow (subworkflow).

    IBM Global Services

    Task Definition Synchronous and
    Asynchronous Methods

    A terminating event applies to one instance of a task only, that is, to one specific work item. The work item in turn refers to one specific object for the object type. You must specify a connection to this object for the terminating event.

    Example:
    A head of department has four work items for vacation approval. The request numbers are 2000 (work item 1), 2001 (work item 2), 2002 (work item 3) and 2003 (work item 4). Applicant 2002 deletes his entry. This means that the work item in the inbox is no longer required and must be deleted. The "Request deleted" terminating event must now be generated for object 2002. The existing work item is completed automatically if the 'Deleted' event is triggered in the system. The event must refer to the object on which the work item is based. The object is specified in the _WI_OBJECT_ID element.

    IBM Global Services

    Defining a Task

    First: Assign the business object type method to your task.

    Second: Assign the maximum number of possible agents. (Entry under the 'Additional data' -> 'Agent assignment' -> 'Maintain' menu option).

    You can refer to the organizational model or to an activity group. Create: Select the task, 'Agent assignment' menu option -> 'Create', select and specify the required organizational object.

    The task can also be a general task, that is, each SAP user is a possible agent. Create: Select the task, 'Attributes' button, 'General Task' indicator.

    Third: Define the work item text and required long texts for the task. You can insert workflow interface variables that will be triggered with the current data at runtime.

    If an asynchronous method call is used for the task, the method does not return confirmation of completion to the calling system when it is completed.
    Accordingly, the work item is not completed. An asynchronous method has to make the notification of completion known using an event. This event has to be entered as a 'terminating event' for the task.

    Triggering events are only required if the task is to be started independently of the workflow definition. You will find these types of events in the SAP System when handling IDOC errors, for example.

    IBM Global Services

    IBM Global Services

    Important Task Attributes

    General

    -Workitems can be executed and forwarded to any SAP User

    General Forwarding Allowed

    -Workitems can be forwarded to any user

    General Forwarding Not Allowed

    -Work items can be forwarded to possible users

    Forwarding not allowed

    -No forwarding allowed

    IBM Global Services

    Work Item

    Executable single-step tasks are represented by work items at runtime.Object that represents a task or action in the workflow system at runtime.Depending on the work item type, some of these work items are displayed in a user's work list. Other work items, on the other hand, are only used and processed internally. The work items are displayed in the integrated inboxes of their selected agents, and can be reserved and executed from there.

    IBM Global Services

    Work Items Types

    IBM Global Services

    Workitem Types

    W: Dialog work item

    Runtime display for a single step task with a user dialog

    D: Missed deadline work item

    The message recipient for the missed deadline is informed.

    F: Workflow work item

    Runtime representation of a multi step task

    B: Background work item

    Runtime display for a task executed in the background.

    E: Wait step work item:

    Runtime display for a wait step in the workflow definition.

    IBM Global Services

    Workitem Text

    Title of workitem in the Business WorkplaceFirst create the workitem text and position the cursor to include a varibleChoose the 'Insert variable' icon under the workitem text

    Processes request from &_WI_Object_ID.CreatedBy&

    Example

    IBM Global Services

    Task and its various component in SAP

    IBM Global Services

    Business Object Definition and Implementation

    IBM Global Services

    SAP Business Workflow has been developed on an object-oriented basis.The business object types are identified and described with their object methods in the Business Object Repository(BOR) of the R/3 System. Generally one object is created in the system and then processed in a workflow over several steps by various employees.

    Object Types & Workflow

    IBM Global Services

    Workflow deals with object types. Object types are definitions of data. In order to access database data, workflow uses the object type interface.Most of the information represented by object types is available in the ABAP/4 Dictionary.Objects are created at runtime and are specific instances of defined object types.Many object types are delivered by SAP. In addition, the customer can create new object types or extend SAP objects by creating subtypes (child objects). New customer objects or subtypes may be desired if the delivered SAP object does not contain all the characteristics (attributes) or processing options (methods) desired.

    Object Types & Objects

    IBM Global Services

    Object Type - Definition

    Possible status changes to an object type are defined in events.
    For example, the "material changed" event should occur if a material master is changed using transaction MM02.

    Creating an event for the object type in the BOR does not mean that it is automatically triggered at the appropriate time.
    The application must publish the event specifically in the system.

    Attributes can refer to fields in the DDIC and therefore to a database table, as well as to other object types. For example, the "Purchase order" attribute in the "Material" object type refers to the "Purchase order" object type (BUS2012). At runtime, all purchase orders are available for the "P-100" material, for example, and their attributes can be evaluated. You can also access the methods of the 'Purchase order' object type.

    Methods can refer to all functions defined in the SAP System.
    A method can call a report, transaction, function module, or any defined or customized ABAP code.

    IBM Global Services

    Interfaces

    Interfaces are a combination of attributes, methods, and events to be used in common among multiple object types. The purpose of interfaces is to define common functionality in one object type, and to assign that common functionality via an interface to multiple object types across the Business Object Repository. This avoids redundancy of data and functionality definition.Each new object type automatically receives the interface IFSAP, the SAP standard interface. IFSAP provides every object type with the following:

    Method Display

    Method ExistenceCheck

    Attribute ObjectType

    IBM Global Services

    Key Fields

    Key fields are designed to uniquely identify the object type.

    If the key field has a data type reference of a dictionary table field, the runtime

    system will look to that table field to retrieve the value of the key when

    processing the object. When the key field is created, the ABAP/4 program code

    is generated automatically when the object type is generated.

    IBM Global Services

    Attributes

    Attributes provides access to data.

    ABAP Dictionary Field

    Virtual

    Attributes are available as interface elements and can be incorporated into workflow texts. Attributes are also used in the workflow definition, for example, when formulating conditions, that is, they are used within the process control.

    Source:
    - ABAP Dictionary field: The value of the attribute is taken from a field in an SAP System database
    table at runtime.
    Example: Material short text of BUS1001 - Reference to the MAKTX field in the MAKT table.
    - Virtual: The attribute value must be determined dynamically at runtime according to the values of the object type.
    Example: All existing purchase orders for a material.

    Data type reference:
    - Reference to a dictionary field - Example: See material short text above.
    - Reference to an object type - Example: See all existing purchase orders above.

    If an attribute refers to another object type, its attributes and methods are also available in the program at runtime.

    For virtual attributes, customer-specific source code must be implemented in the program of the object type.

    Attribute properties: An attribute can have multiple lines (all purchase orders), and/or can be mandatory (must always have a value), or instance-independent (value does not depend on a particular object, for example, all IDOC message types in the SAP System).

    IBM Global Services

    Methods

    Methods incorporate the permitted functions available for an object.

    Methods have importing and exporting parameters as well as exceptions.

    Methods can be created using :

    Methods incorporate the permitted functions available for an object.

    For methods to work correctly, you may have to enter import parameters at runtime (defined in the interface for the method).

    Synchronous methods can return values to the calling program in the form of
    - Export parameters (defined in the interface for the method)
    - Result parameter
    - The possible result values are stored in a check table.
    - They are then "known" in the workflow definition, and are automatically inserted as the possible outcomes of the workflow step called by the method. Example: APPROVE method of
    the FORMABSENC object type.

    Asynchronous methods are the opposite of synchronous methods.
    Asynchronous methods can have import parameters, but they cannot have export parameters or result parameters.
    Reason: Asynchronous methods do not send a response to the calling program.

    To implement the method in the object type, proceed as follows:
    - Select a method, then select the "Create" button and enter the basic data.
    - Select the new method (using the "Program" button).
    As far as possible, the system will implement the method in the program when requested.

    IBM Global Services

    IBM Global Services

    Dialog / or background :

    Execution of the method is via a work item in a users integrated inbox or in background by the workflow runtime system. Background methods cannot use messages or exceptions because they cannot be processed by the background system and will result in termination of the program.

    Synchronous / Asynchronous Synchronous methods finish executing before handing control back to the calling program. These types of methods can return export parameters, results and exceptions. Asynchronous methods do not return control to the calling program immediately. Once executed, they depend upon events to communicate the results of the method back to the calling program. Asynchronous object methods cannot have results, export parameters or exceptions.

    Methods - Call attributes

    IBM Global Services

    Result:

    Synchronous methods may return an export parameter as a result. A

    result can be defined like a dictionary field or an object type .

    Instance independence:

    Indicates whether an object reference is passed to the method by binding

    at the time of execution. Methods that generate and return an object

    reference, such as Create, or methods that generate a report listing should

    be instance independent.

    Methods - Call attributes

    IBM Global Services

    Import /Export Parameters

    The method parameter container contains references to all import, export and result parameters which need to be exchanged back and forth between the calling program (single-step task) and the method. Binding is necessary between the single-step task and the method parameter container to accomplish the data transfer.Import parameters are those values which are necessary to execute the method. Import parameters are retrieved from the container CONTAINER using the macro instructions SWC_GET_ELEMENT (single-line) or SWC_GET_TABLE (multiline).Export parameter values are passed to the container CONTAINER using the macro instructions SWC_SET_ELEMENT (single-line) or SWC_SET_TABLE (multiline). The result parameter is passed to the CONTAINER element RESULT via the same macro instructions.

    IBM Global Services

    Exceptions

    Error handling is accomplished through the use of method exceptions (synchronous methods only). The workflow definition can branch according to these possible error states and allow for subsequent steps to handle these conditions. Messages and exceptions cannot be used with background methods because they will terminate the program.Number of the exception: 0001-1000: exceptions defined for interfaces1001-7999: application-specific exceptions (free for SAP development)8000-8999: exceptions raised by the object manager9000-9999: exceptions defined by the customer (free for customers)

    Error type:

    Temporary error: allows for situations where system resources are temporarily not available. The method may be called again at a later time. Temporary errors also occur when the method is locked by another user.

    Application error: caused by the application (table cannot be maintained; document does not exist)

    System error: incorrect configuration of the object manager; inconsistencies between the object type and the method (missing mandatory parameters)

    Message: needs application area and message number.

    IBM Global Services

    Exceptions

    Exceptions are implemented within a method, between the macro instructions BEGIN_METHOD and END_METHOD.EXIT_RETURN Code Variable1 Variable2 Variable3 Variable4.Code = the 4-digit number of the exceptionVariable1 through Variable4 correspond to up to 4 variables which can be derived from the message issued with the exception.The following exceptions (for temporary errors) are also available to allow exiting of the program:EXIT_OBJECT_NOT_FOUND = object not foundEXIT_CANCELLED = cancelled by the user

    IBM Global Services

    Events

    Events describe the change in the status of an object.

    Workflow are usually started using events

    Event parameters are defined to transport runtime application data from the creator of the event (the

    application) to the receiver of the event (a workflow, a single-step task, or an asynchronous method

    needing termination). If the application needs to send any data to the event receivers, event parameter

    container elements must be created in the definition environment and filled at runtime.

    Event parameters are defined as elements in the event container. The object type of the event is

    automatically created as an object reference (event parameter) in the event container.

    To create an event, position the cursor on the blue Event branch of the object hierarchy and follow the

    menu path Edit >Create. Provide an event name, short text and description. Events are created only

    symbolically at the object level.

    They must be published by the application code by one of the means discussed in the Event Definition

    And Implementation chapter.

    Event names may be defined in lower or upper case, but must be entered in event linkage in all upper

    case letters.

    IBM Global Services

    Object Type - Release Status

    Not accessible at runtime.Only in test or internal use, possibly unstable.Released for use by the customer.The functionality has been replaced. The old functionality is still supported for two releases.

    The "modeled" status is the only status in which execution is not possible. Customers should, however, only use components with the "released" status.

    The release information should be noted when a component's status changes to "obsolete".

    IBM Global Services

    Subtype

    The subtype inherits all attributes, methods and events of the supertype and is open for new customer-specific attributes, methods and events. The key fields of the supertype and subtype must be identical. This means that any methods and attributes defined on the parent can be executed and accessed on the child object.

    The analysis of an existing object type resulted in a need for additional attributes, methods, and events.
    You can only make changes directly in an object type provided by SAP if this modification is described in a SAPNet note.

    When creating a subtype, proceed as follows:
    - In the BOR, position the cursor on the standard object type.
    - Select the 'Create subtype' button.
    - Enter the required names in the subsequent dialog box. When assigning names use the customer
    namespace. By defining a sub-object type you are creating a new ABAP program. This is reflected
    in the program name.
    - The object type must be assigned when you save a development class. Otherwise it is not possible
    to release the object type.
    - Enhance the object type to suit your requirements.
    - Finally, set the entire object to the "implemented" status and then to "released". You must also set
    the status of each new component to "implemented" at least.

    IBM Global Services

    Delegation

    This delegation is powerful because it lets you implement your own business logic without modifying any SAP code. As long as the objects are properly delegated, your method will be executed.

    Calling

    Program

    KNA1

    Method:

    Change password

    ZKNA1

    Method:

    Change password

    Transaction: Menu Path: SW01

    Tools Business Workflow - Development - Definition tools - Business Object Builder - Settings - Delegate

    As an ABAP developer you have been given the task of implementing some security measures for the companys online store. The requirement is simple: The password must be at least six characters long.

    Modifying SAP code leads to costly and complicated upgrades due to the modified code being overwritten by the newly delivered SAP code. Therefore, The challenge is finding a way of implementing the business logic without modifying SAP code.

    After some investigation, you realize that the method CHANGEPASSWORD (in BAPI) on the object KNA1 (Customer) is called when customers change their passwords. All you need to do is create a subtype of KNA1 and then redefine the CHANGEPASSWORD method adding the ABAP code to ensure that the password is a minimum of six characters long. It is of course not wise to change SAP code even assuming you have the passwords, which can be provided only be SAP. After the method is redefined, you just need to implement the business rules in ABAP.

    Use the Business Object Builder to set up a delegation:
    Basic Menu - Tools - Business Workflow - Development - Definition tools - Business Object Builder - Settings - Delegate
    Change Mode - 'New Entries' Button
    Object type: Enter the supertype
    Delegation type: Enter the subtype
    Person reponsible: Whoever entered the delegation, that is, whoever is responsible for Customizing
    Caution:
    Do not enter anything into the GUI-specific field.

    You can create any number of subtypes for one supertype.
    However, only one of these subtypes can be selected as a delegation type.

    Testing delegations:
    Status before delegation:
    Display the required supertype in the Business Object Builder and select the 'Test' icon.
    You will not see any attributes, events or methods defined for the subtype.
    Status after delegation:
    Display the required supertype in the Business Object Builder and select the 'Test' icon.
    You will see all of the attributes, events and methods defined for the subtype and you can test the elements.

    IBM Global Services

    Objects in the workflow

    Workflow are usually started using events. The event defined in the BOR then acts as a triggering event. Events can complete workflow steps. In this case, the event is a terminating event.

    Tasks call the object type methods and therefore determine the function executed at runtime.

    You can use attributes in steps (condition, loops, and so on), but you can also use attributes in texts (work item text and the long texts for a task).

    You can change object type definitions without having to modify workflow definitions or organizational structures.

    IBM Global Services

    Business Object Repository (BOR)

    Transaction: Menu Path: SW01

    Tools Tools - Business Workflow Defination tool Busniness Object Builder

    BOR is a client-independent directory of all defined object types

    Each object type is assigned to a development class and, therefore, indirectly to an application component.

    IBM Global Services

    Containers and Bindings

    - Workflow -

    IBM Global Services

    Types of Containers

    There are 5 types of containers used in SAP Business Workflow.

    The task container always contains an element that can save the reference to the object to be processed in the relevant single-step task (_WI_Object_ID). It also contains the "_WI_Actual_Agent" element, which is the agent who actually executed the work item. For synchronous tasks with a defined result parameter, the '_WI_Result' element exists, which can save
    the result of the basic object method.

    The workflow container always contains an element that can store the user name of the "initiator" of the current workflow (_WF_Initiator). For most workflows you must create a new element in the workflow container. To do this, you can either accept the SAP proposals, or you can create your own element. For example, you have to provide a storage element for the main object of your process.

    The event container always contains an element that can save the (object) reference to the object whose change of status is made known using the event '_EVT_Object' element. It also always contains an element with the name of the user responsible for changing the status of the object ('_EVT_Creator').

    The rule container contains the elements required as an entry for the rule resolution at runtime.
    If you define a default rule for the task, the binding can also occur from the task in the rule.

    The method container contains elements that are import parameters in connection with the method execution. You use macros to make the values available in the method.

    376.unknown825.unknown378.unknown379.unknown380.unknown

    IBM Global Services

    Workflow Container

    The workflow container contains workflow-specific system variables and other elements which are defined explicitly.As part of the definition of the workflow task, the import and export parameters of the workflow are defined as elements of the workflow container.When the workflow is defined in the workflow editor, elements can also be added to the workflow container. These elements are then "local variables" within a workflow definition and can be used, for example, to set up a counting loop.

    IBM Global Services

    Task Container

    Each task container already contains the workflow system variable and any additional elements for the method parameters of the referenced object method.You have to add additional elements to the task container for additional values are required for variable replacement in the work item text or in the long texts

    IBM Global Services

    Other Types of Containers

    Event parameter container

    Contains an element which can take the (object) reference to the object

    whose change of status is announced via the event.

    Role parameter container

    Contains the elements required as input in connection with the role

    resolution to be run at runtime.

    Method parameter container

    Contains elements which will be required as import and export parameters

    in connection with the method execution.

    IBM Global Services

    What is a Container?

    Field values
    Multiline lists
    of field values
    Object
    references

    Container

    Definition

    Container

    Instance

    Application

    Data

    R/3

    Definition

    Runtime

    A container is a table like structure for collecting and storing data within the workflow and its components.

    A container definition defines the structure of the data values to be stored in the container instance. A container definition is assigned to the following
    workflow components:

    Object Method

    Role Parameters

    Customer/Standard Tasks

    Workflow Definition

    Container definitions are defined in the various workflow components by a container editor.

    A container instance is a runtime representation of a container definition. It refers to field values, multiline field values or object types.

    Application data is not stored directly in the container instances. The data utilised within a workflow is managed by the application and stored in the database.

    Data assignment to a container element is carried out by:

    Dataflow between container elements

    Assignment of values by an application program

    783.unknown784.unknown785.unknown

    IBM Global Services

    Defining Container Elements

    Element nameData type DescriptionMulti-lineValue

    reference

    Element 1Database FieldDescription 1

    Element 2Database FieldDescription 2X

    Element 3Object TypeDescription 3X

    Definition

    Runtime

    A container editor allows individual container elements to be created and edited.

    Functions available in the container editor include:

    Creating new container elements

    Editing container elements

    Changing views of the container elements

    Selecting container elements for deletion, copying, and cut and paste operations

    Sorting and filtering container elements

    Element names must begin with a letter. The element name can be automatically assigned by the ABAP/4 Dictionary field name.

    IBM Global Services

    Binding

    A binding is simply the art of of pouring selected container elements from one container into another. The binding editor is available when defining:

    Workflow definitions

    Triggering events

    Workflow steps

    Workflow steps ( Standard roles/ Object methods with parameters)

    The binding editor always references the container to receive the application data. Binding definitions can reference:

    Constants

    Variables (container elements)

    System fields

    IBM Global Services

    Container & Dataflow

    Task

    Container

    Method
    Container

    Event
    Container

    Workflow
    Container

    triggering

    event

    sync

    task

    sync

    method

    sync

    task

    sync

    method

    role

    async

    task

    async

    method

    terminating

    event

    Role
    Container

    4

    1

    2

    3

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    Data flows between the workflow components as follows:

    1)Triggering event is created in application.

    2)The workflow receives the application data from the event.

    3)The workflow step transfers application data from the workflow to the synchronous customer/standard task.

    4)The task transfers application data from the task to the object method parameters.

    5)The execution of the object method may change the application data. The object method parameters transfer data to the task.

    6)The task transfers application data back to the workflow.

    7)The workflow step transfers application data from the workflow to the synchronous customer/standard task.

    8)The workflow step transfers application data to the standard role parameters.

    9)The task transfers application data from the task to the object
    method parameters.

    10)The execution of the object method may change the application data. The object method parameters transfer data to the task.

    11)The task transfers application data back to the workflow.

    12)The workflow step transfers application data from the workflow to the asynchronous customer/standard task.

    13)The task transfers application data from the task to the object
    method parameters.

    14)The terminating event transfers application data to the task.

    15)The task transfers application data back to the workflow.

    381.unknown

    IBM Global Services

    Container Data Structure

    SWC_CONTAINER

    SWC_CREATE_CONTAINER

    SWC_RELEASE_CONTAINER

    Declare Container

    Initialize Container

    Release Container

    If you are creating function modules for event creation, you will need to create, initialise and release containers. In an object type implementation program, this is unnecessary. A container called CONTAINER is created automatically and the macros to manipulate the values of the container elements are at your disposal through the include.

    The following macro instructions define and control containers:

    SWC_CONTAINER ContainerName: Declares a container called ContainerName.

    SWC_CREATE_CONTAINER ContainerName: Initialises the container called ContainerName. ContainerName must be previously declared. A container cannot be edited until it has been initialised.

    SWC_RELEASE_CONTAINER ContainerName: Releases the container called ContainerName. A container cannot be edited after it has been released.

    Throughout the remainder of this chapter, assume that unless you are coding in an object implementation program, you will need to incorporate the includes or and use the appropriate macros to declare and initialise containers before using the other macros to write values to containers or read values from them.

    IBM Global Services

    Writing/Reading Container Elements Defined as Field Values

    SWC_GET_ELEMENT

    SWC_SET_ELEMENT

    Variable

    Container

    Instance

    Variable

    SWC_GET_TABLE

    SWC_SET_TABLE

    delete value

    Internal
    Table

    Internal
    Table

    SWC_DELETE_ELEMENT

    The following macro instructions retrieve and set the values of container elements which are defined by fields :

    SWC_GET_ELEMENT ContainerName ElementName Variable: Retrieves the value from element ElementName in container ContainerName and places it in Variable. If the element does not exist in the container, SY-SUBRC will be set to 1; otherwise it will be 0.

    SWC_SET_ELEMENT ContainerName ElementName Variable: Assigns the value from Variable to the element ElementName in container ContainerName. If the element exists in the container, its value is overwritten; if it does not exist, its value is appended to the end of the container with this new value.

    NOTE: ElementName must be typed in the macro instruction exactly as it is represented in the container definition, including lower and upper case letters. ElementName must be in single quotes.

    782.unknown

    IBM Global Services

    Writing to Container Elements Defined as Object Types

    Container

    Instance:

    CONTAINER

    Object

    Element:

    MATRL

    Declare a variable as an object:

    DATA: MATERIAL TYPE SWC_OBJECT.

    Create an instance of your object in your program:

    SWC_CREATE_OBJECT MATERIAL MARA MATNR.

    Declare a variable as the key of your object:

    DATA: MATNR LIKE MARA-MATNR.

    Fill the key with a value:

    MATNR = 123456.

    Object type from B.O.R.

    Key of object you previously defined

    Transfer value of your object instance to the container element:

    SWC_SET_ELEMENT CONTAINER MATNR MATERIAL

    To transfer the value of an object reference in your program to a container element defined to be the structure of an object type, several steps are necessary:

    Declare a variable for the key fields of your object : To declare a variable to hold the key field(s) of the object, use the data statement and declare the key field(s) to be like a type, field or structure from the ABAP/4 Dictionary.

    DATA KEY LIKE , or

    DATA: BEGIN OF KEY,
    KEY1 LIKE . . .,
    KEY2 LIKE . . .,
    END OF KEY.

    Assign value(s) to your key fields using the usual ABAP syntax.

    Declare a variable as an object, use the following syntax:

    DATA ObjectVariable TYPE SWC_OBJECT.

    To create an object instance in your program, use the following macro instruction:

    SWC_CREATE_OBJECT ObjectVariable ObjectType ObjectKey. ObjectType should be in single quotes.

    Transfer the value of your object instance to the container element defined to be like an object with the following macro:

    SWC_SET_ELEMENT ContainerName ElementName ObjectVariable: Assigns the value from ObjectVariable to the element ElementName in container ContainerName.

    IBM Global Services

    Reading Container Elements
    Defined as Object Types

    Container

    Instance:

    CONTAINER

    Declare a variable as an object:

    DATA: MATERIAL TYPE SWC_OBJECT.

    Object Element:

    MATRL

    Read value of container element to your object:

    SWC_GET_ELEMENT CONTAINER MATRL MATERIAL.

    Declare a variable as the key of your object:

    DATA: MATNR LIKE MARA-MATNR.

    Read the object type key into your variable:

    SWC_GET_OBJECT_KEY MATERIAL MATNR.

    Declare a variable to hold the object type:

    DATA: OBJTYPE LIKE SWOTOBJID-OBJTYPE.

    Obtain the object type from your object type variable:

    SWC_GET_OBJECT_TYPE MATERIAL OBJTYPE.

    To transfer the value of an object reference from the container to a variable defined in your program, several steps are necessary:

    Declare a variable for your object:

    DATA: ObjectVariable TYPE SWC_OBJECT.

    Read the value of the container element into your object:

    SWC_GET_ELEMENT ContainerName ElementName ObjectVariable.

    To obtain the key field values of this object, declare a variable to hold the key field(s) of the object. Check the object type key field definitions to make sure you declare your object variable key to be identical in structure.

    DATA Key LIKE , or

    DATA: BEGIN OF Key,
    Key1 like . . .,
    Key2 like . . .,
    END OF Key.

    To obtain the key field(s) value(s), read the object type key into your key variable:

    SWC_GET_OBJECT_KEY ObjectVariable Key.

    To obtain the object type from the object variable, declare a variable to hold the type and then call the following macro:

    DATA: OTypeVariable LIKE SWOTOBJID-OBJTYPE.

    SWC_GET_OBJECT_TYPE ObjectVariable OTypeVariable.

    IBM Global Services

    Writing to Container Elements Defined as Multiline Object Types

    Container

    Instance:

    CONTAINER

    Element:

    PRItems

    Declare a variable as an internal table object:

    DATA: REQITEMS TYPE SWC_OBJECT OCCURS 0.

    Create an instance of your object for each table line:

    SWC_CREATE_OBJECT REQITEM BUS2009 PREQKEY.

    Once the internal table is filled, transfer the internal table to the

    multiline container element:

    SWC_SET_TABLE CONTAINER PRItems REQITEMS.

    Since this internal table has no header, declare a

    work area: DATA: REQITEM TYPE SWC_OBJECT.

    Declare key fields of the object

    (e.g. called PREQKEY) and fill them

    (e.g. within a select loop).

    Append the object instance to the internal table:

    APPEND REQITEM TO REQITEMS.

    Example:

    * declare internal table object, object work area and key structure of object

    data: reqitems type swc_object occurs 0.

    data: reqitem type swc_object.

    data: begin of preqkey,
    number like eban-banf,
    item like eban-bnfpo,
    end of preqkey.

    select purchase reqn. records from eban and fill the key fields defined above

    select * from eban.

    preqkey-number = eban-banf.

    preqkey-item = eban-bnfpo.

    create an object instance for each record drawn from eban

    swc_create_object reqitem BUS2009 preqkey.

    append this object to the object internal table

    append reqitem to reqitems.

    endselect.

    transfer the internal table entries out to the multiline container element.

    swc_set_table container PRItems reqitems.

    IBM Global Services

    Reading Container Elements
    Defined as Multiline Object Types

    Container

    Instance:

    CONTAINER

    Object Element:

    PRItems

    Read value of multiline container element

    into your internal table object:

    SWC_GET_TABLE CONTAINER PRItems REQITEMS.

    Declare your object:

    DATA: REQITEM TYPE SWC_OBJECT.

    Loop through your internal table object

    REQITEMS into individual REQITEM entries.

    Perform operations as needed.

    Use this macro to get the keys of each entry:

    SWC_GET_OBJECT_KEY REQITEMS PREQKEY

    Use this macro to get the object type of each entry:

    SWC_GET_OBJECT_TYPE REQITEMS OBJTYPE.

    Declare a variable to hold the object type:

    DATA: OBJTYPE LIKE SWOTOBJID-OBJTYPE.

    To transfer the value of a multiline object reference from the container to the internal table object defined in your program, several steps are necessary:

    Read the value of the multiline object container element into your internal table object:

    SWC_GET_TABLE ContainerName ElementName TabObjects.

    Declare a variable for your internal table object:

    DATA TabObject TYPE SWC_OBJECT.

    Loop through the TabObjects internal table into TabObject, manipulating the individual lines as necessary.

    To obtain the key field(s) value(s), read the object type key into your key variable:

    Define the key field(s) of the object.

    DATA Key like , or

    DATA: BEGIN OF Key
    Key1 like . . .,
    Key2 like . . .,
    END OF Key.

    SWC_GET_OBJECT_KEY TabObjects Key.

    To obtain the object type from the multiline object, declare a variable to hold the type and then call the following macro:

    DATA: OTypeVariable LIKE SWOTOBJID-OBJTYPE.

    SWC_GET_OBJECT_TYPE TabObjects OTypeVariable

    IBM Global Services

    Events

    IBM Global Services

    Event

    An event describes a possible status change for an object in the SAP System.Before an event can be used in a workflow, it must be defined in the Business Object Repository for the object type.
    Events must be triggered explicitly. The application itself can be the triggering agent.

    IBM Global Services

    Types of Event Creation

    Change

    Document

    Status

    Management

    Message

    Control

    Specific

    HR Tables

    ABAP Code

    In User Exit

    There are four ways to create customer specific instances of events:

    Change documents

    Status management

    Message control

    Calling a function module

    It is possible to extend an object type with additional events and create these events without additional programming. It is recommended that you explore these configurable event creators first, i.e.. change document, status management and message control. (These were previously discussed in the Event configuration section.)

    Only if the configurable event creator do not meet your requirements would you explore creating an event via ABAP/4 application program code.

    Program code can be used to create the event by:

    Adding the event creation function module to a user exit. Note: Be careful that the commit work code is at the appropriate stage in conjunction with the user exit.

    Executing an on-line program or scheduled batch job containing the event creation function module. (Disadvantages with batch jobs are: not real time; potential work item collisions)

    SAP core modification to add the function module to the application code (not recommended).

    IBM Global Services

    Using Customizing for event trigger

    Menu Path :Basic menu -> Tools -> Business Workflow -> Development -> Definition tools -> Events

    IBM Global Services

    Event Creation of Change Document

    Changing

    Master data

    Event linkage is

    done to connect to

    the workflow/ task

    Event creation

    (SWEC)

    Change logged

    using

    change documents

    IBM Global Services

    Event Creation of Status Management

    Event linkage is

    done to connect to

    the workflow/ task

    Event creation

    (BSVW )

    Status

    Management

    When user status

    changes to E002 ,

    event is triggered

    Assign the status object to a schema and specify what event and what object type you want to trigger.

    Then select the entry and under 'Status restrictions' specify the status that should trigger the event.

    You can find the system status using transactions BS22, BS12 and BS02.
    Selecting the appropriate status requires knowledge of the application.

    IBM Global Services

    Event Creation of Message Control

    Create Message type and define

    workflow as transmission medium

    Create Condition Table

    Create Access Sequence

    Assign Access Sequence

    to defined message type

    Define Condition Records

    Assign message type To procedure

    Triggering an event using message control occurs with NAST.

    Maintain the processing program RSWEMC01

    with the FORM routine CREATE_EVENT for

    the output type EVEN and transmission

    medium 9.

    IBM Global Services

    Using ABAP Code

    This is using done by writing custom code e.g. by using SAP FM like

    SWE_EVENT_CREATE inside user exits, BADI etc.

    CALL FUNCTION 'SWE_EVENT_CREATE'

    EXPORTING

    OBJTYPE = OBJTYPE

    OBJKEY = OBJKEY

    EVENT = EVENT

    CREATOR = APPLICANT

    START_WITH_DELAY = ' '

    IMPORTING

    EVENT_ID = EVENTID

    TABLES

    EVENT_CONTAINER = CONTAINER

    EXCEPTIONS

    OBJTYPE_NOT_FOUND = 01.

    IF SY-SUBRC = 0.

    COMMIT WORK.

    ENDIF.

    INCLUDE . Tells the program we are using Workflow Macros

    PARAMETER: SALESORD LIKE VBAK-VBELN.

    DATA: OBJTYPE LIKE SWETYPECOU-OBJTYPE, Business Workflow -> Utilities > Other tools >Event linkage

    The type linkage table can be accessed from the SAP Business Workflow Development Menu, Utilities > Other tools >Event linkage or transaction SWE2

    Each type linkage entry contains the following details:

    Object type: Name of the object type initiating the event

    Event: Name of the event created, which must be part of above object type

    Receiver type: The element manipulated by the creation of the event

    This can be a single-step or multi-step task, a work item requiring a terminating event, or a wait step in a workflow

    The receiver type may be left blank and determined by the receiver type function module

    The receiver type is input to the receiver function module

    Receiver function module: Name of the function module to respond to the creation of the event

    Check function module (optional): Name of the function module to further determine if the receiver should receive the event by execution of the receiver function module

    Receiver type function module (optional): Name of the function module that can determine the receiver type

    Destination (optional): SAP R/3 instance in which the receiver function module is to be executed

    Global indicator: Dictates that the receiver function module is to be executed every time the event of the object type is created irrespective of the object (instance of the object type) generating the event. Indicator set indicates that instance linkage is not evaluated

    Enabled indicator: Dictates whether the type linkage is activated

    IBM Global Services

    Event Trace

    Transaction: SWEL

    Menu Path :Basic menu -> Tools -> Business Workflow -> Development -> Utilities ->

    Events -> Event Trace.

    IBM Global Services

    Organisational Structure

    IBM Global Services

    Organizational Structure Business Scenario

    An organizational plan in SAP describes the organizational structure of a company.The workflow system finds the agents of the individual tasks by evaluating the organizational planThe functions to create and maintain organizational plans are part of the Personnel Planning and Development (PD) part of the SAP HR moduleYou must connect this organizational structure to the workflow

    IBM Global Services

    Organizational units contain positions, occupied by employees.Jobs are abstract descriptions of task assignments.Positions can be linked to jobs. They inherit all the tasks assigned to that job. Users. A user is an SAP logon user ID. It thus represents a single person.Persons. A person is a specific employee created in the HR module.Workflow tasks can be assigned to organizational units, positions, jobs or users. The workflow system uses organizational structure to route work items to the correct recipients

    Organizational Management

    Any organizational plan consists of five kinds of classifications:

    Organizational units. Each organizational unit represents a recognizable group in the organization. This may be a department, a team, a building, etc. Organizational units are hierarchical; that is, they can contain other organizational units as subordinates. For example, a department may be made up of multiple teams, or a company unit may have multiple departments.

    Generally, one organizational unit forms the root of the hierarchy and contains all other organizational units as subordinates.

    Positions. A position represents a slot in an organizational unit filled by a single person, or shared among two or more people. Two examples are H/R Manager and A/P Clerk.

    Jobs. A job is a more general description of a position. A single job can describe multiple positions across multiple organizational units. There is, therefore, a one-to-many relationship between jobs and positions.

    Users. A user is an SAP logon user ID. It thus represents a single person.

    Persons. A person is a specific employee created in the HR module. In order for a person to be usable in a Workflow scenario, we must assign the person to a user, since only a user has access to the SAP mail system. This is configured as part of the HR implementation.

    IBM Global Services

    Create Organisational Plan

    Create root organizational unit

    Additional organizational units

    Create jobs

    Create positions

    Assign Holders

    Assign tasks

    Transaction: Menu Path: PPOCW

    Tools Business Workflow - Development - Environment - Organizational Management - Simple Maintenance Org plan basic data - Create

    Create Executive Board

    Create Sales region , Production

    Administrator , Sales Manager

    Sales Manager eastern Zone

    Create Sales Order

    The first step in simple maintenance involves creating the root organizational unit. Once this organizational unit has been created, create the appropriate lower-level organizational units.

    Organizational units and jobs may be created in any order, but they must exist before the related positions are created.

    Jobs may exist in the job index, or they may be created once the model contains an organizational unit.

    Positions are created after the corresponding jobs have been created in the job index.

    Caution:
    In the SAP R/3 Release 4.6B component, you must define a position first. You can then create the job with reference to the position.

    Holders are assigned to positions, not to jobs.

    The next slide shows the link between workflow tasks and organizational objects.

    The maintenance of SAP Organizational Management is available as a Basis component.

    The Create Organizational Unit icon allows you to create and maintain the organizational structure for your organizational plan.

    The Create Position icon allows you to create the positions again as part of your organizational plan.

    The Tasks function allows you to create, maintain and view assignments for jobs, positions, and users.

    IBM Global Services

    Position: Secretary

    Position: FI administrator 1

    Position: FI administrator 2

    Organizational unit: FI department

    Position: Head of FI depatment

    Job for FI employee

    User 1

    Manager job

    Job for secretary

    User 2

    User 3

    User 2

    Task

    Task

    Task

    Assigment Workflow Task Organizational Objects

    IBM Global Services

    Agent Assignment and

    Role Resolution

    - Workflow -

    IBM Global Services

    Agent

    Agent is an executor of a work item.Agent is responsible for executing a task in a workflow. Agent is determined by the system either through organizational chart or directly if user is assigned as agent for a particular task.If the agents of the individual workflow steps are determined using the customer-specific organizational chart, your agent assignment in the workflow remains flexible to change.

    IBM Global Services

    Types of Agents

    Deadline Agents

    Notification Agents

    Processing Agents

    Selected agents

    are those possible agents who are elected to execute a task at runtime

    Possible agents

    are a collection of agents who qualify to execute a work item

    Actual agent is the agent among those selected agents who actually processes the work item

    The processing agent: The person(s) who actually processes the work item.

    The deadline agent: The person(s) informed when a work item is not processed fully within the specified deadline. This notification is received via a deadline work item in the deadline agents integrated inbox.

    The notification agent: The person(s) notified when an activity step is fully processed. This notification is received via a notification e-mail in the notification agents SAP office e-mail.

    IBM Global Services

    Role Resolution

    List of possible agents

    (executors) of a task

    (All supervisors in a dept.)

    Selected Agent(s)
    (Mr. Banning)

    (Supervisor of

    User PBACON)

    Role = Rules

    A role defines rules by which selected agents can be determined at runtime through

    role resolution. Role resolution restricts the number of possible agents.

    Role Resolution

    When a default role is specified at the task definition level, or a standard role is specified for responsibility at the workflow step level, role resolution occurs at runtime. For example, a default role for approving a vacation request would be the supervisor of the user submitting the request. At runtime, role resolution would determine, from the set of all possible supervisors, the specific supervisor of the user submitting the request. This specific supervisor would be the selected agent for approving the request.

    A role defines rules by which selected agents can be determined at runtime through role resolution. Role resolution restricts the number of possible agents.

    Role resolution is performed through function modules or organisational objects. See section the Creating Roles chapter in the Programming section for details on how to build a role.

    The input values to the role resolution function module consist of role parameters. Role parameters create elements in the role parameter container.

    At runtime, the role container is filled with all necessary information through the binding definition from the workflow container or task container to the role container. The role container is a parameter of the roles function module.

    The role resolution process executes the function module. The algorithm in the function module determines selected agents and inserts them in an internal table that is a parameter of the function module. This is returned directly to the workflow runtime system.

    IBM Global Services

    Standard Rules

    A rule container is defined for each rule.

    The rule parameters determine which information is required for the rule resolution

    to be executed at runtime.

    If an error occurs during rule resolution, setting the termination indicator for the rule

    resolution determines how the workflow will continue:

    Flag is selected - the workflow assumes an Error status and a notification is sent

    to the workflow administrator.

    Indicator is not activated - the workflow forwards this work item to ALL possible

    agents.

    IBM Global Services

    Rule Basics

    Transaction : PFAC_INS(Create)

    Menu Path: Tools Business Workflow Development Definition tools Rules for Agent Assignment Create/Change/Display.

    Each rule gets a 8 digit generated by the system prefixed with AC

    Rules can be tested using PFTC or by function module RH_GET_ACTORS

    IBM Global Services

    Rule Definition in a Activity Step Type

    Various options to create standard rules :

    Responsibility (Pure configuration no ABAP coding)

    Defined Value ranges are assigned to Agents

    Data is filled from workflow container at runtime

    Evulution paths (Pure configuration no ABAP coding)

    Organizational data (Pure configuration no ABAP coding)

    Jobs , positions

    Functions to be executed ABAP Code Function Module

    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.

    Organizational data:
    Rules using organizational data require an SAP organizational object type in the system. Table T7791 contains the delivered SAP organizational object types and information about which organizational object types can be linked to them. Within the object type processed by the workflow, one element must refer to this SAP organizational object type. The SAP organizational object type is linked to agents using organizational units, positions or jobs. For more information, see the appendix of this folder or the workflow documentation. The key word is "Organizational object".

    Responsibilities:
    As of Release 4.0, you can define rules using responsibilities. In the rule container, you define variables that are filled with values at runtime. You also define value ranges for these variables and assign agents to the different value ranges.

    IBM Global Services

    Rule Definition with Responsibility: Example

    Jones

    Smith

    Anna

    Michael

    William

    Ross

    David

    George

    Peter

    Employee Names A-K

    Employee Names L-Z

    Mr. Miller

    Position : Administrator HR

    Mr. Andrew

    Position : Administrator HR

    The two administrators are responsible for employee queries in a medium-sized company.

    Mr. Smith is responsible for employees with surnames from A to K

    Ms Jones is responsible for employees with surnames from L to Z

    IBM Global Services

    Rule Definition with Responsibility: Example

    Rules Container Definition

    Areas of Responsibility

    Mr. Andrew

    Mr. Miller

    Which Value?

    Which Agent

    Container ElementData Type NameElementUnameNameValue From From ToNameA*K*Employees from A-ZL*Z*Employees from L-Z

    To create a rule with responsibilities, you must enter the following:
    1. Rule container
    In this case, we are referring to the attribute name of an employee.
    2. You must define two responsibilities (=value ranges).
    In this case, these are the ranges "Employees from A to K" and "Employees from L to Z".
    3. To belong to this responsibility, the ranges are defined using the interval where the values must be entered at runtime (A* to K* and L* to Z*).
    4. Finally, you assign the people responsible: Use the "Insert agent assignment" button for this.

    5. Enter the rule in the required workflow step and fill the element(s) of the rule container from the workflow container in the binding.

    What happens at runtime?
    The rule you just defined is called and it receives a value for "element".
    If the current value is between A and K, Mr. Smith receives the work item.
    If the current value is between L and Z, Ms. Jones receives the work item.

    In general, you can also define more than one rule with responsibilities in the rule container and create any combinations for value ranges with agents.

    IBM Global Services

    Evaluation path as Rule

    Evaluation path describes how to find one or more organizational objects based

    On an initial organizational units

    Example

    Transaction : OOAW

    Menu Path:

    Evaluation pathMeaningWF_ORGUNGet organization unit for a user id/person idWF_ORGUSAll users of a organization unit,job, positionUS_CHEFSuperiors of a usersSAP_HOLDHolder of a position

    IBM Global Services

    Evaluation path as Rule contd.

    Here are the basic steps:

    Determine the evaluation path that needs to be usedCreate a rule setting the type Function to be executed.Enter function module RH_GET_STRUCTUREEnter the evaluation path determined in step 1 aboveFollowing rule container needs to be createdNameData type refDescriptionExampleOTYPEOBJEC-OTYPEType of organizational management objectUSOBJIDOBJEC_REALOID of organizational management objectSMITHORG_AGENTWFSYST_AGENTOrganizational management objectUSSMITH

    IBM Global Services

    Role Resolution with Function Modules

    Role resolution with function module should be done only for complex criteria

    Here are the basic steps:

    A function module with the following interface is createdCreate a rule setting the type Function to be executed.Enter the created function module nameCreate container elements. Parameter TypeNameData Type RefMeaningTableAC_CONTAINERSWCONTIncoming rule containerTableACTOR_TABSWHACTOROutgoing list of agents in agent formatExceptionNOBODY_FOUNDException indication no agents found

    The function module of the role is executed at runtime by the workflow
    runtime system.

    The role parameters are passed to the function module as a container. The role container is one of the table parameters of every role function module. The values of the role container must be read in the function module using macros.

    The selected agents resulting from role resolution are stored in the table SWHACTOR. SWHACTOR is also one of the table parameters of the
    function module.

    The structure SWHACTOR that holds the resulting selected agents consists of:

    OTYPE: The 2-character ID of the organisational management object type. Examples include:

    O: Organisational unit

    S: Position

    C: Job

    A: Work center

    US: User logon

    P: Person

    OBJID: The 12-character unique identifying key of the organisational management object type. These values can be determined by turning the key on when viewing the organisational plan.

    IBM Global Services

    Via organizational objects: Role resolution utilizing organizational data analyses

    the assignment of an organizational object (plant, laboratory, MRP controller,

    planner group, shipping point, sales office) to a position or organizational unit.

    Plant Laboratory Sales Office

    Execution of a Role Resolution
    via Organizational Objects

    IBM Global Services

    Tasks: Possible Agents & Default Roles

    UserPositionJobOrg. UnitPerson

    TASK

    Default role

    Possible agents

    Business

    Workplace

    The workplace displays the

    work items for a agent

    As we said before, work items are the runtime representation of steps in a workflow. Steps reference tasks. Tasks are activities which create, delete, change or otherwise affect one or more business objects. Tasks can be single-step or multi-step. We will discuss these in more detail in the chapter called Tasks.

    Agents are an important part of tasks. Possible agents (capable executors of the task) must be assigned to the single-step task. (Within the task definition, Additional dataAgent assignmentMaintain.) These are the agents drawn from the organisational plan who are qualified to perform the task.

    Selected agents are derived from all possible agents assigned at the single-step task level. The selected agents can be the same as the possible agents, or a subset of the possible agents derived from a default role. Restriction of the possible agents to a subset is optional.

    Processing agents, deadline agents and notification agents can all be specified as subsets of the possible agents using the default role of the task definition.

    EXAMPLE

    Example of how a rule resolution could be used in an "invoice verification clerk" workflow.

    Design requirements -

    All clerks working in this department are assigned to a specific customer group. At runtime, they should only receive invoices from these particular customers.

    Each clerk has a pre-defined personal transaction limit. If the invoice exceeds this limit, this clerk is not allowed to process the invoice.

    Runtime

    The two import parameters for the rule resolution (Customer name , invoicing amount) determine that the work item should be sent to the three agents circled in red.

    Only those three recipients will receive this work item in their worklist.

    The first user to execute the work item at runtime will block access to this work item. No other user will then be able to access this work item. The work item will actually disappear from the worklist of the other two users when they refresh their worklist.

    After the "first agent" has completed the work item, it will disappear automatically from his or her worklist the next time the screen is refreshed.


    IBM Global Services

    IBM Global Services

    IBM Global Services

    Workflow and ALE

    IBM Global Services

    ALE error handling

    Here is a example scenario for Material master Error handling:

    Inbound function module tells ALE layer that an error has occurred

    ALE triggers objects (I.e. IDOCMATMAS) event inputErrorOccured

    Objects event is linked with standard task (I.e 0007946: MATAMAS_Error)

    Work item appears in users inbox

    When user executes work item, objects method InputForeground is executed

    When IDOC was successfully processed, objects event inputFinished is triggered, which completes work item.

    import bm12.wmf

    IBM Global Services

    Workflow and ALE

    Error NotificationActive MonitoringIDOC Processing Notification of successful posting

    IBM Global Services

    Workflow and Error Notification

    Determine Recipients

    User checks inbox and executes the work item

    Fix the error

    Purge the IDoc

    Restart the process

    User/Group gets notified via a work item

    Can error be fixed?

    End

    Exception Raised

    Yes

    No

    Business User Analysis

    IBM Global Services

    Active Monitoring

    Active monitoring allows to specify threshold values for the state of the system

    For e.g threshold can be on the number of IDocs in error or the time limit

    Report Program RSEIDOCA can be executed periodically Selection screen takes as input the threshold values and persons to be notified When defined threshold is exceeded Single Step Task TS30200088 is executed

    IBM Global Services

    Setting up Inbound Process via Workflow

    The standard system can be configured to start a WF for an incoming IDoc.Useful when review is essential before postingCustom. SAP does not deliver standard.The settings are:

    --Create the custom task or WF

    --Create a new process Code ( WE42) and attach this

    custom WF/Task.

    --In the Partner Profile, attach the new Process code

    IBM Global Services

    Notification of Successful Posting

    The ALE/EDI interface can raise events on successful posting of an IDOC. The settings are:

    --Identify the Appl.Obj created by the Idoc. Txn: WE57

    --Identify the event that needs to be raised.

    --Go to BD67, select Process code and populate Object

    type and Event.

    --Identify/Create tasks/WF and enable event linkage.

    IBM Global Services

    ALE error handling

    Necessary Steps:Create new object type in Business Object Repository for IDOC; object is child of IDOCAPPLCreate new customer taskCreate event-couplings linkingEvent inputErrorOccured linked to standard taskEvent inputFinished to function moduleTo support mass processing:Create new object type as child of IDOCPACKETMaintain process code to refer the above objects and events

    Here is a summary of the necessary steps to enable IDOC error handling:

    Create a new Business Object for IDOC as child of IDOCAPPL

    Create new customer task

    Create event-couplings linking

    InputErrorOccured to standard task

    InputFinished to function module

    Update Process Code(BD67) to refer to the above mentioned objects and events

    To support mass processing: Create new object type as child of IDOCPACKET

    IBM Global Services

    Business Workflow Customization

    - Workflow -

    IBM Global Services

    Workflow Customizing - SWU3

    The function Automatic Customizing allows you to maintain SAP Business Workflow standard settings at the "touch of a button".

    Afterwards, using the button "Verification workflow", a first test workflow can be started to check the settings.

    In the 'Workflow runtime system' section, the traffic light icon should always be green.

    In the 'Workflow development environment' section, an entry with errors in 'Number range for customer tasks' can be ignored.

    If the error 'PD control tables not completely available' occurs, start the report RHSOBJCH.

    Automatic Customizing does not contain either maintenance of the organizational plan, or task-specific customizing, (meaning the assignment between tasks and possible agents).

    User action

    R/3 action

    Execute Workitem

    Fix error and reprocess IDoc

    or

    Flag IDoc for deletion

    Error in inbound function module

    ALE triggers error event

    Workitem appears in user's Inbox

    Display IDoc for user processing

    (IDoc method "InputForeground")

    ALE triggers end event

    Workitem completed

    input Error Occurred

    input Finished

    Determine

    Recipients

    User checks inbox

    and executes the

    work item

    Fix the error

    Purge the IDoc

    Restart the

    process

    User/Group

    gets notified

    via a work item

    Can error be

    fixed?

    End

    Exception

    Raised

    Yes

    No

    Business User Analysis

    SAP AG

    1999

    Tasks: Overview Diagram

    Organization

    Processes

    Business

    objects

    Methods

    WF definition

    Step

    Events

    Attributes

    Role

    Task

    Person

    Position/job

    Org. unit

    Object

    SAP AG

    1999

    Workflow

    Container

    Work Item

    Container

    Methods

    Container

    event

    Container

    Roles

    Container

    Triggering

    event

    Sync.

    Task

    Sync.

    Method

    Async.

    Task

    Async.

    Method

    Terminating

    event

    Role

    Role

    1

    1

    2

    2

    3

    3

    4

    4

    5

    5

    7

    7

    6

    6

    8

    8

    9

    9

    10

    10

    13

    13

    11

    11

    12

    12

    Containers and Binding