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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''