Sage 100

 View Only
Expand all | Collapse all

Has anyone ever received a setkey Err when writing

Jim Woodhead

Jim Woodhead04-13-2012 07:18

  • 1.  Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:16
      |   view attached
    Has anyone ever received a setkey Err when writing data to a table into MAS using BOI. We are using a BOI script to write to the APinvoicedata entry table. and this error is popping up.


  • 2.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:22
    AP Invoice Data Entry. Are you doing something like: strAPVendDiv = ""01"" strAPVend = ""AIRWAY"" strInvNum = ""00001"" retVal = oAPInvEntry.SetKey(""APDivisionNo$"",strAPVendDiv) retVal = oAPInvEntry.SetKey(""VendorNo$"",strAPVend) retVal = oAPInvEntry.SetKey(strInvNum) retVal = oAPInvEntry.SetKey()


  • 3.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:29
    Even if you're not using divisions you have to set APDivisionNo$.


  • 4.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:29
    The value in that message looks nothing like the keys for this table. Are you sure your variables have the expected values?


  • 5.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:33
    it works on the server but not the workstations.


  • 6.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:35
    here is my test script '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Initialization Routines all this code should be pretty much static to use the MAS90 session object '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' First create ProvideX com object Set oScript = CreateObject(""ProvideX.Script"") 'Get the ODBC path for the last accessed installation of MAS 90/200 Const HKEY_CURRENT_USER = &H80000001 Set oReg = GetObject(""winmgmts:\\.\root\default:StdRegProv"") oReg.GetExpandedStringValue HKEY_CURRENT_USER,""Software\ODBC\ODBC.INI\SOTAMAS90"",""Directory"",PathRoot PathHome = PathRoot & ""\Home"" PathHome = ""\\appserver2003\Flores\Sage\v440\MAS90\Home"" Set oReg = Nothing 'The Init method must be the first method called, and requires the path to the MAS90 home directory oScript.Init(PathHome) 'NewObject method creates a new MAS 90 Session object and returns the objects reference in oSS Set oSS = oScript.NewObject(""SY_Session"") 'Display value of one of the MAS 90 Session object's properties 'MsgBox(oSS.sPathSystem) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Routine to login to MAS90: If login fails asks for user and password also sets the company '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'The Logon method returns 1 if MAS90 Security is not enabled or if 'MAS90 has been configured to use Windows Security retVAL = oss.nlogon() 'If the Logon method fails then you must use the SetUser method to be allowed access If retVAL = 0 Then User = ""DOC"" Password = ""doclink123"" retVAL = oSS.nSetUser(User,Password) End If 'If SetUser fails, display LastErrorMsg for reason and quit If retVAL = 0 Then MsgBox(oSS.sLastErrorMsg) oSS.nCleanup()' Call Cleanup() before dropping the Session Object oSS.DropObject() Set oSS = Nothing WScript.Quit End If 'The CompanyCode property must be set before using any Business Objects 'Company must be configured to Allow External Access Company = Trim(InputBox(""Enter Company Code"",,oSS.sCompanyCode)) retVAL = oSS.nSetCompany(Company) 'If SetCompany fails, display LastErrorMsg for reason and quit If retVAL = 0 Then MsgBox(oSS.sLastErrorMsg) oSS.nCleanup()' Call Cleanup() before dropping the Session Object oSS.DropObject() Set oSS = Nothing WScript.Quit End If '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Routine to setup the Date and Module for A/P '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Get the Date to pass in with the MAS90 format strDayOfMonth = Day(Date()) strMonth = Month(Date()) strYear = Year(Date()) YYYYMMDD = strYear & strMonth & strDayOfMonth ' Get the Module to pass in to set the Date strModule = ""A/P"" 'The date format for the SetDate method must be YYYYMMDD retVAL = oSS.nSetDate(strModule, ""20120328"") ' Error handling for setting Date and module Error If retVAL = 0 Then MsgBox(""SetDate Failed - "" & oSS.sLastErrorMsg) Else retVAL = oSS.nSetModule(strModule) 'check retVAL in case module is not activated, etc. If retVAL = 0 Then MsgBox(""SetModule Failed - "" & oSS.sLastErrorMsg) Else ' The Session object is fully initialized, display some of the Session ' properties in a message box then quit 'MsgBox(""Current Company: "" & oSS.sCompanyName & vbCRLF & _ '""Company Data Path: "" & oSS.sPathCompany & vbCRLF & _ '""Current Module: "" & oSS.sModuleName & vbCRLF & _ '""Module Date: "" & oSS.sModuleDate) End If End If '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' retVal = oSS.nSetProgram(oSS.nLookupTask(""AP_Invoice_ui"")) Set oAPInvoiceEntry = oScript.NewObject(""AP_Invoice_bus"",oSS) Set oAPInvoiceLines = oAPInvoiceEntry.oLines If CBool(oAPInvoiceEntry.nBatchEnabled) Then ' Call SelectBatch() if Batches are enabled. ' Pass null BatchNo to create a new batch or ' pass an existing batch number to select it. BatchNo = ""DOC"" oAPInvoiceEntry.nSelectBatch(BatchNo) 'BatchNo = """" 'PrivateFlag = ""Y"" 'CommentText = ""This is a comment"" 'r = oAPInvoiceEntry.nSelectNewBatch(BatchNo, PrivateFlag, CommentText) End If retVal = oAPInvoiceEntry.nSetKeyValue(""BatchNo$"", BatchNo) retVal = oAPInvoiceEntry.nSetKeyValue(""APDivisionNo$"", ""00"") retVal = oAPInvoiceEntry.nSetKeyValue(""VendorNo$"", ""1371200"") retVal = oAPInvoiceEntry.nSetKeyValue(""InvoiceNo$"", ""alt134444"") retVal = oAPInvoiceEntry.nSetKeyValue(""APMU_234_DefaultCompanyCode$"", ""SFN"") retVal = oAPInvoiceEntry.nSetKey() If not(CBool(retVal)) Then MsgBox ""SetKey Err: "" & oAPInvoiceEntry.sLastErrorMsg retVal = oAPInvoiceEntry.nSetValue(""InvoiceAmt"", 1.00) retVal = oAPInvoiceLines.nAddLine() retVal = oAPInvoiceLines.nSetValue(""APMU_234_DefaultCompanyCode$"", ""HSN"") retVal = oAPInvoiceLines.nSetValue(""AccountKey$"", ""00000060A"") retVal = oAPInvoiceLines.nSetValue(""DistributionAmt"", 1.00) retVal = oAPInvoiceLines.nWrite() If not(CBool(retVal)) Then MsgBox ""Lines.Write Err: "" & oAPInvoiceLines.sLastErrorMsg 'write the header retVal = oAPInvoiceEntry.nWrite() If not(CBool(retVal)) Then MsgBox ""Header write Err: "" & oAPInvoiceEntry.sLastErrorMsg MsgBox ""done"" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Cleanup Routine for the MAS90 objects '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'The cleanup method must be called prior to dropping the session object because 'of the recursive dependencies of the session object in other objects it creates. oSS.nCleanup() 'The DropObject method destroys the Session object and releases any 'resourses in use by it E.g. memory, open files, etc. oSS.DropObject() oAPInvoiceEntry.DropObject() oAPInvoiceLines.DropObject() Set oSS = Nothing Set oScript = Nothing Set oAPInvoiceEntry = Nothing Set oAPInvoiceLines = Nothing '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


  • 7.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:40
    I'm no expert but it wouldn't have to do with the fact that ""alt"" in the invoice number is lowercase, would it?


  • 8.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:44
    It has to be something related to the MAS200 client because the script works fine on the server but not on the client workstation. I have reinstalled the workstation client already.


  • 9.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:52
    Private batch not accessible from that user?


  • 10.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 12:57
    Same user code works from server not from workstation


  • 11.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 13:02
    Are you having the script run from the server or the client?


  • 12.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-12-2012 13:25
    BOI scripts run at the workstation may run as MAS 90 and require that you run them with full access to the MAS 90 folder.


  • 13.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-13-2012 07:02
    Turns out it was a SQL mirroring issue. Usually on MAS200. You only need a SQLMIRRORiNG on the server, but as Dan said BOI runs as MAS90 so I needed to add the DSN to the workstations also. Thanks everyone for the help. Problem resolved!!


  • 14.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-13-2012 07:16
    Oh the complexities that enhancements from master developers create.


  • 15.  RE: Has anyone ever received a setkey Err when writing

    Posted 04-13-2012 07:18
    Yep!!