I am writing a service that monitors a directory for files downloaded from a web service called Concur. The employees submit expense reports in Concur, the managers approve them and then the employee is reimbursed by Concur. To account for the expense payments the customer wants to bring in the transactions as wire transfer manual checks and associate the expenses with the employee (vendor). I have shortened my code to make it more legible including the directory monitoring and file manipulation. What is here is the BOI code from a function call that returns a boolean (true - data imported or false - data not imported). I have also modified the code to write the Job, CostCode, and CostType values as I kept getting "AccountKey is not a valid IO field" which what I really want to use since there will be no Job associated with the expenses. At this point, no data is being saved. I am receiving a retVal of 2 for both of the nAddLine() methods but when I try to nWrite() the distribution line I get: "The record is not in an editble state" Using oInputFile As New StreamReader(dra) Try ' aDistLine(row, column) is an array with the counters and data from the input file ' column 1 is the row number in the file ' column 2 is the Expense Report number in the file ' column 3 is the Expense Report row number ' column 4 is the number of distributions in the Expense Report ' column 5 is the pipe delimited data ' Initialize MAS connection oScript.Init(masPath) oSS = oScript.NewObject("SY_SESSION") If Not (CBool(oSS.nLogon())) Then retVal = CBool(oSS.nSetUser(masUser, masPW)) End If retVal = oSS.nSetCompany(masCompany) ' Start Manual Check Entry If Not SetSession(oSS, "A/P", "AP_ManualCheck_Ui") Then Return False End If ' Start Looping through data For i = 1 To iRecordCount aInputData = aDistLine(i, 5).Split("|") ' First ER line - Create Manual Check Header If aDistLine(i, 3) = 1 Then oMCObj = oScript.NewObject("AP_ManualCheck_bus", oSS) ' Create batch only on the first line in the file If oMCObj.nBatchEnabled = 1 And aDistLine(i, 1) = 1 Then ' New Batch sBatchComment = "Concur Import: " + aInputData(1) + " " + aInputData(2) retVal = oMCObj.nSelectNewBatch(sBatchNo, sPrivate, sBatchComment) End If ' Get next transfer number oAPOptionsObj = oScript.NewObject("AP_Options_Svc", oSS) retVal = oAPOptionsObj.nGetNextSequenceNoForWireTransferXfer(sCheckNo) oAPOptionsObj.DropObject() oAPOptionsObj = Nothing ' Create Manual Check Header Key retVal = oMCObj.nSetKeyValue("BankCode$", sBankCode) retVal = oMCObj.nSetKeyValue("CheckType$", "W") sCheckNo = "W" + sCheckNo retVal = oMCObj.nSetKeyValue("CheckNo$", sCheckNo) retVal = oMCObj.nSetKey() '============================================================== ' Returns 2 - New '============================================================== ' Create Manual Check Header Fields 'retVal = oMCObj.CreateWireTransfer() retVal = oMCObj.nSetValue("BatchNo$", sBatchNo) retVal = oMCObj.nSetValue("CheckDate$", Replace(aInputData(23), "-", "")) retVal = oMCObj.nSetValue("CheckAmt", CDbl(aInputData(31))) retVal = oMCObj.nSetValue("APDivisionNo$", "00") retVal = oMCObj.nSetValue("VendorNo$", aInputData(4)) retVal = oMCObj.nSetValue("Comment$", aInputData(26)) retVal = oMCObj.nSetValue("WireTransferNo$", aInputData(18)) ' Create Invoice Header Line retVal = oMCObj.nAddLine() ' Create Invoice Header Fields 'retVal = oMCObj.oLines.nSetValue("InvoiceType$", "A") 'sInvoiceNo = "Concur-" + aInputData(19) 'retVal = oMCObj.oLines.nSetValue("InvoiceNo$", sInvoiceNo) 'retVal = oMCObj.oLines.nSetValue("InvoiceDate$", Replace(aInputData(23), "-", "")) 'retVal = oMCObj.oLines.nSetValue("TaxSchedule$", "NONTAX") 'retVal = oMCObj.oLines.nSetValue("InvoiceComment$", aInputData(26)) 'retVal = oMCObj.oLines.nSetValue("InvoiceAmt", CDbl(aInputData(31))) End If ' Create distribution line for each line in the Expense Report If aDistLine(i, 3) = aDistLine(i, 4) Then ' Create distribution Key retVal = oMCObj.oLines.nAddLine() ' Create distribution fields 'sAccount = aInputData(166) + aInputData(201) + aInputData(203) + aInputData(200) + aInputData(202) 'retVal = oMCObj.oLines.oDistribution.nSetValue("AccountKey$", sAccount) '============================================================== ' Returns 0 - AccountKey is not a valid IO field '============================================================== retVal = oMCObj.oLines.oDistribution.nSetValue("Job$", aInputData(63)) retVal = oMCObj.oLines.oDistribution.nSetValue("CostCode$", aInputData(64)) retVal = oMCObj.oLines.oDistribution.nSetValue("CostType$", aInputData(65)) retVal = oMCObj.oLines.oDistribution.nSetValue("CommentText$", aInputData(62)) '============================================================== ' Returns 0 - CommentText is not a valid IO field '============================================================== retVal = oMCObj.oLines.oDistribution.nSetValue("DistributionAmt", CDbl(aInputData(168))) ' Close the distribution Line retVal = oMCObj.oLines.oDistribution.nWrite() '============================================================== ' Returns 0 - The record is not in an editable state '============================================================== retVal = oMCObj.oLines.oDistribution.nCommitRow() End If ' Close Invoice and Manual Check on the last Expense Report line If aDistLine(i, 3) = aDistLine(i, 4) Then ' Close Invoice Line retVal = oMCObj.oLines.nWrite() retVal = oMCObj.oLines.nCommitRow() ' Close Manual Check retVal = oMCObj.nWrite() End If Next Catch ex As Exception Log("BOI Scripting exception Error: " + ex.Message, 0) Return False End Try Log("BOI Closed", 1) Return True End Using
↧