Business workflow ( waiting for a project task )

1.44

Use SAP Business Workflow (WebFlow Engine) to (1) define business processes that are not yet mapped in the SAP System. These may be simple release or approval procedures, or more complex business processes such as creating a material master and the associated coordination of the departments involved. Business Workflow is particularly suitable for situations in which work processes have to be run through repeatedly, or situations in which the business process requires the involvement of a large number of agents in a specific sequence.

You can also use Business Workflow (2) to respond to errors and exceptions in other, existing business processes. You can start a workflow when predefined events occur, for example an event can be triggered if particular errors are found during an automatic check.

Reference: https://help.sap.com/viewer/a602ff71a47c441bb3000504ec938fea/7.4.16/en-US/4f41fed1dd88535ae10000000a421937.html



The workflow scenarios can be divided into three categories:
  • Creating Events: Events are created to report status changes for an application object and to allow a reaction to the changes.
  • Providing SAP Tasks: A task contains a task description and the connection to the application logic via the method for a business object.
  • Providing SAP Workflows
When to use? 
  • when different people are involved in different parts of the process 
  • when the users need to be reminded of what they need to do 
  • when the duration of the process is critical and deadlines have to be met 
  • when process-tracking or auditing is critical when the process-consistency is critical 
  • when the process is repetitive in nature and Rule based


You normally create organizational plans by assigning objects of the following types to each other:
  • Organizational Unit
  • Position
  • Job
  • Task

Technical Principles of SAP Business Workflow

  • Business Workplace and Work Items: Work items are displayed to the user for execution in their Business Workplace.
    • For example, work items represent a step at runtime that is to be executed. There are various types of work item. Only certain types are displayed in the Business Workplace.
  • Workflow and Workflow Definition
    • You have to define a workflow before execution. This workflow definition is made up of steps that control the workflow or refer to the tasks to be executed. You can make additional specifications about agents and deadline monitoring for a step. These specifications are evaluated at runtime by the work item manager. The workflow is started either manually by the user or by the system. For the system to start a workflow, the workflow definition must contain at least one triggering event (for example the event material created). When the event occurs, the relevant workflow is started automatically.
    • When you activate a workflow definition, you automatically generate a runtime version. When the workflow is started (manually or automatically), the relevant runtime version is used for the execution. If the workflow definition is changed later and a new runtime version is generated, these changes do not affect workflows that are already being executed.
  • Tasks: Tasks describe elementary business activities. Tasks always refer to a method of an object type. Possible agents are defined for tasks. Tasks can refer to automatically executable methods (background tasks) or they can require a user to execute them (dialog tasks).
  • Object Types and Objects: An object type describes the data with which you want to work in a workflow (for example the object type Material). An object is an individual data record of an object type. Attributes are defined for an object type, which makes up its data record (such as material name, material number). Every object type has methods in which activities are defined that can be executed with the data (for example, create material). You can call the transactions and functions of the SAP System in a method, as can your own or other applications. Events are another important component of an object type. The events describe the status changes that an object can undergo (for example, material deleted or materially changed). A workflow can be started by an event of this kind being triggered.
Each workflow consists of a start and one or more end events, background and dialogue tasks, as well as other elements such as loops, branches, container operations and variables.

Events Used
  • Triggering Events: To Start Workflow tasks. 
  • Terminating Events: To End the Workflow. 
  • Application Creates Event through: 
    • Change Documents: Status changes of objects which are logged as change documents can be reported as events. 
    • Status Management: An event can be created automatically for objects using the general status management when an object status changes.
  • Message Control (NAST table):
    • Programming (Explicit event creation) using Function Modules: Events can be created by calling the relevant function module 
1. SWE_EVENT_CREATE
2. SWE_EVENT_CREATE_IN_UPD_TASK
3. SWE_EVENT_CREATE_FOR_UPD_TASK


Using Linkages
  • A linkage defines the assignment of events to the event receivers interested in them


Architecture
  • Organisation 
  • Process 
  • Business object 


SAP-Tools für die Erstellung von Workflows

#1 SAP Business Workflow
  • Für die Kommunikation zwischen zwei Systemen nutzt SAP Business Workflow die WebFlow-XML-Schnittstelle.
  • Transaktion SWDD
  • Die Definition einer Aufgabe erfolgt über die allgemeine Aufgabenpflege, Transaktion PFTC
  • Transaktion SWEC Events for change documents
  • Transaktion SWED  Assignments
  • Die Transaktion SCDO liefert Ihnen eine Übersicht aller vorhandenen Änderungsbeleg-Objektklassen
#2 SAP Cloud Platform Workflow Management
Workflow-Modellierungssprache setzt auf dem Standard Business Process Model and Notation (BPMN) 2.0

#3 SAP-Fiori-Apps

SAP Business Workflow

Standard-Workflows konfigurieren

In some processes that are handled with SAP, standard workflows already exist, some of which can be used directly.

How to find a sample?


Suche über den Customizing-Leitfaden (SPRO)

Suche über den Workflow Builder

Transaction SWDS / PFTC

Suche mithilfe des Ereignis-Trace

Call the transaction SWELS (switch event trace on/off)
  • SWEL - Display Event Trace 
  • RSWELOGD - Delete Event Trace 
  • SWO1 to see the Object 

Automatisches Workflow-Customizing

Automatic workflow customising is a prerequisite for any use of SAP Business Workflow. You start it via transaction SWU3.

Workflow-Eingang

Work items are workflow worklists to be processed by you or a group of people. The workflow is only continued after they have been processed.

  • Business Workplace (SBWP)
  • Business-Workflow-Arbeitsplatz (Work Center): Service swf_ workplace über URL
  • My Inbox (bzw. das Vorprodukt Unified Inbox): über das SAP Fiori Launchpad
  • Nicht-SAP-Produkte mit Integration in SAP Business Workflow

Workflow-Aktivierung (SWU3)

Startereignisse (start events), auch auslösende Ereignisse genannt, sind die Ereignisse, die dazu führen, dass ein Workflow gestartet wird. Ein Workflow kann mehrere Startereignisse haben. Damit ein Workflow startet, muss das Startereignis aktiv sein.Ob das Ereignis aktiv ist, erkennen Sie an die Symbole für aktiv ( ) und inaktiv ( ) in der Spalte Aktiv.


In some cases, it can be activated in SPRO.

Ereignistypkopplung: Über die Transaktion SWETYPV oder SWE2 (SWETYPV-Typkopplungen) finden Sie die Ereignistypkopplungen.

Das bedeutet, wenn Sie eigene Workflows entwickeln und Startereignisse definieren, finden Sie auch diese Einträge in der Transaktion. Die Einträge entstehen also, wenn Sie im Workflow Builder Startereignisse zuordnen.

  • Check function module: A transaction used to prevent a linkage being triggered when an event occurs.
  • Receiver type function module: The event container is evaluated in the receiver type function module, and a receiver type is determined from the information. Typically, no receiver type function module is required in SAP Business Workflow.
  • Enable Use of Queue: This indicator is only evaluated if the event queue is active. If the indicator is set, the event receiver is started via the event queue. If the indicator is not set or the event queue is not active, the receiver is started immediately.
    • The queue management in transaction SWEADM allows you to make further settings, and the event browser in transaction SWEQBROWSER gives you an overview of the processing and status of the events created via the event queue.

Workflow-Benachrichtigungen einstellen

Einfache Benachrichtigung
  • Using the RSWUWFML2 report, you can easily create e-mail notifications for new work items.
Erweiterte Benachrichtigungen
  • SWN_SELSEN/ You can make the appropriate settings in transaction SWNADMIN (a browser-based BSP application) or transaction SWNCONFIG (an SAP GUI application).

Workflows einsetzen und verwalten

Workitems und Workitem-Status

  • in Vorbereitung (CHECKED)
  • wartend (WAITING)
  • bereit (READY)
  • angenommen/ reserviert (SELECTED)
  • ausgeführt (COMMITTED)
  • beendet (COMPLETED)
  • logisch gelöscht (CANCELLED)
  • fehlerhaft (ERROR)

Workitem-Typen

  • Dialog Workitem (W)
  • Deadline-Workitem (D)
  • Arbeitsvorrats Workitem (A)
  • Workflow Workitem(F)
  • Block Workitem (X)
  • Hintergrund Workitem (B)
  • Warteschritt Workitem(E)
  • Web Workitem
  • Container Anker
Useful transactions 
  • In transaction SWI6 (Workflow for object) view the workflow for an object.
  • In the transaction SWI1 (work item selection) find the executed transaction SWI1
  • Workflows and work items for a specific time interval. 
  • If you want to make a statement about the frequency of work items, i.e. the number of workflows initiated within a period of time, this can be period, this is possible via the transaction SWI2_FREQ (work items per task).
  • With the reports Work Items without Agents (transaction SWI2_ADM1) or Work items with deleted users (transaction SWI2_ADM2) can be used to determine
Work items without agents can be determined.

Workflows entwickeln

Elemente von Workflow-Definitionen

  • My Inbox/Business Workplace
  • Workflow-Definition
  • Steps: The steps either control the workflow directly 
  • Tasks
  • Classes/Business Objects
  • Organizational management
A running workflow is always based on the version that was active at the time it was started. If a newer version of the workflow is used productively and is activated and is activated, the current workflow is still completed on the basis of the old version.

Workflow-Definition im Workflow Builder

Step types

Aktivität: Execution of a task (single-step task or multi-step task)

This is a simple step which executes the underlying standard Task. For execution of this activity, you need to fill the container of task. The agent assignment is carried forward from the standard task.
It ofers a facility to notify a user on successful execution.

It is required when a task is to be executed at runtime.
    • Control: select or create a task & assign agents 
    • Details: log?  work-item response 
    • Outcomes
    • Notification
    • Latest End: If you set a deadline on the Deadline tab of the created activity, the work item must be processed within this period.  you can display a text as an action and inform a message recipient if the deadline is exceeded. 
    • Latest Start
    • Requested Start
    • Requested End
    • Methods
      1. Secondary methods can be useful in certain cases in order to show the additional information to the operator in another mode.
      2. Preceding and following methods are suitable for background tasks, to example, for converting values, additional notifications of a staff member, etc.
    • Conditions: a new condition ( Only when this condition for creating work items is fulfilled can the work item for this step be executed. Otherwise the work item is created in status "In Preparation"), complete work item (If this condition is fulfilled, the work item is set to the status-completed and the workflow with the outcome Condition for 'complete work item' is correct is continued. This work item is checked as long as the work item does not have the status error, logically deleted or completed), complete execution 
    • Programs Exits. You can execute additional methods that you have programmed when predefined events occur.The ABAP classes added must support the IF_SWF_IFS_WORKITEM_EXIT interface.

Web-Aktivität: Sending an XML document from the workflow

This step uses an existing Workflow step as a reference and sends the container elements to an XML document. The XML document contains the operation CreateProcessInstance, which starts a remote process.

Mail versenden

Document from Template 

This step enables us to create a document runtime using the data in the containers. You can create an Excel sheet, Word Document or even a PPT presentation and slides to display the data. For this, you must create the templates first, carrying references to the container variables. Then at runtime, the template and flow items are passed from Workflow container to the task container for processing.


Formular

A form is displayed, edited, or approved (based on a structure-based container element). A screen is technically generated from this structure-based container element.

  1. Create a structure with fields.
  2. Create a container element with the connection to the new structure
  3. Insert the step
  4. A formular will be displayed 

Benutzerentscheidung: User decision

This step is useful for seeking approval for a certain task. You can send a proposal to a user informing him about a case.

Dokument aus Vorlage: A document is created from a document template
Bedingung

Comparable to an IF statement in software development, a branch is run through after evaluating the condition. The multiple condition serves like Case-When statement.

Ereigniserzeuger: Events 

You can artificially generate events of the objects that are a part of Workflow container.

Warten

  • The Wait step type is a modeling element that can be used to specify that the system is waiting for an event or for a condition to be fulfilled.
  • In order not to have to end the workflow and start a new one in such a case, recursions can be modelled with the step Wait for <event>.

Containeroperation

Elements of the workflow container can be with elementary arithmetic operations (add, subtract, multiply, divide) or value assignments can be changed. Here you can manually assign values to the required container elements. This is useful especially while setting/
resetting the counters for running loops.

Ablaufsteuerung: 

Work items of the current workflow can be influenced (cancel work item or make obsolete).
  • Cancel the specified Work Item. The work item is set to status logically deleted. The prerequisite is that the process control should be in a branch parallel with the work item.
  • Cancel Workflow. All the Workflow steps are set as logically deleted. If this Workflow is being called by another one, the calling Workflow is set to status Incorrect.
  • Terminate Workflow. Workflow status is changed to Completed.
  • Set the given work item (again this should be in parallel with the process control) to obsolete.

Loop (UNTIL)

Parallel Abschnitt

Unbestimmt

Standard tasks

Standard tasks thus serve to use methods of a class or object type in the workflow. in the workflow.
In transaction PFTC_INS (Create tasks/task groups) you can create a standard task.


Class or BOR.
On the Container tab  find the data which are located in the task container. The task container contains all the necessary runtime runtime data of the task, the necessary task variables, so to speak, including the task object (Wi_Object_ID). 

Trigger events
Terminating events
Default rules 

Business objects, SWO1

Classes 

In the context of SAP Business Workflow, only classes that use the interface IF_WORKFLOW can be used.

Container 

With the workflow container, it is possible to make data available globally within the workflow, to edit it, and to use it in the various steps. 
  • Workflow-Container: Sie enthalten Werte, die von einem Schritt an einen weiteren Schritt weitergegeben werden sollen.
  • Aufgabencontainer
  • Methodencontainer
  • Ereigniscontainer
  • Regelcontainer

Data flows

The methodology in workflow development to transfer data between containers is data flows. The data flows specify how data is to be exchanged between exactly two containers. are to be exchanged. 


Example.
From the event.. 

The binding can be generated.
 
From the event to the step..
Here, data is transferred from the task container to the method container. is transferred.


Standard-Workflows erweitern

Startbedingungen definieren

Start conditions are used to define additional conditions for the start of a workflow. The start of the workflow then depends on the occurrence of the triggering event and the fulfillment of the defined conditions.

Transaction: SWB_COND

Call the transaction  SWETYPV

@objkey(12)

The check will be visible in the trace.

Bearbeiterfindung anpassen

The agent determination, i.e. the determination of the users responsible for the respective work items responsible for each work item is individual and company-specific in many and company-specific.

From the activity:


From Org.

  1. Create an organisational unit with the respective positions for for purchasing in transaction PPOME (Change Organisation and Staffing), or use an existing organisational unit.
  2. In transaction PFOM (Create PFOM Assignment), assign the purchasing groups to the positions of the created organisational unit.
  3. Select your organisational unit from the organisational plan (for example the for example, the purchasing department) and the organizational object type T024 (purchasing group)
  4. Return to transaction PFOM and execute it. 
  5. Assign 
In the standard task

Workflow-Texte anpassen

In a Task


Einen eigenen Workflow auf Basis von Standardobjekten entwickeln

  1. Create a class
  2. Assign the interface IF_WORKFLOW
  3. The key of a business object in the workflow environment must have a certain format, the so-called local persistent object reference (LPOR). 
BI_PERSISTENT~FIND_BY_LPOR method (Find via local persistent object reference) converts the persistently stored representation of an object into an instance of the ABAP class. Object Reference) converts the persistently stored representation of an object into an instance of the ABAP class.

BI_PERSISTENT~LPOR method is the counterpart to the FIND_BY_LPOR method and returns the persistent representation for an existing instance of an ABAP object.

BI_PERSISTENT~REFRESH method is required when you need to ensure that all values of the object are valid and match the persistent state.

With the method BI_OBJECT~DEFAULT_ATTRIBUTE_VALUE you get back the display name of the object, the so-called default attribute.

Mit der Methode BI_OBJECT~RELEASE können Sie nicht mehr benötigte In- RELEASE stanzen, also abhängige Klasseninstanzen, löschen.

Before implementing a workflow, you should always create a flow chart and coordinate it with the departments.

Event creation can be done from any programme or UserExit (Enhancement Point, BAdI, etc.) through its own implementation.

With call of a method

  • To create the event in the update, use the function module SWE_EVENT_CREATE_IN_UPD_TASK. This module can be used be used with the addition IN UPDATE TASK and thus trigger the event in the update. trigger the event in the update. This makes sense, since SAP programmes (i.e. classical transactions) often use the update system for database updates.
  • SWE_EVENT_ CREATE oder SAP_WAPI_CREATE_EVENT

With the class 

TRY.
 cl_swf_evt_event=>raise(
 im_objcateg = cl_swf_evt_event=>mc_objcateg_cl
 im_objtype = 'ZCL_WF_CHANGE_MASTER'
 im_event = 'IN_APPROVAL'
 im_objkey = lv_objkey).
 CATCH cx_swf_evt_invalid_objtype cx_swf_evt_invalid_event.
 CONTINUE.
ENDTRY.

With output types ( send medium )

Using BOR and Event. 

With BTE 

Einen eigenen Workflow auf Basis kundeneigener Objekte entwickeln
Fehlerbehandlung und -analyse im Rahmen der Workflow-Entwicklung

Workflows im Kontext vonSAP S/4HANA

Transaktion SWDD_SCENARIO (Flexibler Workflow: Scenario Editor).
SAP NetWeaver • Application Server • Business Management • SAP Business Workflow • Flexibler Workflow • Szenario Aktivier

By activating a scenario, you basically enable the possibility to select this scenario in the respective SAP Fiori app and to set up a flexible workflow. and to set up a flexible workflow.

Materialwirtschaft • Einkauf • Bestellung • Flexibler Workflow für Bestellungen • Flexiblen Workflow für Bestellungen aktiviere

WS02000006 Workflow for Sales Orders

Start event: CL_SD_SALESORDER_WORKFLOW=>TOBEAPPROVED

Scenario

Control

Activitiy - Task - User type

Conditions

Agent




Comments