Epicor 10 BAQ Customization How To (The Old Way)

They have an ABL conversion page below.


This is a .Net conversion Wen:


Snippet Converter for .NET 4.0



Jonathan Lang
I.T Manager
Database Engineer

So recently I came to the forum to try and figure out how to implement BAQs like I did in Vantage 8 and 9. It took a lot of tweaking, but I finally figured it out. Here is the code.


Dim dynQry As DynamicQueryImpl
dynQry = WCFServiceSupport.CreateImpl(Of Ice.Proxy.BO.DynamicQueryImpl)(DirectCast(oTrans.Session, Session), Epicor.ServiceModel.Channels.ImplBase(Of Ice.Contracts.DynamicQuerySvcContract).UriPath)
     Dim dsDQ As Ice.BO.DynamicQueryDataSet = New Ice.BO.DynamicQueryDataSet
     Dim dsEx as  Ice.BO.QueryExecutionDataSet = New Ice.BO.QueryExecutionDataSet
              Dim ds2 As System.Data.DataSet
              Dim RetRows() as datarow
              Dim Rework as boolean
              dsDQ = dynQry.GetByID("JBIS-JobPerformance1")
     dsDQ.QueryWhereItem(0).RValue = dteStartDate.Text
     dsDQ.QueryWhereItem(1).RValue = dteEndDate.Text
     dsDQ.AcceptChanges
     ds2 = dynQry.Execute(dsDQ, dsEx)


Then set your Grid equal to ds2 of course.

Also the RValues are actually only PARAMETERS set in the BAQ, so if you have a constant, constant, parameter, parameter in that order in your BAQ the RValues still start at 0 marking the first parameter.


Lastly I know this is the old way and there are newer ways to do it, but this works for me nicely and its really not that complex and still requires parameters to be set up, but gives you flexibility with dates, so when working with dates this way actually seemed to work better then the new way. So just an FYI. if you are needing help on this message me if you'd like. And if you are going to comment on how this is the old way. Thank you for repeating me.


Thanks everyone

Aaron.

Aaron,


  We are testing Epicor 10 now and I am struggling to figure out how to use a BAQ parametrized in version 10. I tried your code and received several errors.  I added Imports Ice.Proxy.BO and it resolved most of them.  Now I am getting the error "Session" is not defined.  I tried adding Dim session as EpiTransaction.Session but that doesn't work.  I don't know anything about WCFServiceSupport.  Where do I find this information?  I tried using the BL Tester to get the BAQ to run parametrized but it is acting strangely.  I have to ExecuteById then add the execution parameters to the dataset and ExecuteByID again.  Something is not right here.  Why did they remove the ExecuteByIDParametrized method?


I saw two other methods of using the WCFServiceSupport in this group but they were in C# and my translation failed.


Any help you could give will be appreciated.  Here is the code I am trying to use along with the code I normally use in Epicor 9.


Epicor 10 Code:


     Dim baqID as string = "DTSF-RollUpWeightAsm"
     Dim dset1 as DataSet
     Dim session as EpiTransaction.Session
     Dim dynQry As DynamicQueryImpl
     dynQry = WCFServiceSupport.CreateImpl(Of Ice.Proxy.BO.DynamicQueryImpl)(DirectCast(oTrans.Session, Session), Epicor.ServiceModel.Channels.ImplBase(Of Ice.Contracts.DynamicQuerySvcContract).UriPath)
     Dim dsDQ As Ice.BO.DynamicQueryDataSet = New Ice.BO.DynamicQueryDataSet
     Dim dsEx as  Ice.BO.QueryExecutionDataSet = New Ice.BO.QueryExecutionDataSet
     Dim RetRows() as datarow
     Dim Rework as boolean
     dsDQ = dynQry.GetByID(baqID)
     dsDQ.QueryWhereItem(0).RValue = JobName
     dsDQ.AcceptChanges
     dset1 = dynQry.Execute(dsDQ, dsEx)


Epicor 9 Code:


     Dim baqID as string = "DTSF-RollUpWeightAsm"
     Dim dset1 as DataSet
     Dim DQAdpt as DynamicQueryAdapter = New DynamicQueryAdapter(JobEntryForm)
     If (DQAdpt.BOConnect()) = true then
       Dim resultFieldList as string = ""
       Dim topNRecords as int32 = 100000
       Dim hasMoreRecords as boolean = True
       Dim execSet as Ice.BO.QueryExecutionDataSet
       execSet  = DQadpt.GetQueryExecutionParametersByID(baqID)
       Dim targetRow as DataRow
       Dim tbl as DataTable = execSet.Tables("ExecutionParameter")
       targetRow = execSet.Tables("ExecutionParameter").NewRow()
       targetRow("ParameterID") = "JobName"
       targetRow("ParameterValue") = JobName
       targetRow("ValueType") = "String"
       targetRow("IsEmpty") = False
       targetRow("RowMod") = "A"
       tbl.Rows.Add(targetRow)
       DQadpt.ExecuteByIDParametrized(baqID, execSet, resultFieldList,topNRecords, hasMoreRecords)  

dSet1 = DQadpt.QueryResults


Thanks

Jeff Sanders

Here you go Jeff,

You should REALLY consider changing your code to C# there are a lot of things that just won't work right in VB... and some of the functions within Epicor are case sensitive which VB ignores and will cause you logs of headaches


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Mon, Aug 15, 2016 at 5:40 PM, jps@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p></p><p>Aaron,</p><p><br></p><p>  We are testing Epicor 10 now and I am struggling to figure out how to use a BAQ parametrized in version 10. I tried your code and received several errors.  I added Imports <a rel="nofollow" target="_blank" href="http://Ice.Proxy.BO">Ice.Proxy.BO</a> and it resolved most of them.  Now I am getting the error &quot;Session&quot; is not defined.  I tried adding Dim session as EpiTransaction.Session but that doesn&#39;t work.  I don&#39;t know anything about WCFServiceSupport.  Where do I find this information?  I tried using the BL Tester to get the BAQ to run parametrized but it is acting strangely.  I have to ExecuteById then add the execution parameters to the dataset and ExecuteByID again.  Something is not right here.  Why did they remove the ExecuteByIDParametrized method?</p><p><br></p><p>I saw two other methods of using the WCFServiceSupport in this group but they were in C# and my translation failed.</p><p><br></p><p>Any help you could give will be appreciated.  Here is the code I am trying to use along with the code I normally use in Epicor 9.</p><p><br></p><p>Epicor 10 Code:</p><p><br></p><p>     Dim baqID as string = &quot;DTSF-RollUpWeightAsm&quot;<br>     Dim dset1 as DataSet<br>     Dim session as EpiTransaction.Session<span class="ygrps-yiv-767976275"><br>     Dim dynQry As DynamicQueryImpl<br>     dynQry = WCFServiceSupport.CreateImpl( Of Ice.Proxy.BO.DynamicQueryImpl) (DirectCast(oTrans.Session, Session), Epicor.ServiceModel.Channels. ImplBase(Of Ice.Contracts. DynamicQuerySvcContract). UriPath)<br>     Dim dsDQ As Ice.BO.DynamicQueryDataSet = New Ice.BO.DynamicQueryDataSet<br>     Dim dsEx as  Ice.BO.QueryExecutionDataSet = New Ice.BO.QueryExecutionDataSet<br></span><span class="ygrps-yiv-767976275">     Dim RetRows() as datarow<br>     Dim Rework as boolean<br></span>     dsDQ = dynQry.GetByID(baqID)<br>     dsDQ.QueryWhereItem(0).RValue = JobName<br>     dsDQ.AcceptChanges<br>     dset1 = dynQry.Execute(dsDQ, dsEx)<br></p><p><br></p><p>Epicor 9 Code:</p><p><br></p><p>     Dim baqID as string = &quot;DTSF-RollUpWeightAsm&quot;<br>     Dim dset1 as DataSet<br>     Dim DQAdpt as DynamicQueryAdapter = New DynamicQueryAdapter( JobEntryForm)<br>     If (DQAdpt.BOConnect()) = true then<br>       Dim resultFieldList as string = &quot;&quot;<br>       Dim topNRecords as int32 = 100000<br>       Dim hasMoreRecords as boolean = True <br>       Dim execSet as Ice.BO.QueryExecutionDataSet<br>       execSet  = DQadpt. GetQueryExecutionParametersByI D(baqID)<br>       Dim targetRow as DataRow<br>       Dim tbl as DataTable = execSet.Tables(&quot; ExecutionParameter&quot;)<br>       targetRow = execSet.Tables(&quot; ExecutionParameter&quot;).NewRow()<br>       targetRow(&quot;ParameterID&quot;) = &quot;JobName&quot;<br>       targetRow(&quot;ParameterValue&quot;) = JobName<br>       targetRow(&quot;ValueType&quot;) = &quot;String&quot;<br>       targetRow(&quot;IsEmpty&quot;) = False<br>       targetRow(&quot;RowMod&quot;) = &quot;A&quot;<br>       tbl.Rows.Add(targetRow)<br>       DQadpt. ExecuteByIDParametrized(baqID, execSet, resultFieldList,topNRecords, hasMoreRecords)  </p><p>dSet1 = DQadpt.QueryResults</p><p><br></p><p>Thanks</p><p>Jeff Sanders<br></p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>

Thanks Jose.  Looks simple enough.  Doesn't Epicor have something to convert vb.net to C#?