Tuesday, September 6, 2011

How to create a workflow for a transaction

1. Find a standard business object - which relates to the desired master data.
Transaction SWLD - Business ObjectàDefinition Tools Builder
Click on the Business Object Builder button.
Either search for an object by name in short description or use the IMG structure, which is accessed via the Business Object Repository button.
2:Create a subtypeq of this business object.
Once the relevant business object is selected press the Create Subtype button - this will automatically create an object, which inherits all characteristics from the basic business object. Give the subtype a name prefixed with Z_.
Enter the following fields with values:
Object type: Z_TESTXX
Object name: Object_Name_for_XX
Name: Object Name: XX
Description: Object Description: XX
Program: Z_TESTXX
Application: *
3:Create an event.q
When you change your subtype the first step is to create a new event, this is done by selecting the Event node and clicking the create button. Give the event a name and a description. Next set the status of this object type component to implemented.
Event: Z_EVENT_XX
Name: Event name: XX
Description: Event Description: XX
Click on the new event and… Object Typeà Change Release Status àEdit Implemented àComponent
4:Create a method.q
Next a method must be created without using any function module template. When creating the method ensure that the method call is synchronous - this means that the method doesn't require a terminating event. Next set the status of this object type component to implemented.
Method: Z_METHODXX
Name: Method name: XX
Description: Method Description: XX
Implementedà Object Type Component à Change Release Status àEdit q
5. Create Key fields.Create key fields with ABAP dictionary field proposal. Enter ‘BKPF’ in table name field and select all the key fields. Press Continue button. Next set the status of these key fields to implemented.à Object Type Component à Change Release Status àEdit Implemented
6:Implement business object.qThe whole business object needs to be implemented so click on the business object title and…àEdit Implementedà Object Type àChange Release Status
7:Link a changeq document to the business object & an event.Now the event you created in the new business object subtype needs to be linked to the relevant change document type. This will enable the event to be triggered on creation of the relevant change document.
Transaction SWLD… EventàDefinition Tools Linkageà Change Documents àCreation Click the New Entries buttonEnter the relevant Change Document Type, your Business Object Subtype & the related Event from the Business object subtype.This new entry is assigned to a particular type of change document (Create, Change or Delete) so for each type of change document we need to create a respective event in the business object subtype & link these here.
Note 1. The starting point of a workflow is the object/event trigger. Without this the possibility of building a workflow is ruled out. The triggering of events is achieved through a number of mechanisms some of them are listed below:• Triggered using Change document objects.• Triggered using Status control.• Triggered through Message long text.• FI Validation Trigger• And a few others, which are closely, intertwined with config. e.g. Workflow events for Purchase orders using output determination.• Publish events through User exits. This requires custom coding.For this demo example, you will create an event by writing a custom code.
8:Create workflow task.qNow we need to create a workflow task, this will be triggered by the event and will call the desired method in your business object subtype.Transaction SWLD Createà Tasks/Task Group àDefinition Tools This task will be of type TS (Standard Task) after this is entered click the create icon.This will bring up the main task window. Under the Basic Data tab enter the Abbreviated Name, Name and Work Item Text. Enter your business object subtype name as the Object Type and enter the Method you created within the subtype. If you tick Background Processing as the execution mode, the work item is executed without need for manual intervention.Next move to the Triggering Events tab. Insert a new entry in the table here - referencing the business object subtype and the relevant event.
9:Set up containers.qThere are a number of data containers, which are used in this process to transport relevant data between events, tasks and methods, we need to make a few small modifications to these.Click on the Containers button. Create three fields in the container with reference to the database table. Now go back to the Triggering Event tab, highlight the newly created record in the table and click the Binding Definition button. This shows us how data is transferred from the Event container into the Task container. There should be four records. Now click on the Event Parameter Container button, this shows us what data is present in the event for transfer to the task. If there is matching data in the Event Parameter Container, copy the element name from the screen and insert it in to the associated slot in the binding definition (Enclosed in &'s).The last step of all is to activate the event linkage, by pressing the small button to the left-hand side of the event record. This creates the link between the event and the task - which will call the method, which in turn calls the required transaction or reports or function module.