SAP Technical Consultant m.uzairkoreja@gmail.
com
TOPIC:
SAP ABAP Custom Workflow Creation and Make Copy of Standard Workflow.
Mandatory T-Codes to remember in workflows.
1. SWO1 – create business object.
Make a copy of standard business object.
Delegate copy with standard business object to use custom over standard.
2. PFTC – create Workflow.
Create tasks to use in Workflow.
Activate Workflow standard or custom.
Edit Workflow using Workflow builder.
3. SWDD – Workflow builder.
4. SWE2 – link the Workflow with their events standard or custom.
5. SWELS – activate / deactivate the trace for Workflow to check it’s calling.
6. SWEL – check the trace results.
7. SWIA – Workflow report, used to check which Workflow called or having error, its
state and all amount running Workflow.
1
SAP Technical Consultant [email protected]
Workflow Scenario:
When a PR is created or changed or cancelled a Workflow will call. We will maintain
approvers in custom table with hierarchy level 1,2,3 and so on. The Workflow will send
approval request to maintain users one by one.
2
SAP Technical Consultant [email protected]
Step 1:
1. Create a copy of pr business object BUS2105.
2. Go to T-Code SWO1 and click on create button.
3. Fill the fields as given below. Enter the standard Workflow in first field and other will
be custom choose by developer.
4. Hit enter or OK button to final the first step.
A Business Object is Created, Click on SAVE Button.
3
SAP Technical Consultant [email protected]
Step 2:
We will create method to get approvers from our custom table first.
1. Click on methods.
2. Click on create button and select no (we do not have already defined method so we will
be creating here).
Give the method name and details like given below.
4
SAP Technical Consultant [email protected]
Hit enter or OK button finalize step 2.
5
SAP Technical Consultant [email protected]
Step 3:
A new function is added.
Add the parameters for our function.
Click on function and click on parameters button as shown below.
6
SAP Technical Consultant [email protected]
We must add following parameters. Their properties are shown below.
Click on Create Button to create below Parameters.
Tab_agent (Table to get Approvers)
7
SAP Technical Consultant [email protected]
Numb_appr (Number Of Approvers).
8
SAP Technical Consultant [email protected]
Step 4:
Create Approvers Table to maintain approvers.
Fields and data type shown below.
9
SAP Technical Consultant [email protected]
Step 5:
Select method and click on program button same as we clicked on parameters button.
A pop up will appear select yes for predefined code of added parameters.
Enter the following code mentioned below.
10
SAP Technical Consultant [email protected]
Step 6:
1. Go to edit.
2. Select chnage release status.
3. Select object type component to make function available for use in Workflow.
4. Select Implemented.
After that repeat same step and now select released.
Tick will appear near function name that show function is now available for use.
11
SAP Technical Consultant [email protected]
Same steps follow as above.
1. Click on edit -> change release state -> object type -> To be implemented.
2. Click on edit -> change release state -> object type -> To Released.
3. Click generate button a Red and White circled button near check button.
4. Save the Business Object.
Due to this step a tick will appear near Business Object Name. That will make available the
business object to use in Workflow.
Now we can see Tick near Business Object name and Function Name.
If you can see It’s Perfect.
Important Step:
Click on Delegate and add information and save.
1. 2.
12
SAP Technical Consultant [email protected]
Step 7:
1. Create workflow.
2. Go to t-code PFTC.
3. Select workflow template in task type and click create button.
Give the details as given below and click on save button or CLTR+F3.
Now the workflow is created.
13
SAP Technical Consultant [email protected]
Go to container tab and create a parameter with the name of business object (you can use any
name, but type will be same).
In properties check Import and Export.
14
SAP Technical Consultant [email protected]
Step 8:
1. Go to triggering Tab.
2. Select Object Category as BOR Object Type.
3. Object Type BUS2105.
4. Event (Select for which you want to trigger your Workflow).
Note: These Step can be done by SWE2.
(To active Standard Workflow, You will just do this step by PFTC or SWE2)
15
SAP Technical Consultant [email protected]
Click save button and click on Workflow Builder.
You can go to workflow builder by SWDD.
16
SAP Technical Consultant [email protected]
Here we must create some variables for loop and conditions.
Select workflow container and double click to create variable.
Create first variable for loop increment as given below.
17
SAP Technical Consultant [email protected]
By following same steps create another variable Rejected to check that approver has rejected
the PR.
By following same steps create another variable decision Note to make any decision on base
of condition.
18
SAP Technical Consultant [email protected]
Step 9:
It’s time to start designing Workflow.
Add first activity to get approvers.
Click on select circle area point 1 and click on create button point 2 and select Activity point
3.
19
SAP Technical Consultant [email protected]
Step 10:
Here we need to create Task.
Click on little arrow button near Task and select Create Task.
Give the following details as given below.
Note if your Business Object is generated successfully, you will be able to find your custom
created function in Business Object.
20
SAP Technical Consultant [email protected]
Task has been created and added.
21
SAP Technical Consultant [email protected]
Now we have to add another step in Workflow.
1. To add this, click on circled area and click on create button just down the Graphical
Model text.
2. Select user decision from pop up.
Add the following details given below and save the Workflow.
22
SAP Technical Consultant [email protected]
Step 11:
Now we have to handle rejected case.
Select the circled area point 3 and click on create button point 1 and select Container Operation.
Add the following details given below.
Rejected = ‘X’.
It will pass X to Rejected Variable to confirms that user has rejected the PR.
23
SAP Technical Consultant [email protected]
Step 12:
Select use decision activity and click on create button and select Loop (Until).
This Popup will appear, Select In Loop to add user decision in Loop area.
24
SAP Technical Consultant [email protected]
Double click on selected activity.
Now click on tick area to add condition of loop termination.
25
SAP Technical Consultant [email protected]
Add the following condition as given below.
It will terminate the loop when given condition will meet.
Add the last 2 lines given below.
26
SAP Technical Consultant [email protected]
Step 13:
After the Approver Activity add another container operation by following last activity.
Give the details given below.
Loop_inc = loop_inc + 1.
It will make an increment of 1 on every loop.
27
SAP Technical Consultant [email protected]
Step 14:
Now Workflow Creation is Final.
Now activate the workflow.
To check the workflow execution.
Click on Run button point 2.
Select business object BUS2105.
Give the PR Number and hit execute button.
Further results you can check by SWELS and SWEL T-Code by tracing and SWIA Report.
28