Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic SO printing 2

Status
Not open for further replies.

osiron

Technical User
May 10, 2011
3
US
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
 
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
 
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.
 
osiron:

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
 
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")
oScript.Init(PathHome)
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()
Loop

' 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("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$", 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)
Do
Diff = DateDiff("s",Now,Ending)
if Diff <= 0 then Exit Do
WScript.Sleep 1000
Loop

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

retVal = oSO.nMoveNext()
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top