In order to integrate the system activity into the process flow and to reach the next step after having exported the CSV or end the process correctly, the step status has to be modified. In the example this is done using the method markActivityAsCompleted:
Changing the step status to completed
<?php
class csvSystemActivity extends AbstractSystemActivityAPI
{
...
private $fieldDelimiter;
private $csvFile;
private $csvFilePointer;
private $numberOfRows;
protected function exportCsv()
{
$this->increaseSystemActivityCalls();
$this->debug('exportCsv start');
$this->loadGlobalSettings();
$this->openCsvFile('w');
$this->debug('executeMethodForSubtable for '. $this->getFixSubtableName());
$this->initLineCounter();
$this->executeMethodForSubtable('writeSubtableLineIntoFile', $this->getFixSubtableName());
$this->storeOutputParameter('targetFile', $this->csvFile);
$this->storeOutputParameter('numberOfRows', $this->numberOfRows);
$this->markActivityAsCompleted();
}
protected function increaseSystemActivityCalls()
{
$systemActivityCalls = $this->getSystemActivityVar('systemActivityCalls', 0);
$systemActivityCalls++;
$this->debug('system activity calls: ' . $systemActivityCalls);
$this->setSystemActivityVar('systemActivityCalls', $systemActivityCalls);
}
protected function loadGlobalSettings()
{
$this->fieldDelimiter = $this->resolveInputParameter('fieldDelimiter');
}
protected function openCsvFile($mode)
{
$this->csvFile = $this->getTempPath() . DIRECTORY_SEPARATOR . 'test.csv';
$this->debug('csvFile: '.$this->csvFile);
$this->csvFilePointer = fopen($this->csvFile, $mode);
}
protected function initLineCounter()
{
$this->numberOfRows = 0;
}
protected function writeSubtableLineIntoFile()
{
$this->debug('writeSubtableLineIntoFile for '. $this->getFixSubtableName());
$subtableValues = $this->resolveInputParameterListValues('fieldList');
$csvLine = implode($this->fieldDelimiter, $subtableValues)."\r\n";
fwrite($this->csvFilePointer, $csvLine);
$this->numberOfRows++;
}
}
If you now execute the system activity, it will be completed and the process progresses to the next step or is completed depending on the workflow configuration.