This Blog describes how to create a very simple SAP Business Workflow
with a single decision step that can be used for Duet or Alloy.
The Workflow will be triggered by the creation of a new material in the ERP Backend (transaction
MM01).
The sample workflow just consists of a single decision step which is to
approve or reject the new material. The work item will be visible in
the Business Workplace.
In this easy example we do not focus on a complex agent determination
– therefore the creator of the material also receives the work item
himself (which is fine for this example – but may not be the case in a
real environment).
In order to enhance the work item with some Material specific values
we create a new Business Object (inherited from the standard Material
Business Object) with some new attributes.
As a first step we create a new Business Object Subtype, inherited
from the Material Master Object Type. Then we define the Event Linkage,
and finally we create a new Workflow in the workflow builder that uses
the event to initiate the workflow.
1. Create a new Business Object Subtype
Start Transaction
SWO1 to launch the Business Object Builder. Enter Standard Business Object Type
BUS1001006
(Standard Material). From the menu choose Object Type –> Inheritance
–> Create Subtype, and provide the attributes required in the
popup-menu:
The subtype has inherited all Attributes, Methods etc. from the
superior object. In order to create own attributes place the cursor on “
Attributes”
and press the create button. As we want to create attributes that are
coming from the Material Master table MARA, we select “Yes” in the
“Create with ABAP Dictionary field proposals” dialog. Enter “
MARA” as table name and scroll down to the fields “
Size / Dimensions“, “
EAN/UPC” and “
EAN Category” and select them. Press
Enter
to close the dialog. For each newly selected line there will be a popup
with the attribute properties. You can confirm the default values.
Set Object Type to “
Implemented” by selecting Edit
–> Change Release Status –> Object Type –> To Implemented.
Generate the Object Type by pressing the generate button, or by CTRL+F3.
2. Define Event Linkage
Call Transaction
SWEC to define the Event Linkage.
Otherwise the event on the new Business Object Subtype won’t be executed
and thus no consumer will be called. Press “
New Entries” button, and specify the attributes as follows:
Press Save.
Ensure that the event trace (Transaction
SWELS is turned on). If you now create a Material via Transaction
MM01, you can see the event in the event log (Transaction
SWEL):
3. Define Sample Workflow
Start the Workflow Builder with transaction
SWDD and press the
Create
button. Switch to the Workflow Container view in the lower left corner.
Double click to create a new container element. Perform this step for
the following attributes. Define all of them with “
ABAP Dictionary Reference“.
Element |
Name |
Short Description |
Structure |
Field |
ZMaterialNumber |
ZMaterialNumber |
Material Number |
MARA |
MATNR |
ZMaterialText |
ZMaterialText |
Material Text |
MAKT |
MAKTX |
ZMaterialSizeDimensions |
ZMaterialSizeDimensions |
Material Size Dimensions |
MARA |
GROES |
ZMaterialEAN |
ZMaterialEAN |
Material EAN |
MARA |
EAN11 |
ZMaterialEANCategory |
ZMaterialEANCategory |
Material EAN Category |
MARA |
NUMTP |
.
Switch back to the “Step Types that can be inserted” view in the lower left corner. Drag & Drop a “
User Decision” step from the toolbox into the Graphical Model:
Provide a Title with placeholders to immediately see the attributes, set “
&_WF_INITIATOR&” as the Agent for execution and specify the Approve and Reject decisions:
Go to the 2
nd tab strip (
Details) and de-activate “
Advance with dialog“.
Click the green check-mark button in the upper left corner of the Task
screen to transfer the definition to the graphics. Press the “
Hat” button or CTRL+F8 to access the basic data. Specify an abbreviation and a description. Navigate to the “
Start Events” tab strip, specify the above created Object Type as triggering event and select “
CREATED” as the triggering event. Save the Workflow.
Click on the button in the first column to activate the triggering
event. Click on the second Button in the table to define the binding.
Define the mapping for all 5 attributes via Drag&Drop:
Confirm the dialog, press Save and back to go to the initial screen. Press the “
Generate and activate runtime version” button or CTRL+F3.
Create another material to verify settings. Go to the Event log (Transaction
SWEL), and you should see the triggered event, which has been consumed by the new workflow:
Go to the Business Workplace and you should also see the new work item:
Via the Workflow log you can navigate into the container to verify if the Z-attributes have been handed over correctly:
That’s it.