Setting a rule to Preventive And Corrective Action(CAPA) object through PX

Hello everyone,

I’m trying to set a rule for the CAPA object through the PX code and struggling with it.

I saw an example in the SDK guide:

Example 17–2 Setting rules for PPM objects
try{
//Get Program
IProgram pgm =
(IProgram)session.getObject
(ProgramConstants.CLASS_PROGRAM,”PGM00239″);
//Get Object and add it as a relationship under the Content tab
IChange eco = (IChange)session.getObject(ChangeConstants.CLASS_ECO,”C00060″);
ITable table = pgm.getTable(ProgramConstants.TABLE_RELATIONSHIPS);
IRow row = table.creator(eco);
//Get the Control object status
IStateful state = (IStateful)pgm;
IStatus[] statuses = state.get states();
IStatus ctl_status = null;
for(int i=0; i<statuses.length; i++){
if(statuses[i].getName().equals(“In Process”)){
ctl_status = statuses[i];
break;
}
}
//Get the Affected object status
state = (IStateful)eco;
statuses = state.get states();
IStatus aff_status = null;
for(int i=0; i<statuses.length; i++){
if(statuses[i].getName().equals(“Submitted”)){
aff_status = statuses[i];
break;
}
}
//Add Rule
HashMap map = new HashMap();
map.put(CommonConstants.ATT_RELATIONSHIPS_RULE_CONTROLOBJECT, PGM);
map.put(CommonConstants.ATT_RELATIONSHIPS_RULE_AFFECTEDOBJECT, eco);
map.put(CommonConstants.ATT_RELATIONSHIPS_RULE_CONTROLOBJECTSTATUS,
ctl_status); map.put(CommonConstants.
ATT_RELATIONSHIPS_RULE_AFFECTEDOBJECTSTATUS, aff_status);
row.setValue(CommonConstants.ATT_RELATIONSHIPS_RULE, map);
System.out.println(row.get cell
(CommonConstants.ATT_RELATIONSHIPS_RULE));
}catch (APIException ex) {
System.out.println(ex);
}

 

 

When I tried to implement it in the CAPA object, I failed.

What I’m trying to do in my PX code is, Add CAPA objects to the relationships tab of a “Main CAPA” object and create a rule inside the relationships tba that the workflow status of the “Main CAPA” will determine the workflow status of the other CAPA’s objects inside the relationships tab.

Here is my code:

 

package maincapa;

import com.agile.api.*;
import com.agile.px.*;
import java.util.*;
import java.sql.*;
// additional imports here

/**
*
* @author Menny Atia
*/
public class MainCAPAPX implements ICustomAction {
// public variables here
int totalcomponents=0;
String pntxt = “”;

public ActionResult doAction(IAgileSession session, INode
actionNode, IDataObject data)

{
ActionResult ar = null;
String message = “”;
try
{
// Main Program Flow:
// 1.
// 2.
// 3.

// message = data.getName() + System.lineSeparator();
String source = data.getValue(QualityChangeRequestConstants.ATT_PAGE_TWO_LIST02).toString();
String pdLine = data.getValue(QualityChangeRequestConstants.ATT_COVER_PAGE_PRODUCT_LINES).toString();
IQuery sessionQry = (IQuery)session.createObject(IQuery.OBJECT_TYPE, data.getAgileClass());
sessionQry.setCriteria(“[“+ QualityChangeRequestConstants.ATT_COVER_PAGE_STATUS + “] not in (‘$STATUSTYPE.COMPLETE’, ‘$STATUSTYPE.CANCEL’) and ” +
“[“+ QualityChangeRequestConstants.ATT_PAGE_TWO_LIST02 + “] in ‘” + source + “‘ and ” +
// “[“+ QualityChangeRequestConstants.ATT_PAGE_TWO_LIST17 + “] in ‘Product Failure:כשל במוצר ‘ and ” +
“[“+ QualityChangeRequestConstants.ATT_COVER_PAGE_PRODUCT_LINES + “] Equal To ‘” + pdLine + “‘ and ” +
“[“+ QualityChangeRequestConstants.ATT_COVER_PAGE_QCR_NUMBER + “] starts with ‘CAPA'”);
Iterator itr = sessionQry.execute().getReferentIterator();

while(itr.hasNext()) {
IQualityChangeRequest capmain = (IQualityChangeRequest)itr.next();
ITable rlstp = data.getTable(QualityChangeRequestConstants.TABLE_RELATIONSHIPS);

try{

rlstp.createRow(capmain);

message += capmain.getName() + ” Has Been Added To The Relationships Tab” + System.lineSeparator();
} catch(Exception e){

}
}
ar = new ActionResult(ActionResult.STRING,message);
message += “No CAPA To Add To The Relationship Tab” + System.lineSeparator();

}
catch (Exception e)
{
// error handling here
ar = new ActionResult(ActionResult.EXCEPTION, e);

}
finally
{
// close files, db connections, etc…

}

return ar;

}

}

 

Thanks.

Menny.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.