cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a request form in workflow

Former Member
0 Kudos

Dear Gurus,

Hope you all are fine. I am new to workflow. I need to make a z form (Leave request form), in which a user enter the details. After entering the details, user will see his/her leave quota in form and when he save the button, workflow will start. the form will go to head of department who will approve or reject it. Can anybody guide me how can i do this? In workflow we can make form in screen painter? right? How can i do it? Also, i am also confused on one thing. Shall i create form in header option of workflow or as a step in worlflow? Kindl help in this regards.

Many Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

OK i am using work flow form options. I have made a small workflow, in which a user can requests for leaves and than it will go to his supervisor who will approve or reject it. I want to ask that different user has different supervisors? how can i tell this to work flow? in simple ABAP code i can fetch the supervisor of that use from table  but how can i do this in work flow? can anyone explain please.

Thanks

former_member185167
Active Contributor
0 Kudos

Hello,

"in simple ABAP code i can fetch the supervisor of that use from table  but how can i do this in work flow?"

You can use that same simple ABAP code in workflow. Create a method (of a BOR or class) that uses that ABAP. Create a task (TS...) that calls that method. Create a workflow step that calls that task.

What table do you select from to find a supervisor??

regards

Rick Bakker

Former Member
0 Kudos

> I want to ask that different user has different supervisors? how can i tell this to work flow?


I recommend that you get yourself familiar with "Agent determination". If you open the step in the workflow builder, there is a place for agent determination. You have different options there - one of them is a rule function module. Basically you can develop your own function module, and then in this function module you can find and return the supervisor (=agent) to the workflow. There rule function module must have certain parameters in order to work within workflow, but I am sure you will find examples for this.


Regards,

Karri

former_member215542
Active Participant
0 Kudos

Also the determination of supervisor/ request approver depends on the requirements of the organisation. In most cases it is immediate supervisors, in case you have implemented HR, you will have to first find the PERNR of the user and then identify the position and org assignment details. Then find the reporting manager. I would suggest that you get yourself familiarised with how the HR org structure works and how you can determine the supervisor of an employee.

There should be a lot of material available on the internet regarding the same.

Former Member
0 Kudos

Dear Rick,

Thanks for your reply. I will be using  hrp1001 table to find the supervisor. Can you send a link of any example which mention the way you are saying to do it. As i am new to workflow, it will be very helpful for me.

Thanks

Former Member
0 Kudos

I assume that as a supervisor you mean the manager of an organizational unit? If this is the case, there is standard solution for this. Just open the step in the workflow builder and check the agent determination part. There are multiple different ways to find get the agents and one of them is for getting the supervisor (based on rule 168 and function SWX_GET_MANAGER). Try that one out. No need to code anything by yourself. (Well, you might want to do some improvements to the standard rule, but that's another story.)

Regards,

Karri

former_member185167
Active Contributor
0 Kudos

Just as Karri says!

Former Member
0 Kudos

Dear KArri,

I checked the rule 168 and FM SWX_GET_MANAGER but it is not working. I dont know what is the reason. Could it be possible that i can make my own FM and role? If i write my own FM, do i need to add something related to workflow? Kindly help in this regards. I will be much appreciative if u can send a link for tutorial explaining how to make new rule using FM.

Thanks

Former Member
0 Kudos

Just Google "SAP workflow rule function".

Or take a look to the SWX_GET_MANAGER. Copy the same parameters to your own Z function module. You can just hardcode your own user ID to the function and return it to the ACTOR_TAB. Now your workflow should find your user ID as an agent. This should give you an idea how it works.

Regards,

Karri

Former Member
0 Kudos

Dear Karri,

Thanks for your reply. I am Little confused on making WF rule through FM. Inside SWX_GET_MANAGER, there are three more functional module are being used. These are 'RH_ACT_LEADING_POSITION',  RH_PBUILD_WORKFLOW and  RH_STRUC_GET. If i write my own FM, do i have to use these 3 FM as well? I can fetch my supervisor simply by select statement. Kindly guide little, after using select statement inside FM, what i have to do next? do i need to use these fm as well the one inside SWX_GET_MANAGER?


2nd question is do i have to attach this rule in form step or do i need to put user decision step? When i enter &_WF_INITIATOR& in form step, WF works fine but when  attach rule 168 in form, it does not work?is there something i am missing Karri?

Regards

Former Member
0 Kudos

You don't need to call those three function modules. You can write your own code and use select or whatever. The important part is to fill the ACTOR_TAB with the found agents.

You can add rule to any dialog step (background tasks do not require agents) including a "form step". Without seeing the system it is impossible to say why your rule 168 is not working. Are you giving the right parameters (through binding) to the rule? For example one of the parameters should be the employee ID. If the parameters are correct, then does your employee even have a supervisor maintained in the organisation. You could use the "where-used" function for the rule 168 - it is used in few standard workflows, and you could take a look.

Regards,

Karri

Former Member
0 Kudos

Another thing: Use the simulation functionality for the rule in transaction PFAC. You can give the parameters by yourself, and see whether it finds an agent or not.

Regards,

Karri

Former Member
0 Kudos

Dear Karri,

Thanks for your reply. I am confused on one thing. How will i pass employee number to rule 168 or my customized rule? Employee number is coming through a field in form. Look at my this small workflow.

Karri, here in form step i am giving rule 168. Look at image.

am i doing right? But in form, i can't see any field where i can give parameter. Even if i make my custom rule, how will i pass employee number to it?

Kindly Help.

Regards

Former Member
0 Kudos

It looks fine. It does not matter whether it is a standard or a custom rule, you need to do the binding between your workflow and the rule (or in this case FROM the workflow container TO the rule container). Click the "Binding" button (in your second screenshot). There you will see the workflow container in the left side, and rule container in right side. Drag and drop your employee ID container element from the WF container to the corresponding element in the rule container.

Regards,

Karri

Former Member
0 Kudos

Try testing your rule using transaction PFAC. You will find 3 parameters there (ORG_OBJECT, OTYPE, OBJID for rule 168. First test it, how it works (fill OTYPE = P, OBJID = your_personal_number). Then you can achieve the same in your workflow, where you can fill your container variables.

Former Member
0 Kudos

OK dear..i understand now. You are very helping. Thanks.

Former Member
0 Kudos

Dear Karri, have a look on this screen shot.

i have made new rule and test it. It gives position number of the person who will apply for leave. Kindly look at this binding screen. &LEAVEFORM.ZPERNR& is the employee number that is coming from form and &EMPNO& is the parameter which i am using in Fm to fetch the manager. But when i run the workflow it is coming to me, it suppose to go to supervisor. Am i putting right enteries on this screen/? Kindly help

Former Member
0 Kudos

Test the rule with PFAC. You can give the EMPNO as input, and you will see what it returns. Then you will whether it works or not. To make things simple, make your rule return (=fill the ACTOR_TAB) with a user ID (just hardcode it for testing purposes).

Your screen looks just fine. You are filling the EMPNO container element from your workflow container. The only problem that you might have with your binding is that perhaps the LEAVEFORM.ZPERNR is empty in the container. This I cannot see from the screenshort and you need to find it out from the workflow log.

Regards,

Karri

Former Member
0 Kudos

Dear Karri,

hope u r fine. I did check the rule in PAFC, if i give employee number, in return it will give employee number of superior. The form should go to supervisor. Rule is working fine. I also de-bugged it and employee number does comes in LEAVEFORM.ZPERNR. But when i execute the workflow, it does no go to supervisor. If i enter my employee number, it should go to my supervisor. But it comes to my workplace inbox.

Rule is working fine. If i give my employee number, it return employee number of my manager.  But workflow is not going to my manager inbox. what can be the issue? The first form is attached in the header. I put the employee number and than form comes to the form step, at this step it should go to supervisor.

Kindly help

Thanks

Former Member
0 Kudos

Does your manager/supervisor have a user ID maintained in infotype 105?

Basically the rule should return the USER ID (not the employee number). The work item will be sent to the user, so when he logs in to the system and opens his inbox, he will find the work item there.

You can enhance your rule in a way that it returns the user ID (OTYPE = 'US' and OBJID = '<user_id> of the supervisor and not the number.

Regards,

Karri

Former Member
0 Kudos

Thanks Karri,

As you said that USER ID should be passed, i did it and its working now. Before i was trying it through employee number. Thanks for ur help.

Former Member
0 Kudos

Dear Karri,

Hope you are fine. I have one question please. In the form step, where if supervisor Approve the form, infotype supposed to be updates. I do know ow to update infotye, bu i don't know how will i differentiate in "Approve" and Reject" because infotype can only be updated if supervisor approve the leaves. When i press the Approve and Reject button, it comes in the MODULE EXPORT_DATA_0003 INPUT. But here how can i fit "Approve" in If condition. How can i  find OK-code is approve so that i can use it in condition.

Thanks

Answers (3)

Answers (3)

0 Kudos

Hi,

Have a look at tutorial given in below link.

  • Using the step "Form" in Workflow (Simple example) (More details)
  • Using the step "Form" (Detailed example) (More details)

Regards,

Unni

Former Member
0 Kudos

HI,

In continuation to what Pulkit said, there is a standard leave approval workflow WS12300111. The workitem for this workflow can be processed from portal and not from SBWP. there is aready SAP standard a web dynpro application for entering/approving/rejecting leave request. The leave quota can also be seen there.

Regards

Ibrahim

Former Member
0 Kudos

You can keep the development of the application/form and the workflow separated. Just build your form with screen painter or whatever UI technology you want to use. Once the user clicks the save button from the form, I would assume that the data gets stored in the database. At this point you can create/trigger an event from your form. The event can be configured to start a workflow. (You don't need to develop the screen "from the workflow".)

The workflow delivers a work item to the approver. When the approvers click the work item, a task method gets executed. In this task method you can e.g. write code like CALL SCREEN, and this will open the same form that you developed previously.

I also recommend that you take try to participate some workflow training. Make also sure that you really need to create a new Z-objects for leave requests (there is standard solution in SAP) and make sure that there really is a need for dynpro / screen painter screens (why not some newer technology such as web dynpro?). Unless you are just doing some self-learning...

Regards,

Karri

Former Member
0 Kudos

Dear Karri,

Thanks for your reply. Actually i have not worked on work flow before, that is why i am confused. Ok i can develop separate form in screen painter. Can you please send sample code or tutorial which can show the rest of the steps? like calling workflow in screen painter, and sending it to another for approval etc.

Here we used to do this on Portal but company is going to install Fiori and they have to upgrade ECC as well for this. Till that time, they want this leaves thing in ECC.

Regards

anjan_paul
Active Contributor
0 Kudos

Hi,

   There is a FORM step with  APPROVE functionality   in workflow .

  Search in SCN for that. But as you are new to workflow, first learn basic of workflow. You will find lot of documents in Workflow space

http://scn.sap.com/community/bpm/business-workflow/content

Former Member
0 Kudos

Hi,

You need to do your homework. The only hint I will give you is to use events (you can create them with function SAP_WAPI_CREATE_EVENT). The application (=screens) do not need know much about workflow - you just create events such as CREATED, APPROVED, REJECTED etc from the code of your screen. and the workflow should be "listening" for those events.

As far as I know there are Fiori apps for the whole leave request scenario (submitting and approval).

Regards,

Karri

ronen_weisz
Active Contributor
0 Kudos

You can create a function module calling a regular dialog screen here it's regular ABAP.

only difference is you need to return a result parameter (1 = approve, 2 = reject etc.), and create a task calling a method with a returned result as well, if you use a fixed value domain for the result you will see the optional values in the workflow template as results of the task.

also if the user exits the screen you need to add an 'exit cancelled' command in the method so the workitem will remain in the users inbox.  

former_member215542
Active Participant
0 Kudos

If you are using portal, then there is a very high probability that you might also implement ESS/ MSS.

SAP already provides a standard solution to create leave request. Please go through the below documents and raise specific questions

SAP documentation on the standard WDA available for ESS

SAP Library - Business Package for Employee Self-Service (WDA) 1.50

Workflow configuration for leave request

Configuration of Leave request workflow for ESS/MSS