Error printing SO using BOI

SOLVED

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

Parents Reply Children
  • +1 in reply to n0tgunshy2
    verified answer

    I think you maybe missing something like ReportSetting$

    Here should be the basics...

    ...

    ...
    Set oSO = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)

    retVal = oSO.nSelectReportSetting("STANDARD")
    retVal = oSO.nSetKeyValue("ModuleCode$", oSS.sModuleCode)
    retVal = oSO.nSetKeyValue("CompanyKey$", oSS.sCompanyKey)
    retVal = oSO.nSetKeyValue("ReportID$", "SO_SALESORDERPRINTING_UI")
    retVal = oSO.nSetKeyValue("ReportSetting$", "STANDARD")
    retVal = oSO.nSetKeyValue("RowKey$", "00001")
    retVal = oSO.nSetKey() ' retVal should be either 2 or 1

    retVal = oSO.nSetValue("SelectField$", "Order Number")
    retVal = oSO.nSetValue("SelectFieldValue$", "Order Number")
    retVal = oSO.nSetValue("KeyReference$", "<SalesOrderNo$>")
    retVal = oSO.nSetValue("Tag$", "TABLE=SO_SALESORDERHEADER;COLUMN=~SalesOrderNo$")
    retVal = oSO.nSetValue("Operand$", ">")
    retVal = oSO.nSetValue("Value1$", "")
    retVal = oSO.nWrite()
    ...

    This should put the setting to print all orders

    E

  • 0 in reply to jepritch

    I'll check all the points.  I do have the report setting in there, but maybe something else is amiss. I'll let you know how I do.  Thank you!