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 ENTERIES?

Former Member
0 Kudos
134

WHAT IS THE USE OF FOR ALL ENTERIES IN AN INTERNAL TABLE?PLZZ TELL

6 REPLIES 6

Former Member
0 Kudos
68

Hi,

It is used instead of writing select inside a loop.

former_member589029
Active Contributor
0 Kudos
68

Assumed you have a table 'itab' with a column that holds material numbers 'MATNR'. Now you want to get all material info for those material only:

select * from mara

into table lt_mara

for all entries in itab

where matnr eq itab-matnr.

This will select all MARA entries for which there is a matnr entry in itab.

However if for whatever reason itab is empty ALL entries from MARA will be selected, it is the same behavior as with an empty select-option.

Hope that helps,

Michael

former_member156446
Active Contributor
0 Kudos
68

it reduces a bunch of where clause for the corresponding select, which reduces the load on DB

Former Member
0 Kudos
68

Hi,

Assume If you have two internal tables with some data existing in each table.

when you are trying to retreive the data from database into the second internal table, you will check whether your first internal table has some information or the data with respect to first internal table information. If nothing is there that means if first internal table is initial then the complete data even the irrelavent data is retreived into Second internal table. To avoid this Unnecessary data retreival into 2nd internal table we use this For All ntries Concept.

Reward if Useful,

Regards,

Naveen Tiramdasu.

Former Member
0 Kudos
68

hi srinath,

FOR ALL ENTRIES command is used to get the data from the data base table for each record of the specified internal table by matching the field.

This command is used when you have two internal tables ITAB1 and ITAB2. if you want to retrieve some necessary data to ITAB1 and for each data in ITAB1 we have to get the required data to ITAB2.

This command needs some necessary things to be followed.

1. Make sure that FOR ALL ENTRIES internal table is not empty.

2. All possible primary key fields should be considered in the select statement to ignore duplication.

3.WHERE clause condition should be validated on the FOR ALL ENTRIES internal table field.

4.The fields used in WHERE clause should always be using the same data type and length.

syntax: FOR ALL ENTRIES in <1st table name> WHERE

<field name> = <1st table name> - <field name>

FOR ALL ENTRIES in ITAB1 WHERE MATNR = ITAB1-MATNR.

*REWARD IF USEFUL* .

reply for further information.

regards,

santosh

Former Member
0 Kudos
68

Hi,

FOR ALL ENTRIES works with a database in a quantity-oriented manner. Initially all data is collected in an internal table. Make sure that this table contains at least one entry (query sy-subrc or DESCRIBE), otherwise the subsequent transaction will be carried out without any restrictions).

SELECT...FOR ALL ENTRIES IN is treated like a SELECT statement with an external OR condition. The system only selects those table entries that meet the logical condition .

Using FOR ALL ENTRIES is recommended when data is not being read from the database, that is, it is already available in the program, for example, if the user has input the data. Otherwise a join is recommended.

Here is sample program for FOR ALL ENTRIES:

DATA:it_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.

DATA:it_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

SELECT * FROM ekko INTO TABLE it_ekko UP TO 10 ROWS.

IF NOT it_ekko[] IS INITIAL.

SELECT * FROM ekpo INTO TABLE it_ekpo

FOR ALL ENTRIES IN it_ekko

WHERE ebeln = it_ekko-ebeln.

ENDIF.

LOOP AT it_ekko.

WRITE:/ it_ekko-ebeln.

HIDE it_ekko-ebeln.

ENDLOOP.

AT LINE-SELECTION.

LOOP AT it_ekpo WHERE ebeln = it_ekko-ebeln.

WRITE:/ it_ekpo-ebelp,it_ekpo-ebeln.

ENDLOOP.

Regds

Sivaparvathi

Please reward points if helpful....