09-21-2009 3:01 PM
Hi friends,
Iam facing a problem while retreving data from a cluster table..
select knumv
kposn
krech
kawrt
kbetr
waers
kpein
kmein
kwert
from konv
into table gt_konv
where knumv in s_agnm.
In s_agnm i have 8 entries ie: iam giving manually 8 entries in s_sgnm-low.
If i do the above way iam getting exactly the 82 entries which i have in KONV table.. This is perfect..
But when iam using for all entries iam getting only 58 records from the KONV table..
ie :
SELECT KNUMV
KPOSN
KRECH
KAWRT
KBETR
WAERS
WAERS
KPEIN
KMEIN
KWERT
FROM KONV
INTO TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE KNUMV = ITAB-F1
Here F1 is the field which is same as S_SGNM as above and it also contains same number of records as above
Now when iam running the 2nd select statment iam getting only 58 entries ... instead it should get 82 entries as above...
Can any one tell me how to correct..
Regards
Kumar
09-21-2009 3:06 PM
Read ABAP help for FOR ALL ENTRIES, it is removing duplicates so you are losing data if you don't include all key fields.
Thomas
09-21-2009 3:06 PM
Read ABAP help for FOR ALL ENTRIES, it is removing duplicates so you are losing data if you don't include all key fields.
Thomas
09-21-2009 4:07 PM
even if i use all the key fields , its giving me the same results 58 reocrds, instead it should give me 82.
select knumv
kposn
stunr
zaehk
from konv
into table gt_tybh
where knumv in s_agnm.
if gt_tybh is not INITIAL.
sort gt_tybh by agreement_number kposn stunr zaehk.
select knumv
kposn
krech
kawrt
kbetr
waers
kpein
kmein
kwert
from konv
into table gt_konv
for all entries in gt_tybh
where knumv = gt_tybh-agreement_number and
kposn = gt_tybh-kposn and
stunr = gt_tybh-stunr and
zaehk = gt_tybh-zaehk.
In the above iam getting all the 82 records for the select-options s_sgnm..
later iam trying to get the other fields form the same konv table by using for all entries... here even if iam using all the key fields also its not getting me the total 82 records...
Initially for s_sgnm which contains 8 values , for those 8 values iam getting 82 records it table gt_tybh. But later when iam using for all entries iam not getting those 82 records in the 2nd select statment in the internal table gt_konv.
Why is this happening...
can any one correct it..
Regards
Kumar
09-21-2009 4:11 PM
You have to include those key fields in the result set (i.e. field list), that's where the duplicate check is done.
Thomas
P.S. if that's not it, then there must be something different in your selection values and/or selection logic.
09-21-2009 4:53 PM
One possibility could be that when you use the select options
select knumv
kposn
stunr
zaehk
from konv
into table gt_tybh
where knumv in s_agnm.
Here the select-option values are considered as wild card parameters instead of taking the exact value.
For eg, if the input for s_agnm is 1234 and if there is a record 123456, even this could be selected. thats why you must be getting the extra records.
Where as when you are using
select knumv
kposn
krech
kawrt
kbetr
waers
kpein
kmein
kwert
from konv
into table gt_konv
for all entries in gt_tybh
where knumv = gt_tybh-agreement_number and
kposn = gt_tybh-kposn and
stunr = gt_tybh-stunr and
zaehk = gt_tybh-zaehk.
Here it will consider the exact values instead as a wild card parameter. You could just compare the extra records and confirm if this is the case.
09-21-2009 6:16 PM
Thanks Thomas For your valuable answer...... It worked cheers...!!!!!!
Kumar
09-21-2009 3:07 PM
09-21-2009 3:09 PM
Hi Kumar,
Since the number of rows returned (82 and 58) is not too high to inspect visually, the first thing I would do is simply print out the two result tables and compare them. Also make absolutely certain that the internal tables referenced in your WHERE clause do indeed contain what you think they contain.
Keep us posted,
Mark