Printing Custom Sage 300 Report from Sage CRM

By | May 31, 2014

There may arise a scenario where one would need to print custom Sage 300 form from Sage CRM. To achieve this, we will need to tweak the standard Sage 300 report printing macro to enable report printing from Sage CRM.
In this blog we will discuss the technical guidelines for amending the additional code required for printing reports from Sage CRM order entry screen.
The New Stuff : Customize Sage CRM Order screens to promote Orders into Sage 300 ERP

Follow below code snippet:
Step1: Define the Variable in general declaration section:
<SNIP >
Dim temp As Boolean
Dim rpt As AccpacReport
Dim rptPrintSetup As AccpacPrintSetup
Dim session As AccpacSession
Dim newdblink As AccpacDBLink
Dim printrpt As AccpacPrintReport
</SNIP >
Step 2: Calling our Custom Report “OEPICK01.rpt”
<SNIP >
Set newdblink = adsOEORDH.DBLink
Set session = adsOEORDH.DBLink.session
Set rpt = session.ReportSelect(“OEPICK01[C:\Program Files\Sage\Sage 300 ERP\OE61A\ENG\OEPBPICK.RPT]”, ”      “, ”      “)
rpt.SetParam “SELECTBY”, “0”             ‘ Report parameter: 2
rpt.SetParam “SORTBY”, “0”               ‘ Report parameter: 3
rpt.SetParam “FROMSELECT”,   ‘ Report parameter: 4
rpt.SetParam “TOSELECT”,   ‘ Report parameter: 5
rpt.SetParam “FROMLOC”, ” ”              ‘ Report parameter: 6
rpt.SetParam “TOLOC”, “ZZZZZZ”           ‘ Report parameter: 7
rpt.SetParam “PRINTBY”, “0”              ‘ Report parameter: 14
rpt.SetParam “SERIALLOTNUMBERS”, “1”     ‘ Report parameter: 15
rpt.SetParam “PRINTKIT”, “1”             ‘ Report parameter: 11
rpt.SetParam “PRINTBOM”, “1”             ‘ Report parameter: 12
rpt.SetParam “REPRINT”, “1”              ‘ Report parameter: 8
rpt.SetParam “QTYDEC”, “0”               ‘ Report parameter: 9 – O/E Sales History:Detail,Sort by   Item Number
rpt.SetParam “COMPLETED”, “0”            ‘ Report parameter: 10
rpt.SetParam “SESHNDL”, “1454615”        ‘ Report parameter: 13
rpt.NumOfCopies = 1
rpt.Destination = PD_FILE
rpt.Format = PF_PDF
temp = rpt.PrintReport
Set printrpt = New AccpacPrintReport
printrpt.ReportViewer session, rpt.WebReportURL
</SNIP >
In the Order Entry screen we have implemented the same code on the click of the “Print forms” button as shown below.

Order Entry

Using the above code you can easily print the custom report from the Sage CRM.

Printing_Report

Also Read:
1. Update Bill-To-Address and Ship-To Address on OE Order Entry Screen
2. Populate Items on Order Entry Screen using Template Code
3. Template feature for Order Entry in Sage 300 ERP
4. Open Orders Inquiry for Sage 300 ERP Order Entry Screen
5. Generate BOM and Kitting items on the fly from Order Entry screen in Sage 300 ERP