title: Calling previous step from the current step in the spring batch
body: <p>I have a requirement to read one of our module related transaction table using Spring default FlatFileReader to fetch record and use Spring FlatFileWriter to write so I don't have control on these reader and writer as they are not custom one. 
  Then the second step is tasklet to transmit the same flat file to the remote location using SFTP. </p>
  
  <p>But some times when Spring FlatFile reader don't get record then it will generate empty File with header. </p>
  
  <p>So I am checking the content of the file in the second step tasklet and checking if it contains header and record then transmit the same in that step otherwise I'm inserting some default records which is holding some logic into the transaction table. Once insertion is completed then I would like to call previous step that is step 1 Spring flat file reader from the current tasklet step.</p>
  
  <p>Please let me know on the same to call previous step from the current step which is tasklet.</p>
  
  <p>Please find the below sample job config</p>
  
  <pre><code>    &lt;batch:step id="FlatFileStep3" next="TransmissionFlatFileStep4"&gt;
      &lt;batch:tasklet&gt;
          &lt;batch:chunk reader="FlatFileReader" writer="FlatFileWriter" commit-interval="50"/&gt; 
      &lt;/batch:tasklet&gt;
                     &lt;/batch:step&gt;
  &lt;batch:step id="TransmissionFlatFileStep4"&gt;
      &lt;batch:tasklet&gt;
          &lt;batch:chunk ref="TransmissionFlatFileTasklet"/&gt;    
          &lt;batch:next on="NOT_COMPLETED" to="FlatFileStep3"/&gt;
          &lt;batch:next on="COMPLETED" to="UpdateTxnTableStep5"/&gt;
      &lt;/batch:tasklet&gt;
  &lt;/batch:step&gt;
  &lt;batch:step id="UpdateTxnTableStep5"&gt;
      &lt;batch:tasklet&gt;
          &lt;batch:chunk ref="UpdateTxnTableTasklet"/&gt;  
      &lt;/batch:tasklet&gt;
  &lt;/batch:step&gt;
  </code></pre>
  
  <p>when the spring batch comes to the TransmissionFlatFileStep4 then in the TransmissionFlatFileTasklet I have logic to check the file content. if the file is empty then I have insertion logic to insert some default data to our transaction table. Then in the same tasklet (TransmissionFlatFileTasklet) I override the public ExitStatus afterStep(StepExecution stepExecution) method by implementing StepExecutionListener interface and set the custom exit status NOT_COMPLETED &amp; COMPLETED
  so its calling UpdateTxnTableStep5 when the status is COMPLETED as well as it call FlatFileCreationStep3 on NOT_COMPLETED so this time the flat file will be generated with those default records but once the flat file completes then it should again call TransmissionFlatFileStep4 which is not happening the batch is throwing error : unable to find the next state</p>