Does anyone have a simplified example of printing a ‘standard’ report through code, in 10.2?
I have a ButtonClick customization that launched a report in E9, but the code conversion to E10 has rendered it non-functional. The ‘usings’ have all changed to Ice (appropriately, it seems), although a trace of the manual report execution reveal calls to Erp.Proxy.Rpt.
Anything identifying the proper using directives or references and perhaps the objects to be instantiated would be appreciated. Guessing just isn’t producing results for me.
I think it does Ken,
I’m hoping this isn’t strictly for SSRS, as we’ve opted to migrate to 10.2 (from 9) retaining our Crystal Reports. Redesigning reports is a project for another day.
Hmmm. I seem to be hitting the same brick wall, but from different angles. Can’t seem to get the correct objects instantiated, and I’m not aware of any documentation that lays out what is connected to what…
Yeah, I thought of that, Ken. I’ve tried adding all sorts of references and using statements to no avail. Given the few clear success stories online, it appears that printing programmatically has gotten a bit more difficult with E10. I do really appreciate your taking the time to help…
The way I did it for the Pick list report was to call via a new Context menu, a customization of SoPickListReport window, passing along the active sales order number. Launch the print then close the window.
@Hogardy, This WILL help, as the picker is next on the list. It’s interesting that the construct you’re using is different than what I’m attempting now with the SalesOrderAcknowledgement. This appears to be using some ‘other’ programming assemblage in order to create the report ‘object’? Is this the approach going forward?
@knash, you nailed it with the lowercase “s”. I’m elated and frustrated at the same time as everything that Epicor automatically inserts into the script capitalizes that first character! Even the name of the DLL is capitalized! There’s just no rhyme or reason.
Whew! Done venting. I will now work backwards to remove all the references and other test code I’ve littered the script with as I tried and errored.
Thanks again. I’ll get up to speed on this eventually, but I definitely needed the leg-up this time. On a tight deadline and have to get these reports running for go-live at the end of the month. I’m sure glad this forum is around!
Yep, once you know what you’re doing, it ain’t so bad
I wonder if that reference is documented anywhere - or did someone figure it out by trial and error.
In any case, I think the comments on this thread will be useful to others - it certainly was for me.
The code below gets the printer settings from a BAQ I wrote that links user names to printers in the system and then submits the BAQ report to the System Agent.
private void PrintBillsSSRS(){
if (numBOLNum.Value == null || Convert.ToInt32(numBOLNum.Value) <= 0) { return; }
// Make sure the boxes and weight are up-to-date before printing
UpdateBOLBoxesAndWeight(Convert.ToInt32(numBOLNum.Value));
// ** Place Event Handling Code Here **
string[] printerInfo = GetDefaultPrinter(((Session)HHConfirmShipForm.Session).UserID);
string printer = printerInfo[0];
string pageSettings = printerInfo[1];
string printerSettings = printerInfo[2];
//MessageBox.Show("Printer: " + printer);
string agentID = "";
try
{
Session otSession = (Session)oTrans.Session;
//Set the workstationID
string workStation = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID(otSession);
//Get or Set the AgentID
using (var aSA = new SysAgentAdapter(oTrans))
{
//oTrans.PushStatusText("Get System Agent Info", true);
aSA.BOConnect();
aSA.GetDefaultTaskAgentID(out agentID);
if (!string.IsNullOrEmpty(agentID)) { agentID = "SystemTaskAgent"; }
}
//MessageBox.Show(agentID + ", " + workStation);
for (int i =0; i < 3; i++)
{
var baqR = WCFServiceSupport.CreateImpl<Ice.Proxy.Rpt.BAQReportImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BAQReportSvcContract>.UriPath);
var dynamicReport = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.DynamicReportImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.DynamicReportSvcContract>.UriPath);
var rptMonitor = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.ReportMonitorImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.ReportMonitorSvcContract>.UriPath);
// GET DEFAULT REPORT PARAMETERS
var rptDs = dynamicReport.GetByID("PSG-tmsCustBOL");
var baqRptDS = baqR.GetNewBAQReportParam("PSG-tmsCustBOL");
baqRptDS.BAQReportParam[0].Option01 = numBOLNum.Value.ToString();
baqRptDS.BAQReportParam[0].AutoAction = "SSRSPRINT";
baqRptDS.BAQReportParam[0].WorkstationID = workStation;
baqRptDS.BAQReportParam[0].PrinterName = printer;
baqRptDS.BAQReportParam[0].RptPageSettings = pageSettings;
baqRptDS.BAQReportParam[0].RptPrinterSettings = printerSettings;
baqRptDS.BAQReportParam[0].SSRSRenderFormat = "PDF";
//baqRptDS.BAQReportParam[0].Character01 = numBOLNum.Value.ToString();
//baqRptDS.BAQReportParam[0].Character02=flag;
baqRptDS.BAQReportParam[0].BAQRptID = "PSG-tmsCustBOL";
baqRptDS.BAQReportParam[0].ReportID = "PSG-tmsCustBOL";
baqRptDS.BAQReportParam[0].Summary = false;
baqRptDS.BAQReportParam[0].ReportStyleNum = 1;
baqRptDS.BAQReportParam[0].BAQID = "PSG-tmsCustomerBOL";
baqRptDS.BAQReportParam[0].ReportTitle = "Bill of Lading";
//baqRptDS.BAQReportParam[0].TaskNote = guid.ToString();
rptDs.BAQRptOptionFld[0].FieldValue = numBOLNum.Value.ToString();
rptDs.AcceptChanges();
StringWriter writer = new StringWriter();
rptDs.WriteXml(writer);
baqRptDS.BAQReportParam[0].Filter1 = writer.ToString();
//baqR.RunDirect(baqRptDS);
baqR.SubmitToAgent(baqRptDS, agentID, 0, 0, "Erp.UIRpt.BAQReport");
//MessageBox.Show("Report Submitted to System Agent for processing.");
}
}
catch (Exception ex)
{
MessageBox.Show("An error occured trying to print report." + ex.Message);
}
}
// Gets the printer for the current user.
private string[] GetDefaultPrinter(string currentUser)
{
string[] output = new string[3];
string printer = string.Empty;
string pageSet = "Color=True,Landscape=False,PaperSize=[Kind=\"Letter\" PaperName=\"Letter\" Height=1100 Width=850],PaperSource=[SourceName=\"FormSource\" Kind=\"FormSource\"],PrinterResolution=[Kind=\"Custom\" X=600 Y=600]";
string printSet = "PrinterName=\"" + printer + "\",Copies=1,Collate=False,Duplex=Default,FromPage=1,ToPage=0";
// Special cases for PLT02 and PLT03, because we can only add 2 printers to each workstationID
if (currentUser.ToUpper().Equals("HH10") || currentUser.ToUpper().Equals("HH04"))
{
// PLT02. Default to PLT2-PR-02
printer = "\\\\PSG-SRV-02\\PLT2-PR-02";
printSet = "PrinterName=\"" + printer + "\",Copies=1,Collate=False,Duplex=Default,FromPage=1,ToPage=0";
output[0] = printer;
output[1] = pageSet;
output[2] = printSet;
return output;
} else if (currentUser.ToUpper().Equals("HH08") || currentUser.ToUpper().Equals("HH05") || currentUser.ToUpper().Equals("HH06"))
{
// PLT03. Default to PLT3-PR-06
printer = "\\\\PSG-SRV-02\\PLT3-PR-06";
printSet = "PrinterName=\"" + printer + "\",Copies=1,Collate=False,Duplex=Default,FromPage=1,ToPage=0";
output[0] = printer;
output[1] = pageSet;
output[2] = printSet;
return output;
}
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("PSG_tmsPrinterForUser");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("UserID", currentUser, "nvarchar",false,Guid.NewGuid(), "A");
dqa.ExecuteByID("PSG_tmsPrinterForUser", qeds);
foreach (DataRow row in dqa.QueryResults.Tables["Results"].Rows)
{
// Only use printers that aren't label printers (do not contain "LBL")
if (!row["SysPrinter_PrinterID"].ToString().ToUpper().Contains("LBL"))
{
printer = row["SysPrinter_NetworkPath"].ToString();
pageSet = row["Calculated_PageSettings"].ToString();
printSet = row["Calculated_PrinterSettings"].ToString();
}
}
output[0] = printer;
output[1] = pageSet;
output[2] = printSet;
return output;
}