Application Development and Automation 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: 
Read only

Get data from MSEG

Former Member
0 Likes
1,255

I want to get material last good issue record from MSEG,How to write the code

Select * from MSEG

Where MSEG~BUDAT = MAX ?

6 REPLIES 6
Read only

Former Member
0 Likes
1,051

hi,

Try this code

SELECT * FROM MSEG INTO G_MSEG

UP TO 1 ROWS ORDER BY BUDAT DESCENDING .

ENDSELECT.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,051

Hello Bean,

MSEG is a huge table which stores data for all the Material Mvmts taking place in the syst. Your qeury will take lot of time to process.

You need to restrict your scope of selection. Can you plz tell what are the user inputs i.e., selection-screen params?

BR,

Suhas

Read only

Former Member
0 Likes
1,051

Hi,

try like this...


select * from mkpf into table it_mkpf.

select * from mseg
into table it_mseg
for all entries in it_mkpf
where mblnr eq it_mkpf-mblnr.

sort it_mseg by budat descending.

read table it_mseg index 1.

Now the first row will contain the latest figure..

Arunima

Edited by: Arunima Rudra on Dec 17, 2008 11:30 AM

Read only

Former Member
0 Likes
1,051

Hi Bean,

Can you please be bit clear that what do you mean by "material last good issue record ".

And MSEG does not have the field name BUDAT.

Regards

Akshay

Read only

0 Likes
1,051

Hi,

I want to get the some material last goods entry to some storage location

BUDAT is a field that is the material doc.'s post date

.

Read only

Former Member
0 Likes
1,051

This is the logic to calculate the last PO for a particular material .

You can interprate with your condition depending on the movement type and the number range assigned to the material document number .

SELECT * UP TO 1 ROWS

FROM ekpo

INTO wa_ekpo

WHERE ebeln LIKE '45%'

AND matnr = wa_outtab-matnr

ORDER BY ebeln DESCENDING .

ENDSELECT .

If any further issue pls revert back .

Regards

Jamal