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

Mseg table data retrival

Former Member
0 Likes
1,517

Dear Expert's,

i am having a proble with this

SELECT mblnr mjahr zeile matnr charg bwart menge dmbtr ebeln ebelp lgort

FROM mseg

INTO CORRESPONDING FIELDS OF TABLE it_mseg

FOR ALL ENTRIES IN it_ekko

WHERE ebeln = it_ekko-ebeln

AND ebelp = it_ekko-ebelp

AND lgort = '0001'

AND werks = '1001'

AND bwart IN ('961','962').

i want to retrive data from mseg table i am having a purchase order & item no ,

Storage location, Plant, Movement type .

if a ma using above query the this query takes lots of time

Provide me method by with i can retrive data on the given condition using some other method...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,370

Hi Naresh,

You are writen the query correctly, but you did not maintained the sequence of the fields. we need to maintain the field sequence based on the table

if not it_ekko[] is initial.
SELECT mblnr mjahr zeile matnr charg bwart menge dmbtr ebeln ebelp lgort
FROM mseg
INTO TABLE it_mseg
FOR ALL ENTRIES IN it_ekko
WHERE 
<b>werks = '1001'   and 
bwart IN ('961','962') and
lgort = '0001'    and</b>
ebeln = it_ekko-ebeln
AND ebelp = it_ekko-ebelp.
endif.

Regards

Sudheer

Hi Naresh,

You are writen the query correctly, but you did not maintained the sequence of the fields. we need to maintain the field sequence based on the table

if not it_ekko[] is initial.
SELECT mblnr mjahr zeile matnr charg bwart menge dmbtr ebeln ebelp lgort
FROM mseg
INTO TABLE it_mseg
FOR ALL ENTRIES IN it_ekko
WHERE 
<b>werks = '1001'   and 
bwart IN ('961','962') and
lgort = '0001'    and</b>
ebeln = it_ekko-ebeln
AND ebelp = it_ekko-ebelp.
endif.

Regards

Sudheer

6 REPLIES 6
Read only

Former Member
0 Likes
1,370

You can think of creating index on MSEG for PO/PoItem or use EKBE table to first find out Material doc for all POs and then go to MSEG for details of Material doc.

Read only

Former Member
0 Likes
1,370

Hi Naresh,

Make sure if the table it_EKKO is not empty.

Also, sort it_ekko by ebeln and ebelp.

Declare the table it_mseg with the fields in the same order as they are selected from the table. and replace the statement INTO CORRESPONDING FIELDS OF TABLE it_mseg with INTO TABLE it_mseg

Regards,

Ravi

Read only

Former Member
0 Likes
1,370

sort it_ekko by ebeln ebelp.

and write your select query.

Read only

Former Member
0 Likes
1,370

Hi

Change the positions as shown in below:

removed into corresponding

SELECT mblnr mjahr zeile bwart matnr charg lgort dmbtr menge ebeln ebelp

FROM mseg

INTO TABLE it_mseg

FOR ALL ENTRIES IN it_ekko

WHERE ebeln = it_ekko-ebeln

AND ebelp = it_ekko-ebelp

AND lgort = '0001'

AND werks = '1001'

AND bwart IN ('961','962').

Regards

Shiva

Read only

Former Member
0 Likes
1,370

Hi Naresh,

Re write the code i this fashion,

<b>if not it_ekko[] is initial.</b>

SELECT mblnr mjahr zeile matnr charg bwart menge dmbtr ebeln ebelp lgort

FROM mseg

<b>INTO TABLE it_mseg</b>

FOR ALL ENTRIES IN it_ekko

WHERE ebeln = it_ekko-ebeln

AND ebelp = it_ekko-ebelp

AND lgort = '0001'

AND werks = '1001'

AND bwart IN ('961','962').

<b>endif.</b>

<b>i have bolded the changes in your code..

first check whetehr the internal table it_ekko is initial or not and remove the into corresponding fields of table , rather arrange the field in your internal table it_mseg in the order you are selecting from mseg.</b>

Read only

Former Member
0 Likes
1,371

Hi Naresh,

You are writen the query correctly, but you did not maintained the sequence of the fields. we need to maintain the field sequence based on the table

if not it_ekko[] is initial.
SELECT mblnr mjahr zeile matnr charg bwart menge dmbtr ebeln ebelp lgort
FROM mseg
INTO TABLE it_mseg
FOR ALL ENTRIES IN it_ekko
WHERE 
<b>werks = '1001'   and 
bwart IN ('961','962') and
lgort = '0001'    and</b>
ebeln = it_ekko-ebeln
AND ebelp = it_ekko-ebelp.
endif.

Regards

Sudheer