Epicor Multi-company hurdle today, highlighted is new - untested:
Private Function GetPool(sCompany As String) As Epicor.Mfg.Core.BLConnectionPool
Dim oConnPool As Epicor.Mfg.Core.BLConnectionPool = Nothing
Try
oConnPool = New Epicor.Mfg.Core.BLConnectionPool("user", "pass", "AppServerDC://" & _AppServer)
Dim oSession = oConnPool.Get()
Dim oMod = New Epicor.Mfg.Lib.SessionMod(oConnPool)
oMod.SetCompany(sCompany, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
oConnPool.Release(oSession)
WriteLog("BLConnectionPool Got")
CloseLog()
Return oConnPool
Catch Ex As Exception
If oConnPool IsNot Nothing Then oConnPool.Dispose()
WriteLog("BLConnectionPool Fail: " & Ex.Message)
MsgBox(Ex.Message)
Throw
End Try
Return Nothing
End Function
Using epicor BO the datasets get rows with filter clauses. Using company in the filter clause was adding to a filter clause which already included company… even if it was never set. I think this is one way to switch companies.
Public Function GetForecast(sPart As String, sCompany As String, sPlant As String) As Epicor.Mfg.BO.ForecastDataSet
Dim oList As Epicor.Mfg.BO.ForecastDataSet = Nothing
Using oConnPool As Epicor.Mfg.Core.BLConnectionPool = GetPool(sCompany)
Dim oForecast As Epicor.Mfg.BO.Forecast = New Epicor.Mfg.BO.Forecast(oConnPool)
oList = oForecast.GetRows("PartNum = '" & sPart & "' AND Company = '" & sCompany & "'" & PlantFilter(sPlant), "", 0, 0, False)
End Using
Return oList
End Function
Green is redundant.
Here is an example of the epicor SQL passing company twice as a result of this call:
declare @p1 int
set @p1=26585
exec sp_prepexec @p1 output,N'@P1 varchar(8),@P2 varchar(50),@P3 varchar(8),@P4 varchar(8)',N'SELECT "company", "custnum", "partnum", "plant", "foredate", "inactive", "foreqty", "ForeQtyUOM", "consumedqty", "ponum", "createdby", "createddate", "autotransfer", "character01", "character02", "character03", "character04", "character05", "character06", "character07", "character08", "character09", "character10", "number01", "number02", "number03", "number04", "number05", "number06", "number07", "number08", "number09", "number10", "date01", "date02", "date03", "date04", "date05", "checkbox01", "checkbox02", "checkbox03", "checkbox04", "checkbox05", "demandreference", "demandcontractnum", "demandheadseq", "schedulenumber", "shiptonum", "enddate", "SysRowID", "SysRevID", "BitFlag", "ParentPartNum", "KitFlag", "EDIUpdateDate", PROGRESS_RECID, PROGRESS_RECID_IDENT_ FROM "dbo"."Forecast" WHERE (("Company" = @P1) AND ("PartNum" = @P2) AND ("Company" = @P3) AND ("Plant" = @P4)) ORDER BY "company", "partnum", "plant", "custnum", "foredate", "ParentPartNum" ','COMPANYX','000-00-00',COMPANYX,PLANTY
select @p1
I had help finding SessionMod here:
http://epicor-dev.blogspot.com/feeds/posts/default