Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Retrive data from mseg

Former Member
0 Kudos

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.

4 REPLIES 4

former_member223537
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

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.

former_member186741
Active Contributor
0 Kudos

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.