I have looked at the threads on printing Sales Orders with the BOI, but am not having any success replicating what I found.
I am getting the error "Data not selected for report printing."
Can anyone look at this and tell me what might be happening? For context, I used the e-Business Web Services to set the PrintSalesOrder and PrintPickingSheet to 'Y' for each order before this step, and I have printed these reports at least once with the logged in user.
My current code is below:
Public Function Print(OrderNo As String, Optional type As String = "PRINT") As Boolean
retVal = oSS.nSetDate("S/O", AccountingDate)
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Accounting Date", oSS.sLastErrormsg))
End If
retVal = oSS.nSetModule("S/O")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Module", oSS.sLastErrormsg))
End If
oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrderPrinting_UI"))
Dim soPRINT As Object = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)
' Terminate UI if you need to avoid screen prompts or
' do not terminate ui if you want to Print to preview
type = type.ToUpper
If type <> "PRINT" And type <> "DEFERRED" Then
type = "PREVIEW"
Else
oSS.nTerminateUI()
End If
Try
retVal = soPRINT.nSetKeyValue("ModuleCode$", "S/O")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Module Code (soPRINT)", oSS.sLastErrormsg))
End If
retVal = soPRINT.nSetKeyValue("ReportID$", "SO_SalesOrderPrinting_UI")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Report ID (soPRINT)", oSS.sLastErrormsg))
End If
Catch ex As Exception
logger.Log(ex)
End Try
' Select the Template record.
' The record must exist for the user/company, which means
' the user you are logging in as must have printed/previewed
' the form at least once in MAS.
soPRINT.nSelectReportSetting("STANDARD")
soPRINT.nSetKeyValue("ReportSetting$", "STANDARD")
soPRINT.nSetKeyValue("RowKey$", "1")
retVal = soPRINT.nSetKey()
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Template", soPRINT.sLastErrormsg))
End If
' Set Selection criteria
retVal = soPRINT.nSetValue("SelectField$", "Order Number")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Tables", soPRINT.sLastErrormsg))
End If
retVal = soPRINT.nSetValue("SelectFieldValue$", "Order Number")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Tables", soPRINT.sLastErrormsg))
End If
retVal = soPRINT.nSetValue("Tag$", "TABLE=SO_SALESORDERHEADER; COLUMN=SALESORDERNO$")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Tables", soPRINT.sLastErrormsg))
End If
soPRINT.nSetValue("Operand$", "=")
' Available "Operand$" values
' All - "A"
' Begins with - "B"
' Ends with - "E"
' Contains - "C"
' Less than - "L"
' Greater than - "G"
' Range - "R"
' Equal to - "="
' Not Equal to - "N"
soPRINT.nSetValue("Value1$", OrderNo)
' set Value2$ for a range oPICK.nSetValue("Value2$", LastOrderNo)
' Write report setting to memory
retVal = soPRINT.nWrite()
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Write", soPRINT.sLastErrormsg))
End If
' Call ProcessReport to execute the printout
' ProcessReport(Destination)
retVal = soPRINT.nProcessReport(type) ' <<<<----- ERROR HERE
' Available Print destinations
' PRINT - print to printer
' DEFERRED - print to deferred
' PREVIEW - preview requires UI
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Process Report", soPRINT.sLastErrormsg))
End If
If retVal = 0 Then
Return False
Else
Return True
End If
End Function