Application Development 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: 

for all enrtries

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

9 REPLIES 9

Former Member
0 Kudos

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

0 Kudos

hi Naveen

maybe u can give me ex. of using PRIMARY KEY in selection of table

regards

0 Kudos

hi

delete the duplicate entries before using FOR ALL ENTRIES in the select statement.

regards,

madhu

Former Member
0 Kudos

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

0 Kudos

hi rk.

how u explain that in my loop its working and i don't change the where condition

regards

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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