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

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

  • 0 in reply to n0tgunshy2

    Oops, looks like I have a typo above for the tag field my apologies:

    TABLE=SO_SALESORDERHEADER;COLUMN=~SalesOrderNo$

    Try that...

  • 0 in reply to jepritch

    Gotcha.  Thank you.  I made the change, but I'm back to my original error.  Darn.  Any more ideas?

  • 0 in reply to n0tgunshy2

    Where do you get that error?

  • 0 in reply to jepritch

    Oops.  Meant to include that.  I had edited my script for legibility and that got lost in the edits.  The error is at this line:

    retval = oSO.nWrite()  

  • +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!