Print BAQReport with modified dataset [SOLVED]

There is no need to create a file, you can pass the data-set directly to Crystal Reports. Run the BAQ using the Dynamic Query business objects, the results will be a data-set that you can pass directly to Crystal reports. Before sending it to Crystal you can manipulate the data-set as needed.

The best way to run BAQs in Epicor 9 is to build them with parameters so that you don't have to build where statements. There is an example at the end of this message.

Once you run the BAQ and have the data-set it will be a plain vanilla exercise to send it to Crystal. Many examples on the Net showing how.

Jim Kinneman
Encompass Solutions, Inc

// this example shows how to populate a grid but the routine to call it would be the same for crystal except you would pass the data-set to crystal instead of to a grid.

Many of us use BAQs in our embedded customizations, typically you add where clauses to get the results you are looking for. Parameters can be defined for a BAQ and used to filter the data. Using the ExecuteByIDParametrized method you can pass the parameters and execute the BAQ in one step, greatly reducing the amount of coding. In the example below the BAQ has a parameter called "PartSearch" which limits the results to a single part number. Multiple parameters can be combined on the criteria for the BAQ and usually eliminates or at least reduces the need for where clauses.

private Epicor.Mfg.BO.QueryExecutionDataSet dsExecute;

string inputFilter; // holds the part number we are looking for

private void LoadGrid()
{
dsExecute.Clear();
String resultFieldList = String.Empty;
int topNRecords = 0;
Boolean hasMoreRecords;
try
{
dsExecute.Tables["ExecutionParameter"].Rows.Add("PartSearch",inputFilter,"Character",false,"","A",null);
// Declare and create an instance of the Adapter.
DynamicQueryAdapter adQuery = new DynamicQueryAdapter(this.oTrans);
adQuery.BOConnect();
// Declare and Initialize Variables
string pcQueryID = ("JAK-MyBAQ");
// Call Adapter method
adQuery.ExecuteByIDParametrized(pcQueryID,dsExecute,resultFieldList,topNRecords,out hasMoreRecords );
grdSupplierParts.DataSource = adQuery.QueryResults.Tables["Results"];
// set headings
foreach(DataRow dr in adQuery.QueryResults.Tables["DisplayFields"].Rows)
{
grdSupplierParts.DisplayLayout.Bands[0].Columns[dr["FieldName"].ToString()].Header.Caption = dr["FieldLabel"].ToString();
}
// Cleanup Adapter Reference
adQuery.Dispose();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
Hi, I need to print data from EpiUltraGrid which dataset is taken from BAQReport and one of the columns is modified manualy. The report should have this manual input values (which exists in BAQ as 0). When I put BAQReportResult table to ReportDataSet I get the error:

Progress.Open4GL.Exceptions.Open4GLException: Input result set error: System.IndexOutOfRangeException: Index was outside the bounds of the array. There might be a mismatch between an input result set and the schema in the proxy. (7228) (7176)

If I don't add Result table to dataset, I get the correct report with my own parameters (but of course without data from EpiUltraGrid). Is any possibility to fix it? Or maybe is another way to achieve my needs?

The code (Epicor 9.05.701):

Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()

dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")

dsReport.Tables("BAQReportParam").Rows(0)("BAQID") = "TC-BM_MaterialRequest"
dsReport.Tables("BAQReportParam").Rows(0)("ReportTitle") = "Zapotrzebowanie materialowe"
dsReport.Tables("BAQReportParam").Rows(0)("DCDUserID") = JobTrackerForm.Session.UserID
dsReport.Tables("BAQReportParam").Rows(0)("BAQRptID") = "TC_BM_MtlReq"
'dsReport.Tables("BAQReportParam").Rows(0)("AutoAction") = "Preview"
dsReport.Tables("BAQReportParam").Rows(0)("AgentID") = "SystemTaskAgent"
dsReport.Tables("BAQReportParam").Rows(0)("WorkstationID") = Environment.MachineName
dsReport.Tables("BAQReportParam").Rows(0)("DateFormat") = "mm/dd/yyyy"
dsReport.Tables("BAQReportParam").Rows(0)("NumericFormat") = ",."

Dim tabResult As DataTable = new DataTable("BAQReportResult")
tabResult = Me.epiUltraGridJobs.DataSource.Clone()
dsReport.Tables.Add(tabResult)
For Each t As DataTable In dsReport.Tables
If t.TableName = "Results" Then
t.TableName = "BAQReportResult"
End If
Next

For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
dsReport.Tables("BAQReportResult").ImportRow(row)
Next

report.SubmitToAgent(dsReport,"SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.BAQReport;TC_BM_MtlReq")

End Sub
1 Like
You are missing a lot of semi-colons... and not sure what "dim" means :)

You can't pass results to the report that you have previously retrieved if I follow what you are doing.

The call to submittoagent is only going to process parameters that will be used to look things up, at the time you submit to agent no data has been retrieved yet. Once the item has been submitted to agent it will retrieve the items for the report.

An alternative is to run the BAQ to get the data, you then can build your own crystal report using the BAQ results as the data-source. Examples of building a Crystal report via code has been listed in this group before and Googling it will give a number of examples of building one via code.

Jim Kinneman
Encompass Solutions, Inc.

--- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@...> wrote:
>
> Hi, I need to print data from EpiUltraGrid which dataset is taken from BAQReport and one of the columns is modified manualy. The report should have this manual input values (which exists in BAQ as 0). When I put BAQReportResult table to ReportDataSet I get the error:
>
> Progress.Open4GL.Exceptions.Open4GLException: Input result set error: System.IndexOutOfRangeException: Index was outside the bounds of the array. There might be a mismatch between an input result set and the schema in the proxy. (7228) (7176)
>
> If I don't add Result table to dataset, I get the correct report with my own parameters (but of course without data from EpiUltraGrid). Is any possibility to fix it? Or maybe is another way to achieve my needs?
>
> The code (Epicor 9.05.701):
>
> Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
> Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
> Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
>
> dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")
>
> dsReport.Tables("BAQReportParam").Rows(0)("BAQID") = "TC-BM_MaterialRequest"
> dsReport.Tables("BAQReportParam").Rows(0)("ReportTitle") = "Zapotrzebowanie materialowe"
> dsReport.Tables("BAQReportParam").Rows(0)("DCDUserID") = JobTrackerForm.Session.UserID
> dsReport.Tables("BAQReportParam").Rows(0)("BAQRptID") = "TC_BM_MtlReq"
> 'dsReport.Tables("BAQReportParam").Rows(0)("AutoAction") = "Preview"
> dsReport.Tables("BAQReportParam").Rows(0)("AgentID") = "SystemTaskAgent"
> dsReport.Tables("BAQReportParam").Rows(0)("WorkstationID") = Environment.MachineName
> dsReport.Tables("BAQReportParam").Rows(0)("DateFormat") = "mm/dd/yyyy"
> dsReport.Tables("BAQReportParam").Rows(0)("NumericFormat") = ",."
>
> Dim tabResult As DataTable = new DataTable("BAQReportResult")
> tabResult = Me.epiUltraGridJobs.DataSource.Clone()
> dsReport.Tables.Add(tabResult)
> For Each t As DataTable In dsReport.Tables
> If t.TableName = "Results" Then
> t.TableName = "BAQReportResult"
> End If
> Next
>
> For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
> dsReport.Tables("BAQReportResult").ImportRow(row)
> Next
>
> report.SubmitToAgent(dsReport,"SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.BAQReport;TC_BM_MtlReq")
>
> End Sub
>
Thanks for your response and explanation how agent works with reports.

No need semicolons - it's VisualBasic. Dim means definition of variable.

Your solution is probably the same as next mine. I've found it also in the group so I will try to go this way...

--- In vantage@yahoogroups.com, "jckinneman" <jckinneman@...> wrote:
>
> You are missing a lot of semi-colons... and not sure what "dim" means :)
>
> You can't pass results to the report that you have previously retrieved if I follow what you are doing.
>
> The call to submittoagent is only going to process parameters that will be used to look things up, at the time you submit to agent no data has been retrieved yet. Once the item has been submitted to agent it will retrieve the items for the report.
>
> An alternative is to run the BAQ to get the data, you then can build your own crystal report using the BAQ results as the data-source. Examples of building a Crystal report via code has been listed in this group before and Googling it will give a number of examples of building one via code.
>
> Jim Kinneman
> Encompass Solutions, Inc.
>
> --- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@> wrote:
> >
> > Hi, I need to print data from EpiUltraGrid which dataset is taken from BAQReport and one of the columns is modified manualy. The report should have this manual input values (which exists in BAQ as 0). When I put BAQReportResult table to ReportDataSet I get the error:
> >
> > Progress.Open4GL.Exceptions.Open4GLException: Input result set error: System.IndexOutOfRangeException: Index was outside the bounds of the array. There might be a mismatch between an input result set and the schema in the proxy. (7228) (7176)
> >
> > If I don't add Result table to dataset, I get the correct report with my own parameters (but of course without data from EpiUltraGrid). Is any possibility to fix it? Or maybe is another way to achieve my needs?
> >
> > The code (Epicor 9.05.701):
> >
> > Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
> > Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
> > Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
> >
> > dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")
> >
> > dsReport.Tables("BAQReportParam").Rows(0)("BAQID") = "TC-BM_MaterialRequest"
> > dsReport.Tables("BAQReportParam").Rows(0)("ReportTitle") = "Zapotrzebowanie materialowe"
> > dsReport.Tables("BAQReportParam").Rows(0)("DCDUserID") = JobTrackerForm.Session.UserID
> > dsReport.Tables("BAQReportParam").Rows(0)("BAQRptID") = "TC_BM_MtlReq"
> > 'dsReport.Tables("BAQReportParam").Rows(0)("AutoAction") = "Preview"
> > dsReport.Tables("BAQReportParam").Rows(0)("AgentID") = "SystemTaskAgent"
> > dsReport.Tables("BAQReportParam").Rows(0)("WorkstationID") = Environment.MachineName
> > dsReport.Tables("BAQReportParam").Rows(0)("DateFormat") = "mm/dd/yyyy"
> > dsReport.Tables("BAQReportParam").Rows(0)("NumericFormat") = ",."
> >
> > Dim tabResult As DataTable = new DataTable("BAQReportResult")
> > tabResult = Me.epiUltraGridJobs.DataSource.Clone()
> > dsReport.Tables.Add(tabResult)
> > For Each t As DataTable In dsReport.Tables
> > If t.TableName = "Results" Then
> > t.TableName = "BAQReportResult"
> > End If
> > Next
> >
> > For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
> > dsReport.Tables("BAQReportResult").ImportRow(row)
> > Next
> >
> > report.SubmitToAgent(dsReport,"SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.BAQReport;TC_BM_MtlReq")
> >
> > End Sub
> >
>
Guess I'll leave out the attempts at humor.... :)

--- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@...> wrote:
>
>
>
> Thanks for your response and explanation how agent works with reports.
>
> No need semicolons - it's VisualBasic. Dim means definition of variable.
>
> Your solution is probably the same as next mine. I've found it also in the group so I will try to go this way...
>
> --- In vantage@yahoogroups.com, "jckinneman" <jckinneman@> wrote:
> >
> > You are missing a lot of semi-colons... and not sure what "dim" means :)
> >
> > You can't pass results to the report that you have previously retrieved if I follow what you are doing.
> >
> > The call to submittoagent is only going to process parameters that will be used to look things up, at the time you submit to agent no data has been retrieved yet. Once the item has been submitted to agent it will retrieve the items for the report.
> >
> > An alternative is to run the BAQ to get the data, you then can build your own crystal report using the BAQ results as the data-source. Examples of building a Crystal report via code has been listed in this group before and Googling it will give a number of examples of building one via code.
> >
> > Jim Kinneman
> > Encompass Solutions, Inc.
> >
> > --- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@> wrote:
> > >
> > > Hi, I need to print data from EpiUltraGrid which dataset is taken from BAQReport and one of the columns is modified manualy. The report should have this manual input values (which exists in BAQ as 0). When I put BAQReportResult table to ReportDataSet I get the error:
> > >
> > > Progress.Open4GL.Exceptions.Open4GLException: Input result set error: System.IndexOutOfRangeException: Index was outside the bounds of the array. There might be a mismatch between an input result set and the schema in the proxy. (7228) (7176)
> > >
> > > If I don't add Result table to dataset, I get the correct report with my own parameters (but of course without data from EpiUltraGrid). Is any possibility to fix it? Or maybe is another way to achieve my needs?
> > >
> > > The code (Epicor 9.05.701):
> > >
> > > Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
> > > Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
> > > Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
> > >
> > > dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")
> > >
> > > dsReport.Tables("BAQReportParam").Rows(0)("BAQID") = "TC-BM_MaterialRequest"
> > > dsReport.Tables("BAQReportParam").Rows(0)("ReportTitle") = "Zapotrzebowanie materialowe"
> > > dsReport.Tables("BAQReportParam").Rows(0)("DCDUserID") = JobTrackerForm.Session.UserID
> > > dsReport.Tables("BAQReportParam").Rows(0)("BAQRptID") = "TC_BM_MtlReq"
> > > 'dsReport.Tables("BAQReportParam").Rows(0)("AutoAction") = "Preview"
> > > dsReport.Tables("BAQReportParam").Rows(0)("AgentID") = "SystemTaskAgent"
> > > dsReport.Tables("BAQReportParam").Rows(0)("WorkstationID") = Environment.MachineName
> > > dsReport.Tables("BAQReportParam").Rows(0)("DateFormat") = "mm/dd/yyyy"
> > > dsReport.Tables("BAQReportParam").Rows(0)("NumericFormat") = ",."
> > >
> > > Dim tabResult As DataTable = new DataTable("BAQReportResult")
> > > tabResult = Me.epiUltraGridJobs.DataSource.Clone()
> > > dsReport.Tables.Add(tabResult)
> > > For Each t As DataTable In dsReport.Tables
> > > If t.TableName = "Results" Then
> > > t.TableName = "BAQReportResult"
> > > End If
> > > Next
> > >
> > > For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
> > > dsReport.Tables("BAQReportResult").ImportRow(row)
> > > Next
> > >
> > > report.SubmitToAgent(dsReport,"SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.BAQReport;TC_BM_MtlReq")
> > >
> > > End Sub
> > >
> >
>
Hi, for the future my solution:

First you have to prepare two things:
1. Make the empty .rpt from BAQReportDesigner
2. Make the proper .xml file and put dataset to the .rpt in CR

Next the code below will work:

Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()

dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")

Dim tabResult As DataTable = new DataTable("BAQReportResult")
tabResult = Me.epiUltraGridJobs.DataSource.Clone()
tabResult.TableName = "BAQReportResult"
dsReport.Tables.Add(tabResult)

For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
dsReport.Tables("BAQReportResult").ImportRow(row)
Next

Dim datafile As String = ""
Dim reportfile As String = "\\erptest1-lc\Epicor905\Server\reports\CustomReports\TC_BM_MtlReq.rpt"
Dim tmprfile As String = ""

datafile = "\\erptest1-lc\EpicorData\Reports\" & JobTrackerForm.Session.UserID & "\MaterialRequest_" & DateTime.Now.ToString("yyyyMMddHHmmss") & ".xml"
tmprfile = "\\erptest1-lc\EpicorData\Reports\" & JobTrackerForm.Session.UserID & "\TC_BM_MtlReq.rpt"

'CR viewer erase the report and datafile so you need to copy at least the rpt file to view it and not loose the project
My.Computer.FileSystem.CopyFile(reportfile,tmprfile,FileIO.UIOption.AllDialogs,FileIO.UICancelOption.DoNothing)

'If you need to catch the .xml file to put it to the .rpt just do it when CR viewer is open

dsReport.WriteXml(datafile)

Dim crviewer As Epicor.Mfg.Lib.Report.EpiCrystalViewer = New Epicor.Mfg.Lib.Report.EpiCrystalViewer(tmprfile,datafile,"Some title")
crviewer.Show()

End Sub

--- In vantage@yahoogroups.com, "jckinneman" <jckinneman@...> wrote:
>
> Guess I'll leave out the attempts at humor.... :)
>
> --- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@> wrote:
> >
> >
> >
> > Thanks for your response and explanation how agent works with reports.
> >
> > No need semicolons - it's VisualBasic. Dim means definition of variable.
> >
> > Your solution is probably the same as next mine. I've found it also in the group so I will try to go this way...
> >
> > --- In vantage@yahoogroups.com, "jckinneman" <jckinneman@> wrote:
> > >
> > > You are missing a lot of semi-colons... and not sure what "dim" means :)
> > >
> > > You can't pass results to the report that you have previously retrieved if I follow what you are doing.
> > >
> > > The call to submittoagent is only going to process parameters that will be used to look things up, at the time you submit to agent no data has been retrieved yet. Once the item has been submitted to agent it will retrieve the items for the report.
> > >
> > > An alternative is to run the BAQ to get the data, you then can build your own crystal report using the BAQ results as the data-source. Examples of building a Crystal report via code has been listed in this group before and Googling it will give a number of examples of building one via code.
> > >
> > > Jim Kinneman
> > > Encompass Solutions, Inc.
> > >
> > > --- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@> wrote:
> > > >
> > > > Hi, I need to print data from EpiUltraGrid which dataset is taken from BAQReport and one of the columns is modified manualy. The report should have this manual input values (which exists in BAQ as 0). When I put BAQReportResult table to ReportDataSet I get the error:
> > > >
> > > > Progress.Open4GL.Exceptions.Open4GLException: Input result set error: System.IndexOutOfRangeException: Index was outside the bounds of the array. There might be a mismatch between an input result set and the schema in the proxy. (7228) (7176)
> > > >
> > > > If I don't add Result table to dataset, I get the correct report with my own parameters (but of course without data from EpiUltraGrid). Is any possibility to fix it? Or maybe is another way to achieve my needs?
> > > >
> > > > The code (Epicor 9.05.701):
> > > >
> > > > Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
> > > > Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
> > > > Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
> > > >
> > > > dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")
> > > >
> > > > dsReport.Tables("BAQReportParam").Rows(0)("BAQID") = "TC-BM_MaterialRequest"
> > > > dsReport.Tables("BAQReportParam").Rows(0)("ReportTitle") = "Zapotrzebowanie materialowe"
> > > > dsReport.Tables("BAQReportParam").Rows(0)("DCDUserID") = JobTrackerForm.Session.UserID
> > > > dsReport.Tables("BAQReportParam").Rows(0)("BAQRptID") = "TC_BM_MtlReq"
> > > > 'dsReport.Tables("BAQReportParam").Rows(0)("AutoAction") = "Preview"
> > > > dsReport.Tables("BAQReportParam").Rows(0)("AgentID") = "SystemTaskAgent"
> > > > dsReport.Tables("BAQReportParam").Rows(0)("WorkstationID") = Environment.MachineName
> > > > dsReport.Tables("BAQReportParam").Rows(0)("DateFormat") = "mm/dd/yyyy"
> > > > dsReport.Tables("BAQReportParam").Rows(0)("NumericFormat") = ",."
> > > >
> > > > Dim tabResult As DataTable = new DataTable("BAQReportResult")
> > > > tabResult = Me.epiUltraGridJobs.DataSource.Clone()
> > > > dsReport.Tables.Add(tabResult)
> > > > For Each t As DataTable In dsReport.Tables
> > > > If t.TableName = "Results" Then
> > > > t.TableName = "BAQReportResult"
> > > > End If
> > > > Next
> > > >
> > > > For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
> > > > dsReport.Tables("BAQReportResult").ImportRow(row)
> > > > Next
> > > >
> > > > report.SubmitToAgent(dsReport,"SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.BAQReport;TC_BM_MtlReq")
> > > >
> > > > End Sub
> > > >
> > >
> >
>
I saw your code on here and was intrigued. I tried using your code but I had problems in three areas. Any help you could give me on this will be much appreciated.

First problem was on this line:
tabResult = Me.epiUltraGridJobs.DataSource.Clone()
It was trying to clone a dataset to a table. I changed it to this:

tabResult = epiUltraGridJobs.DataSource.Tables("Results").Clone()

Second problem was in this area:

For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
dsReport.Tables("BAQReportResult").ImportRow(row)
Next

Again it was trying to use a dataset row for a table row. I changed it to this:

For Each row As DataRow In EpiUltraGridJobs.DataSource.Tables("Results").Rows
dsReport.Tables("BAQReportResult").ImportRow(row)
Next


This made everything seem to work. But after the Crystal Reports Viewer pops up, I get a database login screen. The parameters on the login screen are:

ServerName: ReportDataSet
Database:
Login ID:
PassWord:
Use Integrated Security: false

The two files were created in the Reports/User folders. They seem to be correct and contain the data from the BAQ.

Here is the code I was using:

Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(SubConShipForm.Session.ConnectionPool)
Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
dsReport = report.GetNewBAQReportParam("SubPackSlip")
Dim tabResult As DataTable = new DataTable("BAQReportResult")
tabResult = epiUltraGridC1.DataSource.Tables("Results").Clone()
tabResult.TableName = "BAQReportResult"
dsReport.Tables.Add(tabResult)
For Each row As DataRow In EpiUltraGridC1.DataSource.Tables("Results").Rows
dsReport.Tables("BAQReportResult").ImportRow(row)
Next
Dim datafile As String = ""
Dim reportfile As String = "\\epicor\Epicor905\Server\reports\CustomReports\SubPackSlip.rpt"
Dim tmprfile As String = ""
datafile = "\\epicor\EpicorData\Reports\" & SubConShipForm.Session.UserID &
"\SubPackSlip_" & DateTime.Now.ToString("yyyyMMddHHmmss") & ".xml"
tmprfile = "\\epicor\EpicorData\Reports\" & SubConShipForm.Session.UserID & "\SubPackSlip.rpt"
'CR viewer erase the report and datafile so you need to copy at least the
' rpt file to view it and not lose the project
My.Computer.FileSystem.CopyFile(reportfile,tmprfile,FileIO.UIOption.AllDialogs,FileIO.UICancelOption.DoNothing)
'If you need to catch the .xml file to put it to the .rpt just do it when CR viewer is open
dsReport.WriteXml(datafile)
Dim crviewer As Epicor.Mfg.Lib.Report.EpiCrystalViewer = New Epicor.Mfg.Lib.Report.EpiCrystalViewer(tmprfile,datafile,"Some title")
crviewer.Show()

Any ideas how to fix this?

Thanks,
Jeff Sanders

--- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@...> wrote:
>
>
>
> Hi, for the future my solution:
>
> First you have to prepare two things:
> 1. Make the empty .rpt from BAQReportDesigner
> 2. Make the proper .xml file and put dataset to the .rpt in CR
>
> Next the code below will work:
>
> Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
> Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
> Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
>
> dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")
>
> Dim tabResult As DataTable = new DataTable("BAQReportResult")
> tabResult = Me.epiUltraGridJobs.DataSource.Clone()
> tabResult.TableName = "BAQReportResult"
> dsReport.Tables.Add(tabResult)
>
> For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
> dsReport.Tables("BAQReportResult").ImportRow(row)
> Next
>
> Dim datafile As String = ""
> Dim reportfile As String = "\\erptest1-lc\Epicor905\Server\reports\CustomReports\TC_BM_MtlReq.rpt"
> Dim tmprfile As String = ""
>
> datafile = "\\erptest1-lc\EpicorData\Reports\" & JobTrackerForm.Session.UserID & "\MaterialRequest_" & DateTime.Now.ToString("yyyyMMddHHmmss") & ".xml"
> tmprfile = "\\erptest1-lc\EpicorData\Reports\" & JobTrackerForm.Session.UserID & "\TC_BM_MtlReq.rpt"
>
> 'CR viewer erase the report and datafile so you need to copy at least the rpt file to view it and not loose the project
> My.Computer.FileSystem.CopyFile(reportfile,tmprfile,FileIO.UIOption.AllDialogs,FileIO.UICancelOption.DoNothing)
>
> 'If you need to catch the .xml file to put it to the .rpt just do it when CR viewer is open
>
> dsReport.WriteXml(datafile)
>
> Dim crviewer As Epicor.Mfg.Lib.Report.EpiCrystalViewer = New Epicor.Mfg.Lib.Report.EpiCrystalViewer(tmprfile,datafile,"Some title")
> crviewer.Show()
>
> End Sub
>
> --- In vantage@yahoogroups.com, "jckinneman" <jckinneman@> wrote:
> >
> > Guess I'll leave out the attempts at humor.... :)
> >
> > --- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@> wrote:
> > >
> > >
> > >
> > > Thanks for your response and explanation how agent works with reports.
> > >
> > > No need semicolons - it's VisualBasic. Dim means definition of variable.
> > >
> > > Your solution is probably the same as next mine. I've found it also in the group so I will try to go this way...
> > >
> > > --- In vantage@yahoogroups.com, "jckinneman" <jckinneman@> wrote:
> > > >
> > > > You are missing a lot of semi-colons... and not sure what "dim" means :)
> > > >
> > > > You can't pass results to the report that you have previously retrieved if I follow what you are doing.
> > > >
> > > > The call to submittoagent is only going to process parameters that will be used to look things up, at the time you submit to agent no data has been retrieved yet. Once the item has been submitted to agent it will retrieve the items for the report.
> > > >
> > > > An alternative is to run the BAQ to get the data, you then can build your own crystal report using the BAQ results as the data-source. Examples of building a Crystal report via code has been listed in this group before and Googling it will give a number of examples of building one via code.
> > > >
> > > > Jim Kinneman
> > > > Encompass Solutions, Inc.
> > > >
> > > > --- In vantage@yahoogroups.com, "bmszyca" <bartosz.mszyca@> wrote:
> > > > >
> > > > > Hi, I need to print data from EpiUltraGrid which dataset is taken from BAQReport and one of the columns is modified manualy. The report should have this manual input values (which exists in BAQ as 0). When I put BAQReportResult table to ReportDataSet I get the error:
> > > > >
> > > > > Progress.Open4GL.Exceptions.Open4GLException: Input result set error: System.IndexOutOfRangeException: Index was outside the bounds of the array. There might be a mismatch between an input result set and the schema in the proxy. (7228) (7176)
> > > > >
> > > > > If I don't add Result table to dataset, I get the correct report with my own parameters (but of course without data from EpiUltraGrid). Is any possibility to fix it? Or maybe is another way to achieve my needs?
> > > > >
> > > > > The code (Epicor 9.05.701):
> > > > >
> > > > > Private Sub epiButtonPrint_Click(ByVal sender As Object, ByVal args As System.EventArgs)
> > > > > Dim report As Epicor.Mfg.Rpt.BAQReport = New Epicor.Mfg.Rpt.BAQReport(JobTrackerForm.Session.ConnectionPool)
> > > > > Dim dsReport As Epicor.Mfg.Rpt.BAQReportDataSet = New Epicor.Mfg.Rpt.BAQReportDataSet()
> > > > >
> > > > > dsReport = report.GetNewBAQReportParam("TC_BM_MtlReq")
> > > > >
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("BAQID") = "TC-BM_MaterialRequest"
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("ReportTitle") = "Zapotrzebowanie materialowe"
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("DCDUserID") = JobTrackerForm.Session.UserID
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("BAQRptID") = "TC_BM_MtlReq"
> > > > > 'dsReport.Tables("BAQReportParam").Rows(0)("AutoAction") = "Preview"
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("AgentID") = "SystemTaskAgent"
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("WorkstationID") = Environment.MachineName
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("DateFormat") = "mm/dd/yyyy"
> > > > > dsReport.Tables("BAQReportParam").Rows(0)("NumericFormat") = ",."
> > > > >
> > > > > Dim tabResult As DataTable = new DataTable("BAQReportResult")
> > > > > tabResult = Me.epiUltraGridJobs.DataSource.Clone()
> > > > > dsReport.Tables.Add(tabResult)
> > > > > For Each t As DataTable In dsReport.Tables
> > > > > If t.TableName = "Results" Then
> > > > > t.TableName = "BAQReportResult"
> > > > > End If
> > > > > Next
> > > > >
> > > > > For Each row As DataRow In Me.epiUltraGridJobs.DataSource.Rows
> > > > > dsReport.Tables("BAQReportResult").ImportRow(row)
> > > > > Next
> > > > >
> > > > > report.SubmitToAgent(dsReport,"SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.BAQReport;TC_BM_MtlReq")
> > > > >
> > > > > End Sub
> > > > >
> > > >
> > >
> >
>