10-04-2006 6:17 AM
Hi Friend,
Pls tell me when we will use FOR ALL ENTRIES.
THANX IN ADVANCE
Regards,
Parvez
10-04-2006 6:23 AM
Hi pervez,
what is the use of FOR ALL ENTRIES
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
*----
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*----
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
*----
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
*----
LOOP AT t001.
WRITE 😕 t001-bukrs.
ENDLOOP.
regards,
amit m.
10-04-2006 6:23 AM
hi,
FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
You can check the below code -
SELECT BUKRS BELNR GJAHR AUGDT
FROM BSEG
INTO TABLE I_BSEG
WHERE BUKRS = ....
SELECT BUKRS BELNR BLART BLDAT
FROM BKPF
INTO TABLE I_BKPF
FOR ALL ENTRIES IN I_BSEG
WHERE BUKRS = I_BSEG-BUKRS
AND BELNR = I_BSEG-BELNR
AND BLDAT IN SO_BLDAT.
Hope this helps!
Regards,
anver
if helped amrk points
10-04-2006 6:23 AM
Hi pervez,
what is the use of FOR ALL ENTRIES
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
*----
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*----
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
*----
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
*----
LOOP AT t001.
WRITE 😕 t001-bukrs.
ENDLOOP.
regards,
amit m.
10-04-2006 6:25 AM
Lets say u have data in itnernal table......1000 lines...
now u want to select data from a databse table based on the values of any field of that internal table.
select * from mara into table t1
for all entries in internal_table
where plant = internal_table-plant.
now this will select data from databse table MARA into internl table t1 for all the values of the plant in internal_table.