2012 Jul 16 6:57 PM
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.
2012 Jul 16 8:16 PM
Hi Jose,
Using 'For all entries' deletes duplicates from the result set. When you introduce LGORT the werks matnr mbwbest wbwbest was not duplicate anymore.
Regards,
Shravan
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.
2012 Jul 16 7:07 PM
Hello..
Follow the steps:
1.The for all entries always should be preceeded with the not initial condition.
2.Add the Lgort in the structure.
3.When using the move corresponding(which is least recomeneded),we need to take of the similar structure,or else there wud be wrong mapping.
Please check in the above way let me know.
regards,
Varun
2012 Jul 16 7:22 PM
At first I didn't have the lgort field in my internat table, and I didn't have it in my query. But later I added the lgort field in both places, what I don't understand is why this field makes the query bring a different number of entries.
2012 Jul 16 7:28 PM
I think you're right, if I change my query and avoid the FOR ALL ENTRIES statement using a specific MATNR I got all the 19 entries.
SELECT werks matnr mbwbest wbwbest
FROM s032
INTO CORRESPONDING FIELDS OF TABLE pt_s032
WHERE ssour EQ c_ssour
AND vrsio EQ c_vrsio
AND werks IN r_werks
AND matnr EQ 'VN-058665-0051'.
2012 Jul 16 8:04 PM
Jose,
'For all Enteries In' will result in distict dataset so if 2 records in result table are same than result table
will have only 1 records,( result will be same as using distinct )
Raj Patel
2012 Jul 16 8:16 PM
Hi Jose,
Using 'For all entries' deletes duplicates from the result set. When you introduce LGORT the werks matnr mbwbest wbwbest was not duplicate anymore.
Regards,
Shravan
2012 Jul 16 8:54 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |