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
  • 0

    Hi 

    Just a couple of things to mention for the most part I think everything should work.

    • Rather than retrieve the values for cModuleCode$ and cCompanyKey$ from the object, you can use the session object properties.  oSS.sModuleCode & oSS.sCompanyKey, since these are the values that should be used.  Assuming that you have done the oSS.SetModule at the beginning to "S/O' etc.
    • The setting of the Tag field isn't quite correct, but I don't think this should affect anything.  s/b "TABLE:=SO_SALESORDERHEADER;COLUMN=~SalesOrderNo$"
    • Not sure where the error you are getting is happening, but depending on whether the user you are running under has actually run sales order printing before you will need to set the template for the orders.  This is done using oSO.nSetTemplateDesc("Plain") for example

    Hope this helps, but for the most part I think this should work.  

    Elliott

  • 0 in reply to jepritch

    That helped me get a more useful error.  I'm getting the below after changing the Tag field, as you suggested.  Thoughts?  And thank you for all of your nuggets of wisdom.  Very helpful.

    Also tried removing the tilde.. but that didn't help.  See below.  Does the tilde belong?

    Thank you!

Reply
  • 0 in reply to jepritch

    That helped me get a more useful error.  I'm getting the below after changing the Tag field, as you suggested.  Thoughts?  And thank you for all of your nuggets of wisdom.  Very helpful.

    Also tried removing the tilde.. but that didn't help.  See below.  Does the tilde belong?

    Thank you!

Children