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);
}
}
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);
}
}