Skip to Content
Author's profile photo Former Member

Toolbar script to unlock contract documents that are stuck in Workflow phase

We had a situation in CLM Production where some contract documents were stuck in approval phases and we were unable to unlock them.

As is the case in most organizations, we have contract document approvals / rejections after the respective Legal / Finance / Sourcing team approves or rejects the contract. If it is approved, it moves to Approved phase and when it is rejected it moves back to Draft (or initial) phase for the contract owner to make changes and resubmit. There were a handful of contracts (~31) which were stuck in their approval phases and had remained locked even after approval / rejection.

SAP Basis team restarted the ODP_Workflow_Event Daemon and also restarted the application. What we could not do was to take those contracts out of locked phase as the Edit button was no longer there nor did the Legal / Finance / Sourcing teams and the contract owners had the ability to unlock the contract.

We referred the post below and saw that Sys admin already has Break document lock as Allowed. Though we could never really find the button which said “Break Document Lock”

We also canceled the workflow for these errant documents from Setup > Workflow definitions > Current workflow processes but when the user goes in to the contract, he/she still did not see the  Edit button.

Here is what we did to manually unlock these contract documents. We developed a toolbar script itilizing the IapiDocumentLockManager in our Development instance with the following parameters:

Contract document script view.png

This put a script option on all contract documents as below. In other words, this script provided an option on all contract documents in PROD with a Scripts > Unlock icon and we then had to manually go into each of the 31 contract documents that were stuck to unlock. We did all this on a Sunday to ensure no users were there in the system. Once we accomplished this, then the toolbar script was made Inactive.

Contract document script view.png

One tricky part was to identify which contracts documents were stuck. This was the most tedious part as there were many contract documents in approval phases for legitimate reasons and we didn’t want to unlock those unnecessarily.

We had to write a query for this to fetch those contract documents. Key here was to catch those contract documents which were not locked by “System”. As you know once you put the contract documents in any approval phase, system shows a message “Locked by System on….”. This message was not available on those contract documents that were stuck.

The query snippet that we wrote is as follows:








(select docref_object_id from db2clm.FCI_DOC_LOCK t6

where lock_mode=1 and locked_by_object_name is null)

So by doing the above the problem was solved but the issue is we still dont know why it happened in the first place. We have raised an OSS message with SAP. We do have 2 servers in PROD for HA. Does it have any impact on the system if the Workflow engine Daemon is run on any of these service?

Thank you,


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Vikram,

      Thanks for the post. We enabled the script and it works fine.

      However, I am facing an issue. When we unlock such documents, and then try to restart the approval process through, say,

      Draft --Internal Review -- Initiate Approval(workflow phase)

      the system doesn't allow me anymore to put the doc to workflow phase again.

      Any insights on this. Did SAP come back on this.

      One thing I noticed is even afte cancelling workflow, the contract doc appears in the list of Current Workflow Processes and the phase is "Initiate Approval" itself.

      Any remarks will be valuable.



      Author's profile photo Shashank Agrahari
      Shashank Agrahari

      hi Vikram,

      Thanks it helped!!



      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you, glad to know the fix worked out for you.

      Author's profile photo Former Member
      Former Member

      Hi Vikram,

      We were  facing same issue and similar work around was provided to business.

      I am doing follow up with SAP on this topic for last 3 to 4 months,  to identify the root cause, but still no success.

      In case, if you get to know root cause, do let us know.



      Author's profile photo Gianno De Wee
      Gianno De Wee

      Hi Vikram,

      I have done the script, but I keep on getting this error when I run the scripScript.png



      Author's profile photo Former Member
      Former Member

      Hi Vikram,

      Thanks for the post.

      We are facing similar kind of issue. However Approver already approved the document but still it is showing that approval is pending. i.e. Approval Status is in (4) as per RG.

      I want to try above method mentioned by you, but my question is will the status of document move to next phase or again will it come back to initial phase ?