09-27-2006 2:52 AM
Hi all,
I used the following code to retrieve the latest doc for each material from mseg.
select matnr max( mblnr ) from mseg into table phy_inv where matnr in s_matnr and xauto = ' ' and werks in s_werks group by matnr.
The performance is too slow. can anyone suggest me to improve my performance.
Thanks,
Rajesh.
09-27-2006 3:07 AM
Hi Rajesh,
<b>types : begin of t_inv,
mblnr type mseg-mblnr,
matnr type mseg-matnr,
end of t_inv.
data : phy_inv type standard table of t_inv.
select max( mblnr )
matnr
from mseg
into table phy_inv
where xauto = ' '
and matnr in s_matnr and
werks in s_werks
group by matnr.</b>
The order of fields in the selection and in the where clause should be same as of the order in the table.
Best regards,
Prashant
PS : Please reward all helpful answers
09-27-2006 3:41 AM
Hi,
I get the performance problem when i give a range of materials in my selection.
for example:
select-options:
materials : a to k.
____________________________________________
if i leave it blank the performance is good.
Please send you suggestions,
Rajesh.
09-27-2006 4:19 AM
Hi Rajesh,
Generally data in MSEG is very huge, when you perform group by functionality it will take lot of time, so retrieve the data into internal table sort by material and material doument number(Descending) and delete the adjacent duplicates from internal table.
Regards,
Arun.
09-27-2006 3:45 AM
I think it will be quicker if you get all the data and find the 'max' yourself.
select matnr mblnr from mseg into table phy_inv where matnr in s_matnr and xauto = ' ' and werks in s_werks
.
sort phy_inv by matnr mblnr descending.
delete adjacent duplicates from phy_inv comparing matnr.