‎2008 Jul 01 7:17 AM
select a~mblnr
a~ebeln
a~matnr
a~menge
a~bwtar
a~meins
a~werks
from mseg as a
inner join mkpf as b
on amblnr = bmblnr and
amjahr = bmjahr
into corresponding fields of table it_mseg_header
where
a~WERKS = p_werks
and b~mblnr = s_mblnr
and a~matnr in s_matnr
and a~BWART = '101'.
We have a plant,mblnr and matnr in the selection screen which are all mandatory in the selection screen.
The above select query works fine in all the cases except when the same MBLNR gets repeated in two different fiscal years say 2005 and 2008.
When a mblnr gets repeated in two different fiscal years it is behaving weirdly even thoug we have validated with the fiscal year.
Suppose,if I am running the report for a plant XYZ1 it is picking the data for the plant ABC1.
MBLNR-1234
Plant-ABC1
Fiscal year-2005
MBLNR 1234
Plant-XYZ1
Fiscal year-2008
It is picking the 2005 data in the plant ABC1 instead of 2008 data in the plant XYZ1 even though we had validated with plant.Can anyone let me know where I am going wrong.
Thanks,
K.Kiran
‎2008 Jul 01 7:30 AM
Hi Kiran ,
i also faced this kind of issue , u need to pass MJAHR in this cases.No other way of doing it.
regards
Prabhu
‎2008 Jul 01 7:28 AM
Hello
The internal table it_mseg_header is not contains field mjahr ?
‎2008 Jul 01 7:29 AM
hi,
if u want latest record then sort the data based on fiscal year and then use delete adjacent duplicates statement.
hope this will help u.
‎2008 Jul 01 7:36 AM
Gautam,
MBLNR 1234
Plant ABC1
Fiscal year 2005
MBLNR 1234
Plant XYZ1
Fiscal year 2008
In the selection screen I gave plant as XYZ1
As I had already given Plant in the where condition how come it is picking the data from plant ABC1.This is happening only when the MBLNR gets repeated in two diff fiscal years.
@Derez
I haven't taken fiscal year in the internal table
Thanks,
K.Kiran.
‎2008 Jul 01 7:30 AM
Hi Kiran ,
i also faced this kind of issue , u need to pass MJAHR in this cases.No other way of doing it.
regards
Prabhu
‎2008 Jul 01 7:30 AM
Hi
In where condition you given that
where
a~WERKS = p_werks
and b~mblnr = s_mblnr <------ It most probably select option .
and a~matnr in s_matnr
and a~BWART = '101'.
please do it like this way.
a~WERKS = p_werks
and b~mblnr in s_mblnr
and a~matnr in s_matnr
and a~BWART = '101'.
Edited by: Subhankar Garani on Jul 1, 2008 8:34 AM
‎2008 Jul 01 7:40 AM
‎2008 Jul 01 8:15 AM
Hello
Kiran, why you use table MKPF unless use its fields ?
Why not to do so:
select mblnr
ebeln
matnr
menge
bwtar
meins
werks
from mseg into corresponding fields of table it_mseg_header
where
WERKS = p_werks
and mblnr = s_mblnr
and matnr in s_matnr
and BWART = '101'.