cancel
Showing results for 
Search instead for 
Did you mean: 

Two Workflows in Sequence

Former Member
0 Kudos

Hi Experts ,

I have requirement of having two workflows at two consecutive phases one after the other.

Like if my phases are a b C D e .

I am having workflows at C and D .

Problem I am facing is ,if the workflow at Phase C gets approved it shall move to Phase D and It is rightly moving and adding the approver which I am picking at workflow D by pre script , but it is not locking the document though the Approver is getting the option to approve or reject the document at Phase D.

Prescript of XPDL at C at Approval activity is : Pick the owner of the document and add as approver

Postscript of XPDL at C:If approved go to Phase D for this the code is like


if (getApprovalStatus() == APPROVED)
{
    home = doc.getIBeanHomeIfc();
    home.upgradeToEdit(doc);
    home.changePhase(doc,"D");
 }

Prescript of XPDL at D at Approval activity is :Pick some other collaborator role of custom type

Postscript of D:If approved go to Phase e for this the code is like



if (getApprovalStatus() == APPROVED)
{
    home = doc.getIBeanHomeIfc();
    home.upgradeToEdit(doc);
    home.changePhase(doc,"e");
 }

What I feel is like in Postscript of C the document is being brought to edit mode to change phase of the document then phase change is taking place and since one more workflow is attached it is executing the prescript of it first i.e picking another approver and adding as approver but not locking the document.

I tried using the following code after changing phase in postscript of C hoping it might help in locking the document!.But it din't help me still.

home.save(doc);

home.downgradeToView(doc);

Any help wud be gr8!

Regards,

Uday

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Baski n Rob,

I have already tried the other two ways mentioned and one more option feasible for me was , of introducing one more phase in between. I am waiting for the client's call .

When I tried second option i.e locking the document ...it does lock the document and doc wud go for approval but no one can approve or reject the document because system is throwing error message saying document was locked by so n so person and you cannot edit it!..

So I am left with two options!.

Noppong , technically I think that might happened because we are using changePhase method which changes phases internally via the configurable phase handler so since it is like we are using coding and not changing phase manually to the workflow attached phase ..the document is in edit mode.. That's what I think!.

Regards,

Uday

Former Member
0 Kudos

Hi Uday,

Per Rob comments it is clear that taking the lock way might not be a good idea.. A selling point for merging workflow could be the amount of details logged into the workflow history is available as report for the business users to keep track where the workflow..

Regarding lock aquicstion, I guess the issue you ran into is proabably because of the users who is expected to aquire the lock. I guess it should be the workflow process owner?

@Noppang: reasoning why workflow lock is not in phase 😧 when you aquire the lock for the same user, for the same document 1 or more times, it writes a single lock entry into the table, irrespective of the number of time you try to lock. In this case, when in Phase C post script there is already a lock for the same user/same object combination, when you attempt to go to phase D, lock is tried again, but it is a NO-OP. when the workfow @ phase c is done, the only lock is released..

thanks,

Baski

Former Member
0 Kudos

Hi,

When a workflow is started, the workflow engine locks the business document by introducing entries in the FCI_DOC_LOCK. When the workflow execution is complete, the lock is released by the workflow engine.

In the scenario described by you, When in phase C, the document is locked, when trying to advance to phase D from postScript of "C", the document is already in lock by the same workflow user.

Now at the end of workflow executoin for C, the only lock is going to be relased. Hence the document is not locked even in this phase.

Here are some options that I can think of:

1. Try merging phases if that is an option

2. Aquire a manual lock using the document lock manager api in D pre-script as done by workflow engine..

thanks,

Baski

Former Member
0 Kudos

Hi -

In general, we do not recommend applying the locks manually. The first option pointed by Baski is preferred: combine the 2 workflow phases into 1 workflow.

Rob

Former Member
0 Kudos

Hi Baski,

I am also new in SAP Soucing. I have some doubt on the option#2. You said that

When a workflow is started, the workflow engine locks the business document by introducing entries in the FCI_DOC_LOCK

. When the document is advanced to phase D the workflow of phase D should be started. Why the workflow engioe does not lock the document as it shold do. Could you please help clarify.

Noppong

Thanks you and appreciate for you reply.