‎2009 Jan 22 6:52 AM
Moderator message: please use a more informative subject in future
Hi,
i want retrive data from mseg and mkpf table, base on material , customer and posting date.
above three fields are report input.
means
customer - abc
material - xyz
date - 10/12/2008 to 10/01/2009
material and customer fields in mseg table .
posting date fields in mkpf table.
code
SELECT * FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
WHERE MATNR IN MAT AND KUNNR IN CUST .
SELECT * FROM MKPF INTO CORRESPONDING FIELDS OF TABLE IT_MKPF
FOR ALL ENTRIES IN IT_MSEG
WHERE MBLNR = IT_MSEG-MBLNR AND BUDAT IN DATE .
but it not give between posting date record.
Thanks in Advance.
Regard
Sam.
Edited by: Matt on Jan 22, 2009 9:59 AM
‎2009 Jan 22 7:04 AM
HI Sam,
I would advise you to build a range for MJAHR also from date and use it in both MSEG and MKPF.
Also what other erroneous BUDAT are you getting in the output..can u provide some examples...
and yes MSEG is a transparent table...
so i will suggest you to fetch data using a join..
SELECT (field_list) FROM MKPF as a JOIN mseg as b ON amblnr = bmblnr and amjahr = bmjahr
WHERE ...all conditions...
Edited by: Ankesh Saharan on Jan 22, 2009 12:38 PM
‎2009 Jan 22 6:57 AM
Hi,
try like this,
SELECT * FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
WHERE MATNR IN MAT AND KUNNR IN CUST .
SELECT * FROM MKPF INTO CORRESPONDING FIELDS OF TABLE IT_MKPF
FOR ALL ENTRIES IN IT_MSEG
WHERE MBLNR = IT_MSEG-MBLNR
AND BUDAT IN DATE
AND MJAHR = IT_MSEG-MJAHR . "Added
‎2009 Jan 22 7:00 AM
HELLO
MSEG is a cluster table and the complexity of data in mseg table is very high,so before fetching the data from mseg please make sure that you are providing full primary key details in the where clause so that only the required results are fetched.
hope it helps.
regards
geeta gupta
‎2009 Jan 22 7:03 AM
Hello Sam,
If you try this way, MSEG will have data for MBLNR not in the date range.
I will suggest use INNER JOINS on MKPF & MSEG.
BR,
Suhas
PS: I suggest this to get consistent data & nothing to do with performance.
‎2009 Jan 22 7:06 AM
Suhas,
Why in that case the restriction in WHERE clause for BUDAT IN DATE not work??
‎2009 Jan 22 7:12 AM
Hello Ankesh,
Quite simple: MSEG has no restriction on BUDAT --> You get data based on the WHERE clause say 20 MBLNRs.
MKPF has BUDAT restriction --> You get 5 MBLNRs from the 20 in IT_MSEG which fall in the date reange.
Now you have Loop at IT_MKPF and delete from IT_MSEG. IF you use JOINS you donot have to worry about this.
Suhas
‎2009 Jan 22 7:04 AM
HI Sam,
I would advise you to build a range for MJAHR also from date and use it in both MSEG and MKPF.
Also what other erroneous BUDAT are you getting in the output..can u provide some examples...
and yes MSEG is a transparent table...
so i will suggest you to fetch data using a join..
SELECT (field_list) FROM MKPF as a JOIN mseg as b ON amblnr = bmblnr and amjahr = bmjahr
WHERE ...all conditions...
Edited by: Ankesh Saharan on Jan 22, 2009 12:38 PM
‎2009 Jan 22 7:46 AM
‎2009 Jan 22 8:59 AM