Printing From Shipping Data Entry

SOLVED

Sage 100 ERP 5.00.8.0

We are adding a button to our Shipping Data Entry that calls for a print of an invoice based on a Sales Order Number. I am consistently getting the following two errors:

1)  "The S/O0000000022SO_INVOICEPRINTING_UI         STANDARD            00001 is invalid." (If I use Quick Print)

2) "Data is not selected for report printing." (Regardless of Quick Print vs. Standard; Same with new and existing shipments; Does not matter if I PRINT or PREVIEW)

This script is being run on the server:

retVal = 0
OrderNo = ""

retVal = oBusObj.GetValue("SalesOrderNo", OrderNo)
retVal = oBusObj.Write()

retVal = oSession.SetModule("S/O")
retVal = oSession.SetDate("S/O", MAS_SCR_DTE)

Dim soPRINT
SET soPRINT = oSession.AsObject(oSession.GetObject("SO_InvoicePrinting_rpt"))

' Select the Template record.
retVal = soPrint.SetPartialRecord("Plain", oScript.Evaluate("CPL(""IOLIST TemplateDesc$"")") )
If Mid(OrderNo, 1, 1) = "R" Then
soPRINT.SelectReportSetting("RDD")
soPRINT.SetKeyValue "ReportSetting$", "RDD"
Else
soPRINT.SelectReportSetting("STANDARD")
soPRINT.SetKeyValue "ReportSetting$", "STANDARD"
End If

retVal = soPRINT.SetKeyValue("ModuleCode$", "S/O")
retVal = soPRINT.SetKeyValue("CompanyKey$", oSession.CompanyKey)

soPRINT.SetKeyValue "RowKey$", "1"
soPRINT.SetKey()
if retVal = 0 then
retVal = oSession.AsObject(oSession.UI).MessageBox("", soPRINT.LastErrorMsg & "1")
end if

' Set Selection criteria
retVal = soPRINT.SetValue("SelectField$", "Order Number")
retVal = soPRINT.SetValue("SelectFieldValue$", "Order Number")
retVal = soPRINT.SetValue("Tag$", "TABLE=SO_SALESORDERHEADER; COLUMN=SALESORDERNO$")
retVal = soPRINT.SetValue("Operand$", "=")
retVal = soPRINT.SetValue("Value1$", OrderNo)
retVal = soPRINT.QuickPrint = OrderNo 'Error #1 Here
'retVal = soPRINT.Write()
if retVal = 0 then
retVal = oSession.AsObject(oSession.UI).MessageBox("Write", soPRINT.LastErrorMsg)
end if

'retVal = soPRINT.ProcessReport("PRINT")
retVal = soPRINT.ProcessReport("PREVIEW") ' Error #2 Here
if retVal = 0 then
retVal = oSession.AsObject(oSession.UI).MessageBox("Print", soPRINT.LastErrorMsg)
end if

I have been through the BOI courses - though it has been a while, and I have looked through the examples, but I cannot find anything remotely like what I am trying to do. I am certain I have some extraneous and/or missing information, but I am not sure what. Any thoughts?

  • 0

    My gut reaction regarding #2  is that if you are clicking the button while sitting in shipping data entry, the invoice records have not been created yet.  SO_InvoicePrinting has to have an invoice created already,  it can't print it from data in the sales order files,  must be in the sales order invoice files.

    Have you verified via DFDM that data exists in SO_Invoice_Header?

    Does that make sense?

  • 0 in reply to TomTarget

    That does make sense (and that is where the button is) - and that was my first thought as well, but I don't think it could be the cause with what I have currently for two reasons:

    1) For brand new shipments, the invoice is created through oBusObj.Write(). I do not know if this is the best way, but it is working, and the invoices are written before the soPRINT object is even created.

    2) I get the same error for existing invoices/shipments that I verified before testing.

    Given these facts I think there is something wrong with my code other than that. For what its worth, I had it working with new shipments/invoices earlier, but it broke when I tried to make it work for existing ones as well, and I am not quite sure how to replicate my earlier setup.

  • 0 in reply to vbnet3d

    I had the thought to close out everything and start over. When I did so, the second error disappeared. I still have the first error - but it doesn't seem to actually prevent me from printing - so I may just suppress it for now.

    EDIT: Nevermind... it printed one time then began giving the second error again.

  • 0 in reply to vbnet3d

    OK.  Tried a test in demo data and it appears that the invoice data is created on the fly not after any kind of update.

    My next thought is that you appear to be trying to select the invoice based on the associated sales order number.   Looking at s/o invoice printing,  order number does not appear to be an available selection criteria.  Looks like defaults are shipping/invoice number and warehouse code?

    Are the retvals in these statements indicating errors?

    retVal = soPRINT.SetValue("SelectField$", "Order Number")
    retVal = soPRINT.SetValue("SelectFieldValue$", "Order Number")

  • 0 in reply to TomTarget

    No errors from either statement... This is being created from the Shipping Data Entry screen, so I have the feeling that it is somehow connecting the order number with this object. Indeed, I was able to print successfully one time (see previous post) using this method, but I will go ahead and try using the invoice number and see if anything changes and report on the result.

  • 0 in reply to vbnet3d

    Okay - I tried changing it to use invoice number instead, but there was no change, either positive or negative. I guess that rules out that option.

  • 0 in reply to vbnet3d

    Here's another thought: I just discovered that the orders that will no longer print are those that give the message "This order is currently being Shipped." It seems that this is making it impossible to print these orders. Is there any way that I can circumvent this?

  • 0 in reply to vbnet3d

    You have me intrigued, especially since I see some techniques that I could use elsewhere.  Going to put your script on my system and see what I can learn.

  • 0 in reply to TomTarget

    Sounds good to me.

  • 0 in reply to TomTarget

    Well,  I succeeded in actually printing the invoice by using the invoice number (I did get the form warning).   However,  I then got an error message indicating that the record is in use by another task which I think makes sense.

    Shipping data entry has a lock on that invoice record.   When the invoice printing is done via the script,  it is trying to set the flag indicating that the invoice has been printed.   Since the record is locked it cannot update it,  hence the record in use message.

    OK,  I'm going to follow my tag line at this point.   Since shipping data entry has the ability to print the invoice already,   why do you need to add this button for printing the invoice?