OK, With a little help from David Graham with the queryresult, I have the answer to my question. Also, I'm setting the Resolution Date of the Variance workflow process (I thought I saw someone asking about this but can't find the post). The code is listed below.
/* Workflow code to change the state of the objects in the Affected Objects table of the Variation. */
wt.pom.Transaction trx = new wt.pom.Transaction();
trx.start();
wt.fc.QueryResult affected = wt.change2.ChangeHelper2.service.getChangeables((wt.change2.ChangeIssue) primaryBusinessObject);
while(affected.hasMoreElements()) {
wt.fc.WTObject obj = (wt.fc.WTObject)affected.nextElement();
java.lang.String type = wt.type.TypedUtilityServiceHelper.service.getExternalTypeIdentifier(obj);
if (type.equals("WCTYPE|wt.doc.WTDocument|com.YourDomain.WTDocumentSoftType")) {
wt.fc.Persistable persistable = (wt.fc.Persistable) obj;
if(persistable instanceof wt.lifecycle.LifeCycleManaged) {
wt.lifecycle.LifeCycleManaged lcManaged = (wt.lifecycle.LifeCycleManaged) persistable;
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState(lcManaged, wt.lifecycle.State.toState("PRODUCTION"));
}
}
}
trx.commit();
/* Workflow code to set the Resolution Date of the Variance workflow process */
com.ptc.windchill.pdmlink.change.server.impl.WorkflowProcessHelper.setPRResolutionDate((wt.change2.ChangeIssue) primaryBusinessObject);