2 Replies Latest reply on Oct 18, 2012 6:27 PM by nate.keller

    Halting the Batch Engine within sub events

      I'm trying to fail the batch engine from within a sub event. Here's the steps that I'm trying to accomplish:

      1. Drop file in OpenBatch
      2. Trigger Batch Load Script with BATCHENG initialization.
      3. Batch Load Script triggers FDM subevents "up to load"
      4. "ImportAction" or a sub event (i.e. AftImport) has a conditional script that tests a condition. If the condition fails, then the Batch Load Script should be failed.
      5. Error is listed in BatchEngine log

      Now I have found a way to fail the Batch Engine and write the log by adding the following statement to the Adapter LOAD event. The 'Exit Function' command effectivly kills the batch loader and then an error is written.

      'Check Load Process Status For Import Process Status.
      'If Import Failed, Then checksums were invalid. Used to prevent Batch Loader from pushing load
      If API.MaintenanceMgr.fProcessStatus(API.POVMgr.PPOVLocation, API.POVMgr.PPOVCategory, API.POVMgr.PPOVPeriod).lngStatus = 2 Then
           'Log a CheckSum Error
           objR.strErrDesc = "File Checksum does not match FDM. File was not fully loaded."
           objR.lngErrCode = 99999
           objR.blnIsErr = RES.FDMTrue
           Exit Function
      End If


      But I would prefer to run it in the ImportAction or other sub event. Or is there a better way to return an error to the engine indicating that a condition has failed and the process should be halted.
        • 1. Re: Halting the Batch Engine within sub events
          Stuart Game
          Hi Nate

          What is the condition that you want to test for?

          We have had clients where we did a lot of pre-validating of the source files before importing to FDM, we handled that in the custom batch script created to launch the batch engine, e.g.

          1. Check file header for ceratin conditions
          2. Check record count matches control total
          3. Check period exists in the file
          4. Check TB balances per entity

          We dropped the files into a 'SourceFiles' folder and they were only copied in to the OpenBatch folder if they passed all the pre-tests, that way only files we knew were in the correct format were attempted to process.

          It also meant that we could easily distinguish issues with the source file from issues with the mapping logic.

          Hope this helps
          1 person found this helpful
          • 2. Re: Halting the Batch Engine within sub events
            Hi Stuart,

            Thanks for the feedback, I follow your point... I might approach it that way.

            My source file is 500k records, so I've chosen to query the corresponding TDATASEG# table post import event because it's quicker than reading into an in-memory recordset. The sum I run on the corresponding TDATASEG# table runs in 5 seconds. I'm running the checksum in the Import Action.