Application Development and Automation 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: 
Read only

Internal Table

Former Member
0 Likes
1,187

Hi all Pandits,

I have an internal table 'itab1' containing a field 'field'.

I want to fill another internal table 'itab2' containing same 'field' from a 'dbtable'.

Now I want to use 'For All Entries' when fetch itab2 as it dbtable has got so many entries comparing that field <> itab1-field.

Concern is, when I am doing this I am getting, Iam not getting the required records, instead all the records from dbtable are coming. Why?

Can any pandit help me out here or can provide another way?

Regards

Vaibhav

12 REPLIES 12
Read only

Former Member
0 Likes
1,166

Hi

First check the field is value in Itab1 is it same as u r expecting.And try to use the max keys when u r fetching the data.

Regards,

Raghu.

Read only

0 Likes
1,166

Yes Raghu,

I have checked the field value, itab1 is sorted. I am using keys. So everything as already taken care except the right one which willhelp to resolve my bizarre issue.

Reagrds

Read only

VXLozano
Active Contributor
0 Likes
1,166

Do you check if table1 is empty? FOR ALL ENTRIES IN itab returns all rows in the FROM table when itab is empty.

Read only

former_member209217
Active Contributor
0 Likes
1,166

Hi,

Before using FOR ALL ENTRIES you should check itab1 whether it is initial or not.

If you have not done this check and if no matching record is found in dbtable then all the records from Database Table are retrieved.

Regards,

lakshman.

Read only

0 Likes
1,166

YES ALL,

I have checked itab1 has got the data.

Regars

Read only

Former Member
0 Likes
1,166

Please can u tell whcih tables u r refering.

Read only

0 Likes
1,166

Hi Raghav,

I am using all Z tables.

Issue is coming when I using '<>' operator with 'For All Entries'. But when I use '=', its giving the excact values which I require.

Can u pz check if even u are facing the same issue with '<>' operator?

Regards

Vaibhav

Read only

0 Likes
1,166

Can you please copy here part of your code?

1- data declaration of your internal tables

2- SQL where you fetch data for itab1

3- SQL where you fetch data for itab2

I cannot see any operator between your ''... and I think FAE conditions must be all equal ("=")

Read only

Former Member
0 Likes
1,166

hi

before using for all entries first use if condition Eg .



ifi tab1[] is not initial.

select field from table 
INTO CORRESPONDING FIELDS OF TABLE  itba2
FOR ALL ENTRIES IN itab1
where field = itab1-field. 
endif. 

hope its helps you.

thanks,

Abhilash

Read only

Former Member
0 Likes
1,166

Hi,

Make sure of the following:

1. Internal table 1 has values, else the result of select query will be all the records from database table.

2.The sequence of fields in Select query and the internal table2 should be the same .

Inttab1-field1, inttab2 --field1, dbtable-field1 are of same datatype.

if not inttab1[] is initial.

Select field1

from dbtable

into table inttab2

for all entries in inttab1

where field1 = inttab1-field1.

endif.

Regards,

Ramya

Read only

Harsh_Bansal
Contributor
0 Likes
1,166

Hi,

Please paste your code for reference.

Regards,

Harsh Bansal

Read only

Former Member
0 Likes
1,166

Try This

IF ITAB1[] IS NOT INITIAL.

SELECT FIELD FROM DBTABLE INTO CORRESPONDING FIELDS

OF TABLE ITAB2 FOR ALL ENTRIES IN ITAB1 WHERE FIELD1 = ITAB1-FIELD1.

ENDIF.