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

Problem with MBLNR

kiran_k8
Active Contributor
0 Likes
1,223

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,164

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

7 REPLIES 7
Read only

Former Member
0 Likes
1,164

Hello

The internal table it_mseg_header is not contains field mjahr ?

Read only

GauthamV
Active Contributor
0 Likes
1,164

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.

Read only

kiran_k8
Active Contributor
0 Likes
1,164

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.

Read only

Former Member
0 Likes
1,165

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

Read only

Subhankar
Active Contributor
0 Likes
1,164

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

Read only

kiran_k8
Active Contributor
0 Likes
1,164

Subhankar,

No, it is parameter only.

K.Kiran.

Read only

Former Member
0 Likes
1,164

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'.