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

Help - is this segment of code correct?

Former Member
0 Likes
1,068

SELECT MARAMATNR MSEGMENGE MSEG~BWART

INTO CORRESPONDING FIELDS OF TABLE ITAB_SHIP_QTY

FROM MARA INNER JOIN MSEG ON MSEGMATNR = MARAMATNR

INNER JOIN MKPF ON MKPFMBLNR = MSEGMBLNR

AND MKPFMJAHR = MSEGMJAHR

WHERE MARAMATNR IN Z_MATNR AND MKPFBUDAT IN SHIP_D

AND ( ( MSEG~LGORT = 'L002' AND

MSEG~BWART IN ('901','902','101','102','105','106') ) OR

( MSEGLGORT = 'L001' AND MSEGBWART = '311' ) OR

( MSEGUMLGO = 'L001' AND MSEGBWART = '312' ) ).

Dear all,is the above code correct? coz i get the internal table wif more than 2000records with same material number,same movement type and same storage location...only some of the quantity is different. Thx all

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
976

Hi

After this select write

sort itab_ship_qty by matnr .

delete adjacent duplicates from itab_ship_qty comparing matnr menge bwart.

SELECT MARAMATNR MSEGMENGE MSEG~BWART

INTO CORRESPONDING FIELDS OF TABLE ITAB_SHIP_QTY

FROM MARA INNER JOIN MSEG ON MSEGMATNR = MARAMATNR

INNER JOIN MKPF ON MKPFMBLNR = MSEGMBLNR

AND MKPFMJAHR = MSEGMJAHR

WHERE MARAMATNR IN Z_MATNR AND MKPFBUDAT IN SHIP_D

AND ( ( MSEG~LGORT = 'L002' AND

MSEG~BWART IN ('901','902','101','102','105','106') ) OR

( MSEGLGORT = 'L001' AND MSEGBWART = '311' ) OR

( MSEGUMLGO = 'L001' AND MSEGBWART = '312' ) ).

Dear all,is the above code correct? coz i get the internal table wif more than 2000records with same material number,same movement type and same storage location...only some of the quantity is different. Thx all

7 REPLIES 7
Read only

Former Member
0 Likes
977

Hi

After this select write

sort itab_ship_qty by matnr .

delete adjacent duplicates from itab_ship_qty comparing matnr menge bwart.

Read only

Former Member
0 Likes
976

Hi Joan

The SELECT statement is absolutely correct.

There may be huge data for that meterial. If you want to X check, just check it out in MSEG table by providing the material only. The number of records in the MSEG should be either >= number of records your SELECT populates.

Regards

Surya.

Read only

0 Likes
976

thx rk

hi surya,if the data really are tat huge....should i use the method as suggested by Rk? coz in the end i need to sum up the menge ( qty )

sort itab_ship_qty by matnr .

delete adjacent duplicates from itab_ship_qty comparing matnr menge bwart.

Read only

former_member283648
Participant
0 Likes
976

Hi,

You can do the following.

1. Do an innerjoin separately with MSEG and MKPF for all entries selected from MARA (MARA~MATNR IN Z_MATNR). This willl give u a control on your record fetching.

2. You can use your present query with distinct addition to the BWART field and sum addition to the MENGE field as you will get some of quantities for the same movment types.

3. Otherwise manipulate your output internal table based on the filter criteria you have.

Read only

0 Likes
976

hie balachandran,can u elaborate more on how to do the following?

1. Do an innerjoin separately with MSEG and MKPF for all entries selected from MARA (MARA~MATNR IN Z_MATNR). This willl give u a control on your record fetching.

2. You can use your present query with distinct addition to the BWART field and sum addition to the MENGE field as you will get some of quantities for the same movment types.

thx..

Read only

0 Likes
976

thanks all for the infor..i manage to solve it d ^^

Read only

Former Member
0 Likes
976

hi

good

i hope the inner join is correct, but the procedure of writing is bit confusing, if you r getting more than 2000 records than your one of the condition is satisfying the criteria but some of the condition is not satisfying, if you have use the select statement than insterad of using OR make them AND which i think more appropriate.

thanks

mrutyun^