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

Issue in select query

Former Member
0 Likes
892

Hi ,

The below select query retreives only 6 records for a particular plant from MSEG table but we have 14 records in the table for that plant, this query works fine for all the other materials except for one material , can anyone let me know what may be the reason for this.

IF I_TAB[] IS NOT INITIAL.

SELECT MBLNR

BWART

MATNR

WERKS

DMBTR

LBKUM

SALK3

SHKZG

SMBLN FROM MSEG INTO TABLE IT_MSEG

FOR ALL ENTRIES IN

I_TAB WHERE MATNR EQ I_TAB-MATNR AND

WERKS IN S_WERKS.

ENDIF.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
866

Hi select all the key fiedls while using for all entries this will fetch all the records

add MJAHR , ZEILE fields in the select query. please correct the code below



IF I_TAB[] IS NOT INITIAL.

SELECT MBLNR 
             MJAHR
             ZEILE
             BWART
             MATNR
             WERKS 
             DMBTR
             LBKUM 
            SALK3 
            SHKZG 
            SMBLN FROM MSEG INTO TABLE IT_MSEG
            FOR ALL ENTRIES IN
           I_TAB WHERE MATNR EQ I_TAB-MATNR AND
           WERKS IN S_WERKS.

ENDIF.

If you need further info let me know

Regards

Satish Boguda

8 REPLIES 8
Read only

Former Member
0 Likes
866

Blank

Edited by: Harsh Bhalla on Jan 5, 2010 10:33 PM

Read only

Former Member
0 Likes
866

Since you are using for all entries in itab, this query will give all unique records. Missing records must be duplicates.

regards,

PB

Read only

BH2408
Active Contributor
0 Likes
866

Hi ,

In the Select you are using the For all entries , What it will do . It will look at the I_TAB table entries i.e material number with plant in the selection screen.I is fetching what ever material presented in the I_TAB based on the plant.

Regards,

Bharani.

Read only

Former Member
0 Likes
866

Bring in all the three key fields (MBLNR, MJAHR, and ZEILE) in SELECT statement and you will get all the records.

Read only

Former Member
0 Likes
867

Hi select all the key fiedls while using for all entries this will fetch all the records

add MJAHR , ZEILE fields in the select query. please correct the code below



IF I_TAB[] IS NOT INITIAL.

SELECT MBLNR 
             MJAHR
             ZEILE
             BWART
             MATNR
             WERKS 
             DMBTR
             LBKUM 
            SALK3 
            SHKZG 
            SMBLN FROM MSEG INTO TABLE IT_MSEG
            FOR ALL ENTRIES IN
           I_TAB WHERE MATNR EQ I_TAB-MATNR AND
           WERKS IN S_WERKS.

ENDIF.

If you need further info let me know

Regards

Satish Boguda

Read only

Former Member
0 Likes
866

Hi Mohana,

The 14 records you are expecting from table MSEG, make sure that each of the materials out of these 14 records are present in your i_tab[].

Read only

Clemenss
Active Contributor
0 Likes
866

using for all entries you must select all key fields, otherwise duplicates are eliminated. Then use INTO CORRESPONDING FIELDS and you will not need all key fields in the target area. INTO CORRESPONDING FIELDS is always the better alternative because the DB interface makes sure you have no performance loss.

Regards,

Clemens

Read only

Former Member
0 Likes
866

Hi,

Ur query is for material and plant in where condition. mey the table has 14 records which has same plant and different materials

go to Mseg table and select the data with material and plant n chk the records

Please try this is Debugging mode

Regards

Azeez