Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Automatic SO printing

Automatic SO printing

Automatic SO printing

Greetings.  I'm new to this forum and novice in MAS 90 but learning quickly.  We are having a MAS integrated website developed, but they do not do programming outside the website.  My dilemma is we need an automatic way to print SOs that are generated from the website.  I figure this is possible.  However, I don't know how to do it.  Is there any information out there that explains how to do this?  Or a company that makes such an application?  Thanks for your help

RE: Automatic SO printing

Actually, I did exactly this.
And printing from BOI is *NOT* an easy task (I'm not even sure it can be done at all).

I ended up doing this:

At the time the person checks out on the website, a script is called that gathers up the information, creates a sales order in MAS90, and then calls a stand-alone print routine to print the orders to the warehouse.

There are NOT lots of code samples on the sage site for doing this; and any code examples that I have found there refer to 4.4, and not lower.

The solution is to work around MAS, not necessarily with it.  Your e-commerce site should be storing your sales in a table; really other than creating a sales order, just do everything else outside of MAS.  You'll save yourself hair.


Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg  http://parallel.tzo.com

RE: Automatic SO printing

Thanks all for the help.  Got in touch with someone local who was able to help.  Thanks all for the replies.  If anyone needs the code, just let me know on this post and I'll help out.  Thanks again.

RE: Automatic SO printing


What version of MAS90 are you running?  If you got it working on anything less than 4.4, I would LOVE to see the code.  To my knowledge, it's not possible in versions prior to 4.4 (contrary to the post above saying 4.2+)


Just my 2¢

"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."

--Greg  http://parallel.tzo.com

RE: Automatic SO printing

Hi Greg,

We are running 4.3.  And it is possible, err, well, it works for us at least.  Code is below.  Pay attention to some of the comments.  It does have to run as a user, and that user has to have ran the report at least once from within MAS.  We created a user that all it can do is run the report.  Hope others can find use for it too.  It's all about giving back to the community, right?  
Cheers, Ron.

Const HKEY_CURRENT_USER = &H80000001
Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
oReg.GetExpandedStringValue HKEY_CURRENT_USER,"Software\ODBC\ODBC.INI\SOTAMAS90","Directory",PathRoot
PathHome = PathRoot & "\Home"
Set oReg = Nothing
Set oScript = CreateObject ("ProvideX.Script")
Set oSS = oScript.NewObject("SY_Session")

sUser = "username"
sPassword = "userpass"
sCompanyCode = "companyid"

retVal = oSS.nSetUser(sUser,sPassword)
retVal = oSS.nSetCompany(sCompanyCode)

retVal = oSS.nSetModule("C/M")
retVal = oSS.nSetDate("C/M",oSS.sSystemDate)
retVal = oSS.nSetProgram(oSS.nLookupTask("CM_UDTMaint_UI"))
Set oUDT = oScript.NewObject("CM_UDTMaint_bus",oSS,"SO_UDT_SO_PRINTING_FORM_TYPES")

retVal = oSS.nSetModule("S/O")
retVal = oSS.nSetDate("S/O",oSS.sSystemDate)
retVal = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_UI"))
Set oSO = oScript.NewObject("SO_SalesOrder_bus", oSS)

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

retVal = oSO.nMoveFirst()
Do Until oSO.nEOF = 1
    printOrder = "N"

    ' soType - Sales Order Form Type Values
    ' "1" = ORM-D
    ' "2" = Must Ship Today - NOT USED
    ' "3" = Next Day Air
    ' "4" = Next Day Saturday
    ' "5" = Second Day Air
    ' "6" = Three Day select
    ' "7" = Backorder - NOT USED
    ' "8" = Regular
    soType = "8"
    soNum = ""
    retVal = oSO.nGetValue("SalesOrderNo$",soNum)
    if Left(soNum,1)="W" then
        printSO = ""
        retVal = oSO.nGetValue("PrintSalesOrders$",printSO)
        if printSO = "Y" then
            printOrder = "Y"
            shipVia = ""
            retVal = oSO.nGetValue("ShipVia$",shipVia)
            Select Case shipVia
                Case "UPS - NDA","UPS - NDA EARLY","UPS - NDA SAVER"
                    soType = "3"
                Case "UPS NEXTDAY SAT"
                    soType = "4"
                Case "UPS - BLUE","UPS - BLUE AM"
                    soType = "5"
                Case "UPS - THREE DAY"
                    soType = "6"
            End Select

            Set oItemSvc = oSO.oLines.oGetChildHandle("ItemCode")
            retVal = oSO.oLines.nMoveFirst()
            Do Until oSO.oLines.nEOF = 1
                itemCode = ""
                retVal = oSO.oLines.nGetValue("ItemCode$",itemCode)
                itemCat1 = ""
                retVal = oItemSvc.nGetValue("Category1$",itemCat1)
                if itemCat1 = "ORM-D" then
                    soType = "1"
                end if
                retVal = oSO.oLines.nMoveNext()

            ' Write record to UDT table
            retVal = oUDT.nSetKey(soNum)
            retVal = oUDT.nSetValue("UDF_TYPE$",soType)
            retVal = oUDT.nWrite()
        end if
    end if

    if printOrder = "Y" then
    For x = 1 to 2
        ' Terminate UI if you need to avoid screen prompts or
        ' do not terminate ui if you want to Print to preview
        retVal = 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("AUTOMATED")
        soPRINT.sQuickPrint = soNum
        'soPRINT.nNumberOfCopies = 2

        'retVal = soPRINT.nSelectReportSetting("AUTOMATED")
        'retVal = soPRINT.nSetKeyValue("ReportSetting$", "AUTOMATED")
        '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("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$", soNum)
        ' 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)
        ' Available Print destinations
        ' PRINT - print to printer
        ' DEFERRED - print to deferred
        ' PREVIEW - preview requires UI
        retVal = soPRINT.nProcessReport("PRINT")
        if retVal = 0 then
            msgbox soPRINT.sLastErrorMsg
        end if
        Dim Starting, Ending, Diff
        Starting = Now
        Ending = DateAdd("s",1,Starting)
            Diff = DateDiff("s",Now,Ending)
            if Diff <= 0 then Exit Do
            WScript.Sleep 1000

        retVal = oSO.nSetValue("PrintSalesOrders$","N")
        retVal = oSO.nWrite()
    end if

    retVal = oSO.nMoveNext()

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close