Skip to Content
0
Former Member
Jul 16, 2012 at 05:57 PM

strange behaviour in SELECT Query

17 Views

Hi!,

I don't understand a behaviour of an SELECT QUERY.

I have an internal table:

DATA:
BEGIN OF pt_s032 OCCURS 0,
werks LIKE s032-werks,
matnr LIKE s032-matnr,
mbwbest LIKE s032-mbwbest,
wbwbest LIKE s032-wbwbest,
END OF pt_s032.

I have an internal table of materials (this table only contains one material):

DATA:
BEGIN OF pt_matnr OCCURS 0,
matnr LIKE s032-matnr,
END OF pt_matnr.

and I have a range of plants (this contains a little bit more than 100 rows):

DATA:
BEGIN OF r_werks OCCURS 0,
sign,
option(2),
low LIKE s032-werks,
high LIKE s032-werks,
END OF r_werks.

When I perform the following SELECT query I got 18 rows:

SELECT werks matnr mbwbest wbwbest
FROM s032
INTO CORRESPONDING FIELDS OF TABLE pt_s032
FOR ALL ENTRIES IN pt_matnr
WHERE ssour EQ c_ssour
AND vrsio EQ c_vrsio
AND werks IN r_werks
AND matnr EQ pt_matnr-matnr.

BUT if I also add the field LGORT in my query, I got 19 rows:

SELECT werks LGORT matnr mbwbest wbwbest
FROM s032
INTO CORRESPONDING FIELDS OF TABLE pt_s032
FOR ALL ENTRIES IN pt_matnr
WHERE ssour EQ c_ssour
AND vrsio EQ c_vrsio
AND werks IN r_werks
AND matnr EQ pt_matnr-matnr.


I would appreciate someone could explain this behaviour.

Thanks in advance.