Hello
This is more of a LINQ question rather than an ERPConnect one, I think.
Below is the code which fires a SAP built-in query (here named LPQuery) then filters and adds fields to the result along with data formatting. Code works fine up until the last join. If I activate the last join it ends up in very long running time (don't know whether it ever ends or not, and after a while consuming up memory, so I just stop the run)
1 more info: the last join e.g.:
join bb in earak
on knumv.KNUMV equals bb.KNUMV
uses a second table for joining 1st and 3rd while all other joins are between only 2 tables (=built-in query result fields and another table), maybe that is where I'm causing errors ? So how to correct the last join, to have gain the field
bb.KBETR
??
Thanks
LPQuery = from res in sc.LIEFERPLAN(eladbiz1, ertszerv, partnerszerep, vevocsop)
where ConversionUtils.SAPDate2NetDate(res.VBEP_WADAT) > dtFilter.Value
select res;
var prctr = from x in sc.MARCList where x.WERKS == "3801" || x.WERKS == "3802" && !x.MATNR.StartsWith("Q") && !x.MATNR.StartsWith("S") && !x.MATNR.StartsWith("T") select x;
var earak = from x in sc.KONVList where x.KSCHL == "ZPR0" && x.MANDT == "060" select x;
var vbak = from y in sc.VBAKList where y.VKORG == "0038" select y;
var vevonevek = from nevek in sc.KNA1List where nevek.MANDT == "060" select nevek;
var lieferplanfinal = (from tab1 in LPQuery
join yy in prctr
on tab1.VBAP_MATNR equals yy.MATNR
join zz in vevonevek
on tab1.VBAK_KUNNR equals zz.KUNNR
join aa in vbak
on tab1.VBAK_VBELN equals aa.VBELN into resquery
from knumv in resquery
join bb in earak
on knumv.KNUMV equals bb.KNUMV
select new
{
zz.NAME1,
VBAK_KUNNR = tab1.VBAK_KUNNR.TrimStart(new char[] { '0' }),
VBAK_VBELN = tab1.VBAK_VBELN.TrimStart(new char[] { '0' }),
VBAP_MATNR = tab1.VBAP_MATNR.TrimStart(new char[] { '0' }),
tab1.VBAP_WERKS,
tab1.VBEP_BMENG,
tab1.VBEP_BMENG_0109,
tab1.VBEP_WMENG,
tab1.VBEP_WMENG_0104,
VBEP_WADAT = ConversionUtils.SAPDate2NetDate(tab1.VBEP_WADAT).ToShortDateString(),
yy.PRCTR,
bb.KBETR
}).Distinct().ToList()