Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: LINQ C#4.0 .NET4
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()
 
Posted 22-Nov-12 9:27am
Edited 22-Nov-12 22:30pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 543
1 OriginalGriff 384
2 George Jonsson 258
3 Abdul Samad KP 135
4 Animesh Datta 130
0 OriginalGriff 6,099
1 Sergey Alexandrovich Kryukov 5,411
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100