‎2006 Nov 01 6:09 AM
select distinct vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat
vbrkkunrg vbrksfakn vbrk~knuma
into table i_vbrk
from VRPMA join vbrk
on vrpmavbeln = vbrkvbeln
where ( vrpmafkart = 'ZCB4' or vrpmafkart = 'S2' or
vrpma~fkart = 'S1')
and vrpma~vtweg = p_vtweg
and vbrk~fkdat ge t_date
and vbrk~fkdat le e_date
and vbrk~vkorg = p_vkorg.
Any ideas on enhancing the above selection as both vbrk vrpma are huge tables!
Thanks in advance
‎2006 Nov 01 7:32 AM
Hi Srikanth,
Try this
select vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat
vbrkkunrg vbrksfakn vbrk~knuma
into table i_vbrk
<b>from VBRK join VRPMA</b> on vbrkvbeln = vrpmavbeln
where ( vrpmafkart = 'ZCB4' or vrpmafkart = 'S2' or
vrpma~fkart = 'S1')
and vrpma~vtweg = p_vtweg
and vbrk~fkdat ge t_date
and vbrk~fkdat le e_date
and vbrk~vkorg = p_vkorg.
let me know if is efficient and works by selecting appropriate data..
‎2006 Nov 01 8:36 AM
Pankaj,
Thanks for your reply, your suggestion basically involves interchanging selection tables, so this has no effect on performance metric. any ideas about enhancing/replacing joins as a whole ??
Thanks.
‎2006 Nov 01 8:55 AM
give a try to this piece of code
select vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat
vbrkkunrg vbrksfakn vbrk~knuma
into table i_vbrk
from VRPMA inner join vbrk
on vrpmamandt = vbrkmandt
and vrpmavbeln = vbrkvbeln
and vrpmavbeln = vbrkvbeln
and vrpmavkorg = vbrkvkorg
and vrpmafkdat = vbrkfkdat
and vrpmavtweg = vbrkvtweg
and vrpmafkart = vbrkfkart
and vrpmakunnr = vbrkkunrg
and vrpmakunag = vbrkkunag
and vrpmavbtyp = vbrkvbtyp
and vrpmaERNAM = vbrkERNAM
where ( vrpmafkart = 'ZCB4' or vrpmafkart = 'S2' or
vrpma~fkart = 'S1')
and vrpma~vtweg = p_vtweg
and vbrk~fkdat ge t_date
and vbrk~fkdat le e_date
and vbrk~vkorg = p_vkorg.
after the select query
SORT i_vbrk by fdl1 fld2...
delete adjacent duplicates from i_vbrk comparing fld1 fld2 ...
note: here fld1, fld2 denotes the key fields of your internal table according to which you were initially saying SELECT DISTINCT.
SHANE
‎2006 Nov 01 11:17 AM
Could you just tell me whether view created based on these 2 tables can be used instead of join. Please suggest me which is more efficient with very large amount of data??
‎2006 Nov 01 9:06 AM
As you are selecting all the fields from VBRK and even the filters are also present in VBRK table, I really do not understand the use of VRPMA.
Instead if you try the below query
select distinct vbrkvbeln vbrkfkart vbrkvtweg vbrkknumv vbrk~fkdat
vbrkkunrg vbrksfakn vbrk~knuma
into table i_vbrk
from vbrk
where vbrk~fkart in ('ZCB4','S2','S1')
and vrpma~vtweg = p_vtweg
and vbrk~fkdat ge t_date
and vbrk~fkdat le e_date
and vbrk~vkorg = p_vkorg.