cancel
Showing results for 
Search instead for 
Did you mean: 

Unlock Gp Action Step

Former Member
0 Kudos

In the following code I Get a GP Process and complete the action .

This works


	public String endGP(String processID, String recordID, String matNum) {
		Collator collator = Collator.getInstance();
		String retorno = "";
		int index = 0 ;
		try {

			IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
			IGPDesigntimeManager dtm = GPProcessFactory.getDesigntimeManager();
			IGPUserContext userContext = getUserContext();
			IGPProcessInstance process =
				GPProcessFactory.getRuntimeManager().getProcessInstance(
					processID,
					userContext);
			retorno = "no id " + process.getID();
			IGPActivityInstance inst[] = process.getChildrenInformation();
			boolean contabil = false;
			for (int i = 0; i < inst.length; i++) {
						
				IGPBlockInstance block =
					GPProcessFactory.getRuntimeManager().getBlockInstance(
						processID,
						inst<i>.getID(),
						userContext);
				IGPActivityInstance instBlock[] =
					block.getChildrenInformation();
				
				IGPActivityInstance actInst = null;
				IGPActivityInstance activityToUpDate = null;
				boolean readyToComplete = false;
				for (int j = 0; j < instBlock.length; j++) {
					//		   
	actInst = instBlock[j];
					if (actInst.isBlock()) {
						IGPBlockInstance blockInstance =
							(IGPBlockInstance) actInst;
						IGPActivityInstance instParalelo[] =
							blockInstance.getChildrenInformation();
					}
					if (actInst.isAction()) {
												IGPActionInstance action = (IGPActionInstance) actInst;
						
						IGPActivity activity = action.getTemplate();
						if (collator
							.compare(
								activity.getTitle(),
								"FIRSTSTEP")
							== 0 & action.getStatus().getCode() <= 5) {
									   
							activityToUpDate = actInst;
							readyToComplete = true;
							contabil = true;
						} else {
							if (collator
								.compare(
									activity.getTitle(),
									"SECONDSTEP")
								== 0 & action.getStatus().getCode()
			<= 5 & !readyToComplete) {
										activityToUpDate = actInst;
								readyToComplete = true;
							}
						}
					}

				}
				if (readyToComplete) {
					//		   messageMgr.reportSuccess("ready to complete");
					IGPActionCompletionData completionData =
						GPProcessFactory
							.getRuntimeManager()
							.createActionCompletionData(
							processID,
							activityToUpDate.getID(),
							userContext);
					IGPStructure out = completionData.getOutputStructure();
					//									   addStructure("centralFiscal_output");
					out.addStructure("centralFiscal_output");
					IGPStructure cfo = out.getStructure("centralFiscal_output");
					if (contabil) {
						cfo.setAttributeValue(
							"step",
							"FISCAL@@" + recordID + "@@" + matNum);
					} else {
						cfo.setAttributeValue(
							"step",
							"CENTRAL@@" + recordID + "@@" + matNum);
					}
					completionData.setState(IGPActionCompletionData.RESULT_STATE_COMPLETED_DONE_ONLY);
					completionData.setType(IGPActionCompletionData.ACTIVITY_TYPE_BACKGROUND);
									GPProcessFactory.getRuntimeManager().completeAction(completionData);
	retorno ="action : "+ activityToUpDate.getTemplate().getTitle()+ " is completed. ";
		
}catch (Exception e) {
			retorno ="Exception Finalize. "+ e.getLocalizedMessage()+ " : "+ e.getCause()+ " : "+ e.fillInStackTrace()+" : index : "+ index;
		}
		
		return retorno;
		//@@end
	}

the first time this code runs it ends the u201CFIRSTSTEPu201D .

this works perfect.

The problem is when we call this a second time to the end the u201CSECONDSTEPu201D.

When we do this we get the following :

"Exception Finalize. Object is locked : com.sap.caf.eu.gp.model.fnd.lock.AlreadyLockedException: Object is locked : com.sap.caf.eu.gp.exception.api.GPEngineException: Object is locked"

My question to you ubergeeks: is there a way I can release this lock in orther to finish the u201CSECONDSTEPu201D . or am I mucking up something somewhere?

Thank you in advance ,

Guy

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I opened up a CSS message on this problem .

the funny thing is if we end an action with the API then manually go into the portal and end the next action it works ,

it seems only not to work when i try too end two consecutive actions .

Former Member
0 Kudos

Hi Guy,

We also face this object is locked exception when we try to complete the action through GP public api. Do you find the root cause?

Best Regards

Tom