Quantcast
Channel: Sage 100
Viewing all articles
Browse latest Browse all 36990

Forum Post: BOI Session is broken after Invoice print

$
0
0
Hello Forum, Is anybody also seeing this problem with Sage 100 Premium ERP 2013 (Version 5.00.5.0)? An invoice is created (or modified) successfully and the Invoice form is printed, after which the session object becomes corrupted and it is impossible to use it anymore. Our customers have to restart the software after they print an invoice so that the session is recreated. I am posting a script replicating the problem below, it has the spots marked where BOI calls fail. Any advice would be very much appreciated. Thanks, Alex V-Technologies Sub errchk(r, desc, oss, o)     if (r = 0) then         MsgBox(desc & ": " & o.sLastErrorMsg)         oss.nCleanup()         oss.DropObject()         Set oss = Nothing         WScript.Quit     end if end sub Const HKEY_CURRENT_USER = &H80000001 Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv") RetVal = oReg.GetExpandedStringValue(HKEY_CURRENT_USER,"Software\Sage Software\MAS 90 Business Desktop\Settings", _         "MAS90RootDirectory",PathRoot)   if retVal 0 then   oReg.GetExpandedStringValue HKEY_CURRENT_USER,"Software\ODBC\ODBC.INI\SOTAMAS90","Directory",PathRoot end if   PathHome = PathRoot & "\Home" Set oReg = Nothing Set oScript = CreateObject ("ProvideX.Script")     'oScript.TraceOn=true oScript.Init(Pathhome) Set oSS = oScript.NewObject("SY_Session") retVAL = oSS.nLogon() If retVAL = 0 Then   User = Trim(InputBox("Enter User Name", "", "ap"))   Password = Trim(InputBox("Enter Password", "", "ap"))   retVAL = oSS.nSetUser(User,Password)   errchk retVal, "SetUser", oss, oScript End If sCompany = oSS.sCompanyCode sCompany = Trim(InputBox("Enter Company Code","Company Code",sCompany)) retVAL = oSS.nSetCompany(sCompany) errchk retVal, "SetCompany", oSS, oSS sDate = oSS.sModuleDate if sDate = "" then   sDate = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2)       end if   retVAL = oSS.nSetDate("S/O",sDate) errchk retVal, "SetDate", oSS, oSS retVal = oSS.nSetModule("S/O") errchk retVal, "Set Module", oSS, oSS sDocumentKey = Trim(InputBox("Enter Sales Order Number","SalesOrder Number", "TEST")) oSEC = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_UI")) Set o = oScript.NewObject("SO_SalesOrder_bus", oSS) r = o.nFind(sDocumentKey) errchk r, "SalesOrder find", oSS, o oSEC = oSS.nSetProgram(oSS.nLookupTask("SO_Shipping_UI")) Set s = oScript.NewObject("SO_Shipping_Bus", oSS) fld = "CurrentInvoiceNo$" str = "" r = o.nGetValue(fld, str) errchk r, "GetValue CurrentInvoice Error", oSS, o sInvoiceNumber = str if (str "") then     MsgBox("Invoice found: " & sInvoiceNumber)     r = s.nFind(sInvoiceNumber)     errchk r, "Invoice Number Find failed", oSS, s          r = s.nSetKey(sInvoiceNumber)     errchk r, "Invoice Number SetKey failed", oSS, s else     r = s.nGetNextInvoiceNo(sInvoiceNumber)     errchk r, "GetNextInvoiceNumber failed", oSS, s          MsgBox("New Invoice Number " & sInvoiceNumber) end if r = s.nSetKey(sInvoiceNumber) errchk r, "Setting Key on invoice number", oSS, s r = s.nSetValue("SALESORDERNO$", sDocumentKey) errchk r, "Setting SalesOrderNumber for the invoice", oSS, s s.oLines.nMoveFirst do while (s.oLines.nEOF = 0)     sLineKey = ""     s.oLines.nGetValue "LINEKEY$", sLineKey     iQuantityOrdered = 0     s.oLines.nGetValue "QUANTITYORDERED", iQuantityOrdered     s.oLines.nSetValue "QUANTITYSHIPPED", iQuantityOrdered          s.oLines.nMoveNext loop r = s.oLines.nWrite errchk r, "Writing lines", oSS, s r = s.nSetValue("PrintInvoice$", "Y") errchk r, "Setting PrintInvoice field", oSS, s r = s.nWrite errchk r, "Invoice Write", oSS, s o.nFind("") 'retVAL = oSS.nSetProgram(oSS.nLookupTask("SO_PACKINGLISTPRINTING_UI")) retVAL = oSS.nSetProgram(oSS.nLookupTask("SO_INVOICEPRINTING_UI")) errchk retVal, "SetProgram", oSS, oSS 'Set oPrint = oScript.NewObject("SO_PACKINGLISTPRINTING_RPT",oSS) Set oPrint = oScript.NewObject("SO_INVOICEPRINTING_RPT",oSS) oSS.nTerminateUI sFormCode = "STANDARD" sFormCode = Trim(InputBox("Enter Form Code",,sFormCode)) 'sQuickPrint = Trim(InputBox("Try quick print (Y/N)?","","Y")) ' the following can be used to replace the setvalue, write below, but takes longer 'if sQuickPrint = "Y" then '  RetVAl = oPRINT.sQuickPrint = sDocumentKey '  RetVal = oPRINT.nProcessReport( "PREVIEW" )   '  If retVAL = 0 Then '    MsgBox("QuickPrint - nProcessReport Failed - " & oPrint.sLastErrorMsg & " - ErrorNum = " & oPrint.sLastErrorNum) '  Else '    MsgBox("QuickPrint - nProcessReport Success") '  end if 'end if retVal = oPrint.nSelectReportSetting( sFormCode ) errchk retVal, "Select Report Setting", oSS, oPrint        RetVal = oPRINT.nSetKeyValue( "ReportSetting$", sFormCode ) RetVal = oPRINT.nSetKeyValue( "RowKey$", "1" ) RetVal = oPRINT.nSetKey errchk retVal, "SetKey", oSS, oPrint ' Set Selection criteria RetVal = oPRINT.nSetValue( "SelectField$", "Invoice Number" ) errchk retVal, "SetValue - SelectField", oSS, oPrint RetVal = oPRINT.nSetValue( "SelectFieldValue$", "Invoice Number" ) errchk retVal, "SetValue - SelectFieldValue", oSS, oPrint RetVal = oPRINT.nSetValue( "Tag$", "TABLE=SO_INVOICEHEADER; COLUMN=INVOICENO$" ) errchk retVal, "SetValue - Table", oSS, oPrint RetVal = oPRINT.nSetValue( "Operand$", "=" ) errchk retVal, "SetValue - Operand", oSS, oPrint RetVal = oPRINT.nSetValue( "Value1$", sInvoiceNumber ) errchk retVal, "SetValue - Value1", oSS, oPrint MsgBox(sInvoiceNumber) 'Write report setting to memory RetVal = oPRINT.nWrite errchk retVal, "Write", oSS, oPrint   RetVal = oPRINT.nProcessReport( "PRINT" ) If retVAL = 0 Then     MsgBox("nProcessReport warning - " & oPrint.sLastErrorMsg & " - ErrorNum = " & oPrint.sLastErrorNum)     ''''''''''''''''''''''''''     ' Point of failure     '---------------------------     '---------------------------     'nProcessReport warning - The S/O0000000001SO_INVOICEPRINTING_UI     '---------------------------     'OK        '--------------------------- Else     MsgBox("nProcessReport Success") end if oSEC = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_UI")) '''''''''''''''''''''''''' ' Point of failure '--------------------------- 'Windows Script Host '--------------------------- 'Script:    C:\src\StarShip Client\Current Version\MAS\TestScripts\printInvoice.vbs 'Line:    176 'Char:    1 'Error:     Error: 0 in Method LOOKUPTASK 'Code:    80020009 'Source:     ProvideX Library '--------------------------- 'OK    '--------------------------- Set o = oScript.NewObject("SO_SalesOrder_bus", oSS) r = o.nFind(sDocumentKey) errchk r, "SalesOrder find", oSS, o on error resume next oSS.nCleanUp () if (Err.Number 0) then     MsgBox("Warning: Exception while oSS.nCleanUp call, ignoring and continuing: " & Err.Description)     ' Point of failure     '---------------------------     'Windows Script Host     '---------------------------     'Script:    C:\src\StarShip Client\Current Version\MAS\TestScripts\printInvoice.vbs     'Line:    166     'Char:    1     'Error:     Error: 0 in Method CLEANUP     'Code:    80020009     'Source:     ProvideX Library     '---------------------------     'OK        '--------------------------- end if oSS.DropObject() Set oSS = Nothing Set oScript = Nothing MsgBox("Success")

Viewing all articles
Browse latest Browse all 36990

Trending Articles