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.
Showing results for 
Search instead for 
Did you mean: 

select for all entries

Former Member
0 Kudos



i want know about select for all entries statement in brief with a example,in which condition we can use and what primary requiement for this.


what is difference between type and like




Former Member
0 Kudos

Hi Deepak ,

The basic use of select for all entries is when we want to select values from a table based on the set of values in an internal table.

When using it you need to keep in mind the following things

1. The internal table must not be empty , if it is empty then all the records from the table will be selected which satisfy any other condition mentioed in the where clause of the statement.

2. Try to select all the primary keys of the table , beacuse for all entries does not support duplicate entries.



Former Member
0 Kudos

Hi deepak,

we can use inner joins also instead of for all entries ,but according to performance wise for all entries is preferable.


then reg. ur second answer:

type will be used for elementary as well as database fields

whereas like will only b specified with database fields..

Former Member
0 Kudos

Hi Deepak,

Here are the answers to the two questions that you put forward.


This statement picks up data from a Database Table on the basis of certain data of an internal Table. It would be easier for you to understand if you have a quick look at the following codes.

Suppose from the Selection Screen of a program, the Input has been taken for a certain range of Customer Numbers (kunnr) and Document Types (blart) and the parameters used for these are p_kunnr and p_blart respectively.

Let cust be an internal table where we are selecting the data from table BSID based on the entries in the selection screen.

             kunnr LIKE bsid-kunnr.
 DATA:  END OF cust.

         WHERE kunnr IN p_kunnr
         AND blart IN p_blart.

  SORT cust.


Now the Customer Numbers(kunnr) has been selected based on the given requirement in Internal Table 'cust'.

Now in order to perform some operations on these selected customer numbers we would need to select them from the table BSID yet again and put them in an internal table ws_bsid. Note, only those customer numbers that are there in internal table cust are needed to be selected, so we use the SELECT FOR ALL ENTRIES statment.

  SELECT mandt bukrs kunnr umsks umskz augdt augbl zuonr gjahr
           belnr buzei blart waers shkzg wrbtr xblnr bldat
           FROM bsid INTO TABLE ws_bsid
           FOR ALL ENTRIES IN cust
           WHERE kunnr = cust-kunnr
           AND shkzg = 'S'
           AND umskz = ' '.

This would select all entries of kunnr in internal table cust according to the given specification in ws_bsid.


There are a few standard data types in ABAP. If you want your variable to be alike any of those then you can use the TYPE statement. These data types are as follows.

Type Explanation SL Initial value

C Text (Character) 1 space

N Numeric text 1 '00...0'

D Date (YYYYMMDD) 8 '00000000'

T Time (HHMMSS) 6 '000000'

X Hexadecimal (HeX code) 1 X'00'

I Integer 4 0

P Packed number 8 0

F Floating point number 8 0

STRING Character sequence (string)

variable-length empty string

XSTRING Byte sequence (X string)

So your declarations can be as follows.

DATA : num type i,
            charac type c, 
            word(7) type c,
            money type p decimal 2,
            sentence type string,
            date type d,
            time type t.

Now if you want the variable to be of the data type of a previous variable declared by you or like that of a particular field of a table, then you can use the LIKE statment. For example,

DATA : d_kunnr LIKE bsid-kunnr,
            number like num,         " remember, we had declared num previously as i.
            date1 like sy-datum.     "sy-datum is current system date

Hope these would answer your questions, Let me know if you need any more details on these.

Reward Points if you find them useful.

Former Member
0 Kudos


For eg: you cannot use a pooled or cluster table like BSEG in an inner join query.

For this, we first select the entries from this table into an internal table and then

write another select query using FOR ALL ENTRIES to select the desired matching entries from another table.

The internal table should have atleast one entry before it is used in the "for all entries" query.

Check this: for type and like.



Former Member
0 Kudos

Hi deepak,

1. U can join 2 tables by using joins but the performance goes down. This can be overcomed by for all entries.

select-options : s_vbeln for likp-vbeln.

select vbeln erdat lfart

from likp

into table it_likp

where vbeln in s_vbeln.

based on s_vbeln the records will be stored in it_likp. eg, say 24 records selected

if not it_likp[] is initial.

select vbeln posnr matnr

from lips

into table it_lips

for all entries in it_likp

where vbeln eq it_likp-vbeln.


now , since i am using,

for all entries in it_likp

so the vbeln value of these 24 records (which i have selected in it_likp) will be checked in lips and those records will be stored in it_lips.

Drawback is if the records are not there in it_likp then all the records from lips will be fetched into it_lips.

To overcome this draw back we have to compulsory check

if not it_likp[] is initial.

this means if the internal table it_likp is not initial ie, it is containing some records

2. check this link for difference between type and like

Former Member
0 Kudos

Hi Deepak,

1)Select for all entries

If you need to retreive all the related data for the records of one internal table, You can use for all entries.

For example, You have an internal table ITAB with 8 records (let us say customers). You may need the related information for all these customers let us say the tax categories, then instead of writing 8 selects, you may just select the tax categories for all entries in itab where customer = itab-customer. This way you will be able to retreive the data pertaining to the customer records of the table itab.

Please donot forget to check for the records in the table before using for all entries. i.e if not itab[] is initial --- then only retreive the related data.

Single select will be used if you have the complete key of the table and you are retreiving single record.

UPTO one rows will be used, when you need a single record from the DB table and you donot have the complete key with you.

2)Diff bn TYPE N LIKE.

Go through the link.