How to use BOI to print a Sales Order

We are completing a script to import sales orders into mas using VI and everything is working great, but I need to have the imported Sales Order print out at the end of the script. Does anyone know the BOI function to do this? My order number variable for the form is {ThisForm.fields("Order_Number").value}.

 

Thanks in advance!

 

Best regards,

Matt

  • Matt,

    This is a snip from an example we did which used BOI to create the sales order then print the pick sheet.

    Since you are using V/I to create the sales order you may need to add the Session calls to set the user, company, module, and date etc, which were done in the first part of this example.

     

     

    oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrderPrinting_UI"))
    soPRINT = oPVX.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
    oSS.nTerminateUI()

     

    ' 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")
    soPRINT.nSetKey()

     

    ' Set Selection criteria

    soPRINT.nSetValue("SelectField$", "Order Number")
    soPRINT.nSetValue("SelectFieldValue$", "Order Number")
    soPRINT.nSetValue("Tag$", "TABLE=SO_SALESORDERHEADER; COLUMN=SALESORDERNO$")

    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

    soPRINT.nWrite()

     

    ' Call ProcessReport to execute the printout
    ' ProcessReport(Destination)
    retVal = soPRINT.nProcessReport("DEFERRED")

     

    ' Available Print destinations
    ' PRINT - print to printer
    ' DEFERRED - print to deferred
    ' PREVIEW - preview requires UI

     

    I copied this from our picking sheet printing example, but I beleive settings are the same.

    As you can see, some of this is not exactly intuitive, such as the calls used to select the report setting and selection criteria, so I hope this helps.

  • I should mention that when new orders are created, a record is created in SO_SalesOrderPrint.M4T for each of the following sales order header columns if they are set to "Y":  PrintSalesOrders$ / PrintPickingSheets$.

     

    This "print" record is required for the above BOI logic to print an order or picksheet.

     

    So for the purposes of this thread, this should not be a problem since the orders being printed are the ones that were just created by the V/I job, assuming that PrintSalesOrders$ is set to "Y".

     

    Once the order is printed, the record in SO_SalesOrderPrint.M4T will be deleted and to print it again, the order has to be re-selected for printing via the 'Select' button on the Sales Order Printing screen in MAS.

     

    Currently, there is not a method to actually do the selecting in BOI - E.g. Clicking the Select button.

    Unless someone has found a work-around?

     

    But just to be sure, Matt, your orders should print fine since you just created them.

  • Hi Bret,

     

    Thanks so much for the help! I will try it and get back and post with the results.

     

    Best regards,

    Matt

  • I tried this example both for sales order printing and purchase order printing in the ABC company in version 4.40 and it is not working.  I get the message "Object doesn't support this property or method" on this line:

     

    Dim oscript, oss, retval, soPrint

    Set oScript = CreateObject ("ProvideX.Script")
    oScript.Init("c:\dma\sage\090-440\mas90\Home")
    Set oSS = oScript.NewObject("SY_SESSION")
    retVAL = oSS.nSetUser("test", "pwd")
    retVal = oSS.nSetCompany("ABC")
    retVal = oSS.nSetModule("S/O")
    retVal = oSS.nSetDate("S/O", "20100524")

    retval = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrderPrinting_UI"))
    soPrint = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)

     

    ?

     

    Dawn

  • I tried this on 4.30 (the sales order printing only) and it gave the same message.

     

    Dawn

  • Wow, crickets.  (or the sound of one hand clapping)

     

    Dawn

  • Dawn,

     

    Should that line read  

     

    SET soPrint = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)


    instead of

     

    soPrint = oScript.NewObject("SO_SalesOrderPrinting_rpt", oSS)

  • This worked for me:

     

    Dim oscript, oss, retval, soPrint

    OrderNo = "0000179"

    Set oscript = CreateObject("ProvideX.Script")
    oscript.Init ("C:\acct\MAS440\90\MAS90\Home")

    Set oss = oscript.NewObject("SY_SESSION")
    retval = oss.nSetUser("User", "password")
    retval = oss.nSetCompany("ABC")
    retval = oss.nSetModule("S/O")
    retval = oss.nSetDate("S/O", "20100524")

    retval = oss.nSetProgram(oss.nLookupTask("SO_SalesOrderPrinting_UI"))
    SET soPrint = 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
     oSS.nTerminateUI()

    ' 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.
    retval = soPrint.nSelectReportSetting("STANDARD")
    retval = soPrint.nSetKeyValue("ReportSetting$", "STANDARD")
    retval = soPrint.nSetKeyValue("RowKey$", "1")
    retval = soPrint.nSetKey()

    ' Set Selection criteria

    retval = soPrint.nSetValue("SelectField$", "Order Number")
    retval = soPrint.nSetValue("SelectFieldValue$", "Order Number")
    retval = soPrint.nSetValue("Tag$", "TABLE=SO_SALESORDERHEADER; COLUMN=SALESORDERNO$")


    retval = 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"

    retval = soPrint.nSetValue("Value1$", OrderNo)

    ' set Value2$ for a range oPICK.nSetValue("Value2$", LastOrderNo)

    ' Write report setting to memory

    retval = soPrint.nWrite()

    ' Call ProcessReport to execute the printout
    ' ProcessReport(Destination)
    retval = soPrint.nProcessReport("PREVIEW")

    ' Available Print destinations
    ' PRINT - print to printer
    ' DEFERRED - print to deferred
    ' PREVIEW - preview requires U

  • I copied Robert's script and I'm getting an error "this is an invalid date" after the line retval = soPrint.nProcessReport("PRINT").

     

    I suspect this may have to do with paperless office settings.  Are there methods or keys I need to set to determine the paperless office output?  I'd like to Print/PDF or Electronically Deliver.

     

    Thanks!

     

     

  • I believe I saw another post that referenced how to use Paperless Office in scripting.

    http://community.sagemas.com/t5/Business-Object-Interface/Print-Report-Object-to-Paperless/td-p/25427

     

    Dawn