Workflow tutorial real time example
Work flow sending data from one personnel to another or from one transaction to another.
Workflow will be triggered mainly when a transaction is saved or some even occures in any transaction. When an even t occurs all the data will be bundled and sent to a Business object.
From this business object we can manipulate the data, change according to our requirements and trigger a Work flow.
A business object is basically object oriented repository in SAP.
Components of Business object
It contains business object type, interface type and components such as methods , attributes and events.
When a Work Flow is triggered it starts from the transaction. when a user saves the transaction the data goes to a business object send the data out as event and methods will generate the data and send it to work flow.
Most of the sap transaction have business objects. but we can also do some customization to get new business objects and we can do with out business objects also by using some sap function modules..
Scenario:
For the scenario we have to first look if there is any standard Workflow is available, if available we can use it and if not we have to build one.
Ex: Work flow for sap hr system.
when an employee is hired or rehired, a supervisor will be informed through an email.
Here in this scenario we are using a sap smart form as a email that has to be sent to the supervisor. we can send a simple mail but why we are using a smart form is ,
the mail that goes to a supervisor should ave a standard format. for this purpose we are using a smart form.
In sap hr for hiring we use the transaction PA40.
in the transaction PA40 give the personnel number and Select the HIRE action and then execute.
Basically this is the screen for employee hiring action in HR i.e
PA40. This hiring action is a process of many screens and
they are called infotypes in HR. Just because we have taken
Work flow example in HR..some people may get confused like
my friend Marella…who is in SD and MM module. (thanks to
him for helping in building this website). so come to the point.
here each screen is called as infotype. not we have to fill all
the necessary fields in every screen to complete the hiring
action in PA40.
fill the personnel number and select the HIring as shown in
the screen left side and click execute button. By clicking you
will be taken to another screen i.e infotype "0000". and you
have to fill the necessary fields there. now fter saving you will
be taken to infotype 0002 screen.
This is infotype 0000. give all the required fields and
save. then you will be taken to next screen infotype
0002.
This is infotype 0002 screen where you will have to fill
the values. affter saving here you will be taken to next
screen infotype 0001.
This infotype 0001 screen. Give all the required values and save. this
screen is where exactly where the workflow is needed o be triggered.
Here after giving the contract data and the moemnt you save, the work
flow should be triggered.
Now lets discuss little bit about the architecture here. The moment we
save in this third screen, all the data i.e what ever we filled in the 3 screens
(0000, 0002, 0001) should be bundled into a business object .
I am sure you understand about this point. All the 3 screens data will be
saved into a business object. Now we need to know which business object
it will be stored. And have to see the data we have just filled.
Now we will go from this screen and see how this business object data is
sent to work flow..how we have to configure this scenario.
Now we are looking to identify the business object that our 3 screens data was sent to.
Go to SAP easy access i.e the starting screen of SAP. follow this path.
TOOLS–BUSINESS WORKFLOW–DEVELOPMENT–DEFINITION TOOLS–EVENTS–EVENT CREATION–CHANGE TO HR
MASTER DATA–SWEHR1-LINKAGE:OBJECT TYPE TO HR INFOTYPE.
double click on SWEHR1. this is where you will find the business object associated.
This is the screen you will get when u double click on SWEHR1.
here you can see different columns like object type text, IT(info type)
obj.type etc..
Here identify the infotypes we have just created.(0000,0002 and
0001 in the order). And if you remember we have filled the infotype
0001 3rd screen at the last and discussed that when we filled the
infotype 0001 and save , it has to trigger the workflow.
So, identify the business object related to infotype 0001. because all
the 3 transactions data will be bundled up in that business object.
So in the screen you can easily find Business object number
"BUS1065" opposite to infotype "0001".
Now we got the business object and now we will create the work
flow.
Now go back to SAP initial
screen. follow the path as
shown in the image left
side.
under tasks/task groups
click on transaction:
PFTC_INS-create.
This is the screen you will see when you double click on the above transaction.
Here Task type means: the type of task we are gonna create.
Standard task mean a single task. our scenario is as soon as we save in the infotype
0001..screen, workflow has to send a email to the supervisor , which is typically a
single task . So we will select standard task.
if the workflow consists of multiple tasks then select workflow template.
Give some task id task name and click on create button.
This is the screen you will see after you create the task.
You need to fill all the details..they are all common details like
workflow name object type..we have to assign a object type as
"bus0065" wheich we have identified earlier and object category
as BOR object type i.e business object repository. and method as
CREATE.
these are imporatnt because we have discussed that these r main
components of workflow..object type, method etc..
If you want to see the components of a business object just
double click on business object BUS1065, you will see the below
screen.
The full tree structure of the
business object components looks
like this.
So if you see here, there are events at the bottom and
if you expand the tree structure, you can see all the
events related tot his business object.
Now here in our scenario we are looking for Employee
Hire event & employee rehired event..we have
discussed this point in the begining if you remember.
And these events will be triggered with the method
"employee abstract.create" see int he left side image.
Lets come back to the original screen.
Once you gave all the required information in the screen fields, now we have to
bind the objects. Click on the button shown in the left image to bind the object.
When you click the binding button you will see a screen
like this. Initiall the screen does not map the data as you
are seeing now. Initially you will see a create button and
when u click on the create button all the data will be
mapped automatically and you will see the screen like
this.
IN this binding action, we are binding the task and the
method with the respective task details and methods
together.
Here the word CONTAINER in the image is equvivalent to
a function module. as the function module contains
parameters, here container contains parameters like"
_adhoc_objects" etc..in the left image if u can see.
So we were discussing binding of all the screen
information to business object means..actually the
information sends to Container. i.e when we say
information sent to business objects means it sent to
container. now go back to the previos screen.
Click on the triggering event tab.
Here the important step is fill all the values according to
their respective methods. since we r going to concentrate
on 2 events HIRE and REHIRE,,select object category,
object type and event..
since 2 events ..there are 2 rows.
the green lights u r seeing in the left image initiall will be
red. u need o click on them to activate..then it will become
green.
Actually speaking when u click on the two red buttoon
and making them green(active), two entries will created in
the standard sap transaction table. just see where these
entries will be stored.
go to the transaction SWETYPV. in the commond bar.
Here you can see there checkbox for type linkage is
checked for the business object BUS1065 for HIRE
event. when we bundled up the object there it will
reflect liek this here.
This is very important because how does any
transaction knows that there is a workflow configured
for that transaction? this is the table where a
transaction looks for if any linkage is checked.
Now come back to the previous screen . and select one
row(hire) and click on again a binding button which is
there.
select one row like this and click on the binding button.
Dont get confused here. the first binding we did earlier was
"Task and the method"..this binding is for "event and the
task"
the screen looks like this..almost same as earlier binding. there will be a create
button initially just click on that..you will see mapping will be done for you like this
One thing I forgot is Before going to the "triggering events" tab,
go to 'Container' tab and click on create button. then you will see a
screen like below. give a name 'employee' and give business object
name 'bus1065' and select business object type, click save.
Here let me explain why we need to create a container named 'employee' and then assign it to a business object bus1065.?
if you remember, we have already mapped the business object method to the employee container. it is because..we need to use this custom
container(employee) in later point of time. Thats why we have created 'employee' container though we have a business object 'bus1065'.
Now click on tab 'default rules'. In this tab we are going to
create a rule i.e to whom we are going to send the work flow
information. this could be to a transaction, correspondent
etc. In our scenario we are sending an email to the
supervisor. So here in this screen the agent is nothing but
the supervisor. Here in this screen initially the rule will be
000000..we have to type manually the rule number. Now
how to create a rule ?
open another session and create a rule there, then assign it
here.
This is the path to create the rule. go
to sap easy access and follow the
path shown in the screen left side.
Click on the PFAC_INS-create. dbl
click. you will go to the below screen.
Here you dont have to type anything,
just click on create button. then you
will see the next screen like below.
Here give all the field values and give the function module which we have
created before. I am not telling you how I have created a function
module, because Iam assuming every one who come to workflow session
knows function module. But I will explain what code I have written in that
function module and its purpose.
The function module is going to fetch the supervisor details from
organization structure. and once it gets the supervisor details and will
call a smartform. As we discussed this workflow will send a new hire
details of employee to the supervisor in the well formatted form thats
why we are using a smart form. in this function module we have used
few standard macros to read the data from container. and that will be
manipulated.
Now come back to the screen where we
have assigned the created rule number.
After giving the rule number then save.
again click a binding button on the screen.
if you remember this is the 3rd binding we
are doing.
First was Method binding.
second was task & event binding.
third is rule binding.
Here also there was a create button, when u click on to
that it will map automatically the mapping. Now the task
and the rule are bound.
Now you have created the work flow and now you have
test it. for testing there are few tools available. Go to
transaction 'SWUD'. the transaction looks like below
screen.
Here there will be few verification
methods. click on them you will see
the below screen/
Here make sure whether all the tick marks are green. If
some thing is red cross mark, then it means you need
to maintain some settings here. We have to make sure
all the RFC configurations are working properly.
With out this RFC destination , the work flow will not
work. Majority of these setting will be done by basis
team , but we need to check mainly the RFC destination
working properly or not.
And the other things you need to check are whether the task
is started or not, and whether the workflow is hanging or not.
workflow is hangin means nothing is happpening. it is just
running ina loop. so you need to look into it and solvethe
problem.
Since our plan is to test the workflow. Click on the Test
environment .































Leave a Reply