on 05-10-2011 10:31 AM
Hi
We are working on SAP e sourcing 5.1/ CLM 2.0. Here we are doing a clean up exercise wherein we want to move all the existing contracts to "executed" state. PS we have defined 6 phases of the contracts i.e
Internal Draft Preparation
Internal Review
Vendor Draft
Final Contract Draft Review
Final Contract Approval
Executed
Also we do not have any workflow configured in any of the phases. Is it possible to move all the contracts existing in the system to executed phase from their current respective phases.
Mudit Saini
Hi Rob
I have run that script.It is working fine for contract that are not in executed phase as yet i.e. it is advancing these agreements to "executed " phase
However I am facing a problem with the below mentioned code for contracts that are already in executed phase:
-
PhaseList = ContractDocumentHome.findValidNextPhasesExternalIds(contractDocument); // to get all the available next phases
if (!(contractDocument.getCurrentPhase().getDisplayName(session).equals("executed")) ||!(contractDocument.getCurrentPhase().getDisplayName(session).equals("Executed") ))
{
NextPhase = PhaseList.iterator().next();* //Error// *
logMsg.setLogMessage("****NextPhase="+NextPhase);
Logger.info(logMsg);
ContractDocumentHome.changePhase(contractDocument,NextPhase);
}
-
For contracts that are already in executed phase, NextPhase = PhaseList.iterator().next(); throws an error
Error executing script: Sourced file: inline evaluation of:
``import com.frictionless.api.contracts.ContractIBeanHomeIfc; import com.frictionl . . . ''
: target exception.
Any ideas how this exception can be handled?
Regards
Mudit Saini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mudit,
Usually 'Executed' is the last phase a document can move to. There are no phases after that. This seems to be the case with your system too.
Going by this logic, for contracts that are already in executed phase iterator.next() will return a null. You might need to accomodate a null check in your code
This is just my guess. Hope this helps.
Thanks
Devesh
Hi Mudit -
Changes to the database directly should not be done as those bypass application logic and functionality. For example, something like the "change history" would not be updated if a database change were made directly (this is just one example).
I believe a script could still be written, it just might need a bit more logic in it. In addition to the changePhase IAPI, there are IAPIs to get the "valid next phase(s)". The logic in the script could be to get those valid next phases, then changePhase, up until it gets to the last phase (presumably "Executed").
Rob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rob
I couldn't find IAPIs to get the "valid next phase(s)". Can you plz let me know what is the method available for this.
Lets say for "valid next phase(s)", we have nextValidPhase() available would the following script be able to achieve my objective:
-
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat formatter= new SimpleDateFormat("dd-MM-yyyy");
String dateNow = formatter.format(currentDate.getTime());
contractHome = IBeanHomeLocator.lookup(session,com.frictionless.api.contracts.ContractIBeanHomeIfc.sHOME_NAME);
contractList = contractHome.findWhere("DISPLAY_NAME LIKE 'A%' ");
for(Iterator iterator1 = contractList.iterator(); iterator1.hasNext();)
{
ContractIBeanIfc masterAgreement = (ContractIBeanIfc)iterator1.next();
contractHome.upgradeToEdit(masterAgreement);
contractDocumentList = masterAgreement.getContractDocuments();
for(Iterator iterator2 = contractDocumentList.iterator(); iterator2.hasNext();)
{
ContractDocumentIBeanIfc contractDocument = (ContractDocumentIBeanIfc)iterator2.next();
ContractDocumentHome = contractDocument.getIBeanHomeIfc();
ContractDocumentHome.upgradeToEdit(contractDocument);
while (! (contractDocument.getCurrentPhase().getDisplayName(session).equals("executed"))
{
ContractDocumentHome.changePhase(contractDocument, ContractDocumentHome.nextValidPhase());
}
}
}
-
Plz suggest
Regards
Mudit Saini
Hi Mudit -
The IAPI to get the valid next phases is available on the ContractDocumentIBeanHomeIfc and is as follows:
java.util.List
findAllValidPhasesExternalIds(com.frictionless.api.ibean.AbsDocIBeanIfc doc);
As you can see, the IAPI returns a List, so the code shown above will need to accomodate for the fact that a list of valid phases is returned. It probably will be easiest to simply use the first element in the list, and change phases to it.
Other than that, the code looks like it will basically address the requirement. Obviously, it should be tested to confirm the behavior is as expected.
I hope this helps.
Regards,
Rob
Hi Mudit - This is possible using Scripting. You could develop a script that uses the "changePhase" IAPI to update contracts as appropriate.
Hope this helps.
Rob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Rob
Thanks for your reply. Actually in our business scenario phase definition has been changed over time and it is not consistent for all the contracts. That is why I am not able to deploy a script. Is there anyway we can change is probably at the database level? plz suggest
Regards
Mudit Saini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.