Hello,
I'm getting the error below indicating the module (S/O), company key (0000004), and the UI. I'm hoping there's something obviously amiss with the code below and that another set of eyes will spot the error.
And a huge thanks to David Speck for this bit of code!
The relevant bit of code is below. Please note that I've removed the error checking for legibility.
retval = oSS.nSetCompany(sCompany)
if retval = 0 then
msgbox "Error: " & oSS.sLastErrorMsg
end if
retval = oSS.nSetDate(sModule, sRunDate)
if retval = 0 then
msgbox "Error: " & oSS.sLastErrorMsg
end if
retval = oSS.nSetModule(sModule)
if retval = 0 then
msgbox "Error: " & oSS.sLastErrorMsg
end if
retVal = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrderPrinting_Ui"))
if retval = 0 then
msgbox "Error: " & oSS.sLastErrorMsg
end if
Set oSO = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)
'prep to print
scModuleCode = "": retval = oSO.nGetValue("cModuleCode$", scModuleCode)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
scCompanyKey = "": retval = oSO.nGetValue("cCompanyKey$", scCompanyKey)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
scReportID = "": retval = oSO.nGetValue("cReportID$", scReportID)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
sReportSetting = "AUTOPRINT"
nRowKey = 1
retval = oSO.nSelectReportSetting(sReportSetting)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetKeyValue("ModuleCode$", scModuleCode)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetKeyValue("CompanyKey$", scCompanyKey)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetKeyValue("ReportID$", scReportID)
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetKeyValue("ReportSetting$", UCase(sReportSetting))
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetKeyValue("RowKey$", Right("00000" & CStr(nRowKey), 5))
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetKey()
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetValue("SelectField$", "Order Number")
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetValue("SelectFieldValue$", "Order Number")
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetValue("KeyReference$", "<SALESORDERNO$>")
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetValue("Tag$", "TABLE=SO_SALESORDERHEADER; COLUMN=<SALESORDERNO$>")
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetValue("Operand$", "=")
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nSetValue("Value1$", "JATST")
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSO.nWrite()
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
On Error Resume Next
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
retval = oSS.nLogoffUser()
if retval = 0 then
msgbox "Error: " & oSO.sLastErrorMsg
end if
'clean up and close business objects
oSS.nCleanup()
oSS.DropObject()
Set oSS = Nothing