{
// better clone twice than to face the subtle errors that crawl out here..
final ProcessState next = state.deriveForAdvance();
final DefaultFlowController flowController = next.getFlowController();
final MasterDataRow masterRow = flowController.getMasterRow();
final ExpressionDataRow expressionDataRow = masterRow.getExpressionDataRow();
final Expression[] expressions = expressionDataRow.getExpressions();
if (next.isSubReportEvent())
{
next.setAdvanceHandler(EndSubReportHandler.HANDLER);
}
else
{
next.setAdvanceHandler(EndReportHandler.HANDLER);
}
final ReportStateKey parentStateKey;
final ReportState parentState = next.getParentSubReportState();
if (parentState == null)
{
parentStateKey = null;
}
else
{
parentStateKey = parentState.getProcessKey();
}
final FunctionStorageKey functionStorageKey =
FunctionStorageKey.createKey(parentStateKey, next.getReport());
next.getFunctionStorage().store (functionStorageKey, expressions, expressionDataRow.getColumnCount());
final StructureFunction[] structureFunctions = next.getLayoutProcess().getCollectionFunctions();
next.getStructureFunctionStorage().store(functionStorageKey, structureFunctions, structureFunctions.length);
final DefaultFlowController pfc = flowController.performClearExportedParameters();
final DefaultFlowController efc = pfc.deactivateExpressions();