12-18-2006 4:38 AM
Hi experts,
i would like to know the use of 'For all entries statement' . Kindly give me one
example.
Thanks in advance
Reg
R.Vijaya Kumar
12-18-2006 4:40 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.
*******************************8
look another example
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.
Hope this helps!
Regards,
ANver
12-18-2006 4:40 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.
*******************************8
look another example
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.
Hope this helps!
Regards,
ANver
12-18-2006 4:57 AM
Thanks Anwar,
shall you give me the use of 'On Change of ' statement with one example.
Reg
R.Vijaya kumar
12-18-2006 5:05 AM
hi vijay,
Dont Use ON CHANGE OF
it is obsolute now.
so use AT-NEW
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/frameset.htm
Regards
Anver
12-18-2006 4:42 AM
Hi ,
For all entries is used to select data based on data in an internal table.
an eg. would be
Select matnr maktx
from makt
into table it_maktx
for all entreis in it_mara
where matnr = it_mara-matnr and
spars = sy-langu.
Onc basic thing to remember while using for all entries is that you must make sure that the internal table has values , else the select statement will select all the records from the table which satisfy the other conditions , thus becomming a performace issue.
Regards
Arun
12-18-2006 4:43 AM
Hi
Let us assume you are checking out Sales Order Header Data
SELECt * from vbak into table it_vbak where <cond>
Now for the line items
SELECT * from vbap into table it_vbap
FOR all entries in it_vbak
where vbeln = it_vbak-vbeln and <cond>.
Make sure u check it_vbak is not nitial before you use it in the second SELECT statement. If it_vbak where to be empty the second SELECT would retrieve all entries from VBAP
Regards
Deepak
12-18-2006 9:44 AM
parameters: s_matnr type matnr.
data: itab like mara occurs 1 with header line,
itba1 like makt occurs 1 with header line.
select * from mara into table itab where matnr in matnr.
select * from makt for all entries in table itab into itab2.
In the second select statement the selection will be restricted to the entries in the first select statement. Also we dont need to check with selection screen matnr, Bz In the first select statement we checked the condition.
Cheers.