03-13-2007 8:44 AM
hallow i have a problem with for all entries ,when i have <b>0000 in jobid</b> i get wrong result and when i do in in loop i get o.k. result,but the problem is the <b>performance</b> in loop becuse in my table i have loot of data .
regards
LOOP AT itab INTO wa_itab.
SELECT pernr orgeh persk stell
FROM pa0001
INTO (wa_mb_emp_tab-pernr , wa_mb_emp_tab-orgeh,
wa_mb_emp_tab-employee_subgroup , wa_mb_emp_tab-stell )
FOR ALL ENTRIES IN teken_itab
WHERE orgeh = '00009999'
AND ( persg EQ '6' OR persg EQ '7' OR persg EQ '8' )
AND stell = wa_itab-jobid.
IF sy-subrc = 0.
APPEND wa_mb_emp_tab TO mb_emp_tab.
CLEAR wa_mb_emp_tab.
ENDIF.
ENDSELECT.
ENDLOOP.
03-13-2007 8:52 AM
This is because of the behaviour of the FOR ALL ENTRIES. 000 refers to initial value and when FOR ALL ENTRIES is used, those records will only be selected that have at least one filed as not initial in the value set.
<b>Solution:</b> Make sure that the selection has the PRIMARY KEY of the table also selected into the TABLE
03-13-2007 8:52 AM
This is because of the behaviour of the FOR ALL ENTRIES. 000 refers to initial value and when FOR ALL ENTRIES is used, those records will only be selected that have at least one filed as not initial in the value set.
<b>Solution:</b> Make sure that the selection has the PRIMARY KEY of the table also selected into the TABLE
03-13-2007 8:59 AM
hi Naveen
maybe u can give me ex. of using PRIMARY KEY in selection of table
regards
03-13-2007 9:02 AM
hi
delete the duplicate entries before using FOR ALL ENTRIES in the select statement.
regards,
madhu
03-13-2007 8:58 AM
HI..
If you are using For all entries...Then
<b>You must specify all the Key fields in where condition,and u have to select all the key fields ...</b>otherwise you will get wrong results definitely..
Any time For all entries will give unique records..i.e it will not give duplicate records in out put..
I hope it will helps u..
If helps reward with points..
Regards Rk
Message was edited by:
Rk Pasupuleti
03-13-2007 9:04 AM
hi rk.
how u explain that in my loop its working and i don't change the where condition
regards
03-13-2007 9:13 AM
Hi..Antonio..
You just include all the Primary key fields in your select statement along with the required fields..This is because of The behavior of For all entries..
Regards Rk
03-13-2007 9:05 AM
When you use SELECT ...FOR ALL ENTRIES <teken_itab>....It is important to check that Internal table used in FOR ALL ENTRIES, has some rows. As if there is no row in your internal table <teken_itab>, it will pick all the records from DB.
So please check NOT <teken_itab>[] IS INITIAL and change code as below:
IF NOT <teken_itab>[] IS INITIAL.
SELECT pernr orgeh persk stell FROM pa0001
INTO (wa_mb_emp_tab-pernr , wa_mb_emp_tab-orgeh,
wa_mb_emp_tab-employee_subgroup , wa_mb_emp_tab-stell )
FOR ALL ENTRIES IN teken_itab
WHERE orgeh = '00009999'
AND ( persg EQ '6' OR persg EQ '7' OR persg EQ '8' )
AND stell = wa_itab-jobid.
ENDIF.
Hope this will help.
Regards,
Vishal
Message was edited by:
Vishal Tyagi
03-13-2007 9:26 AM
hi visal
i assumption that itab is not intial and i have in teken itab data like that
jobid
0000000
0000000
0000000
1231231
4564567
1548844
regards
03-13-2007 9:14 AM
Hi,
U have to check the internal table against its entries for not initial this is a must and if u didn't check it and loop and select for all entries it will result an infinite loop so check it and sort the internal table based on key fields before using this will make u achieve the results.
Hope this will help u.
Regards,
Ravi