BOI - AP_ManualCheckRegister_upd

I have a BOI script that monitors a directory for Concur export files running as a service.  When a file is detecdted, the scipt creates an AP Manual Check Batch.  The script works but I am having a problem doing the printing and register update.  Here is snippet of my code that is executed after the last record of the file has been imported into the batch.  Note the data is store in an array so the import file has already been closed.  Also note that after the import, you can go into MAS and manually update the batch.  The Log function writes the application event log based on a debug setting.

 

' Post Batch after last record
If aDistLine(i, 1) = iRecordCount Then

  ' Close the Manual Check Object
  Log("Closing oMCObj", 1)
  If Not oMCObj Is Nothing Then
    oMCObj.DropObject()
    oMCObj = Nothing
  End If

  ' Print and post the batch
  Log("Creating NewObject AP_ManualCheckRegister_upd", 1)
  oMCRObj = oScript.NewObject("AP_ManualCheckRegister_upd", oSS)
  Log("NewObject AP_ManualCheckRegister_upd created", 1)

  If CBool(oMCRObj.nBatchEnabled) Then
    retVal = oMCRObj.nSelectBatch(sBatchNo)
    Log("nSelectBatch " + sBatchNo + " retVal: " + retVal.ToString(), 1)
    If retVal <= 0 Then
      Log("Warning nSelectBatch Message: " + oMCRObj.sLastErrorMsg, 0)
      '===========================================================================
      'Returns: The status of one or more batches has changed.
          'Verify the current status and try again.
      '===========================================================================
    End If
  End If

  retVal = oMCRObj.nSetPostingDate(sPostingDate)
  Log("nSetPostingDate " + sPostingDate + " retVal: " + retVal.ToString(), 1)
  If retVal <= 0 Then
    Log("Warning nSetPostingDate Message: " + oMCRObj.sLastErrorMsg, 0)
  End If
  retVal = oMCRObj.nProcessReport("PRINT")
  Log("nProcessReport retVal: " + retVal.ToString(), 1)
  If retVal <= 0 Then
    Log("Warning nProcessReport Message: " + oMCRObj.sLastErrorMsg, 0)
    '===========================================================================
    'Returns: The Manual Check and Payment Data entry files are empty.
        'NOTE: They are not empty, can be manually printed
    '===========================================================================
  End If
  retVal = oMCRObj.nUpdate()
  Log("nUpdate retVal: " + retVal.ToString(), 1)
  If retVal <= 0 Then
    Log("Warning nUpdate Message: " + oMCRObj.sLastErrorMsg, 0)
    '===========================================================================
    'Returns: You are not authorized to update the Manual Check and Payment Register.
    '===========================================================================
  End If

  oMCRObj.DropObject()
  oMCRObj = Nothing

End If