2006 Nov 24 12:34 PM
Hi, sdn exports,
1) what is diff b/w for all entries and corresponding fields?
Hi, sdn exports,
1) what is diff b/w for all entries and corresponding fields?
2006 Nov 24 12:42 PM
Hi Sudharsan,
Corresponding fileds clause is used to move the data from source to target which fields are having similiar names.
data: begin of wa_mara,
matnr type matnr,
ekgrp type ekgrp,
maktl type maktl,
end of wa_mara.
select *
from mara
into corresponding fields wa_mara.In above example the MARA table and WA_MARA is not in sync i.e MARA having 100 more fields. So, here corresponding clause required to move the data to similiar fileds in the workarea
For all entries clause is used to select the data for each entry in particular fileds.
select *
from mara
into table t_mara.
select *
from makt
into table t_makt
for all entries in t_mara
where matnr eq t_mara-matnr.Here first select statement will retrieve all the records in MARA. The second select statement will retrieve the data from MAKT for only exist entries in MARA.
if it helps plz reward points.
Regards
Bhupal Reddy
2006 Nov 24 12:42 PM
hi sudharshan,
check this from help...
FOR ALL ENTRIES...
Syntax
... [FOR ALL ENTRIES IN itab] WHERE sql_cond ... .
Effect:
The addition WHERE restricts the number of lines included in the result set by the statement SELECT, by using a logical expression sql_cond. The logical expression compares the content of columns in the database with the content of ABAP data objects, or with the content of other columns. You can use the optional addition FOR ALL ENTRIES to compare the content of a column in the database with a component with all lines of a structured internal table itab.
The logical expression sql_cond is either true, false, or unknown. The expression is unknown if one of the columns involved in the database contains a null value and is evaluated with another comparison as IS NULL. A line is only included in the resulting set if the logical expression is true.
Except for columns of type STRING or RAWSTRING, all columns of the database tables or views listed after FROM can be evaluated after the WHERE condition. The columns do not necessarily have to be a part of the resulting set.
<b>CORRESPONDING FIELDS...</b>
... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab [PACKAGE SIZE n]
Effect
target specifies which data objects the result set of a SELECT or FETCH statement is assigned to. You can either specify a single work area wa or a list of data objects dobj1, dobj2 ... after INTO, or you can specify an internal table itab after INTO or APPENDING. If the result set is empty, the objects remain unchanged.
If the result set consists of multiple lines, an internal table itab of any table type can be specified after INTO or APPENDING. The row type of the internal table must meet the prerequisites.
The result set is inserted into the internal table itab line-by-line; a sorting process is executed in the case of a sorted table. If INTO is used, the internal table is initialized before the first line is inserted. Previous lines remain intact if APPENDING is used.
Before any assignment of a line of the result set, an initial row of the internal table itab is created and the line of the result set is assigned to this row. When assigning a line of the result set to a row of the internal table with or without CORRESPONDING FIELDS, the same rules apply as when assigning to an individual work area wa (see above).
If the PACKAGE SIZE addition is not used, all lines of the result set are inserted in the internal table itab and the ENDSELECT statement must not be specified after SELECT.
If you specify the PACKAGE SIZE addition, all lines of the result set are processed in a loop, which must be closed with ENDSELECT. The lines are inserted in the internal table itab in packages of n lines. n must be a type i data object that contains the number of lines. If the value of n is smaller than 0, an exception that cannot be handled occurs. If n is equal to 0, all lines of the result set are inserted in the internal table itab.
If INTO is used, the internal table is initialized before each loop pass and, in the SELECT loop, it only contains the lines of thecurrent package. If APPENDING is used, a further package is added to the existing rows of the internal table in each SELECT loop.
After ENDSELECT, the contents of itab is not defined if INTO is used - that is, the table can either contain the lines of the last package or it can be initial. If APPENDING is used, the content of itab retains the state of the last loop pass.
https://forums.sdn.sap.com///click.jspa?searchID=171994&messageID=2288398
do reward if it helps,
regards,
priya.
2006 Nov 24 12:44 PM
Hi,
For all entries is alternate mathod for JOINS.
if i have one table say itab with field matnr,now i want to know basing on matnr ,i want plant .
then i will use for all entries of itab, like this.
if not itab[] is iniyial.
select werks from marc into table itab1
for all entries in itab
where matnr = itab-matnr.
endif.
Now we will get the plant details for the matnrs.....
corrsponding fields in the sense we are going to move data to a table to the respective fields.
Regards,
Nagaraj
2006 Nov 24 12:54 PM
Hi sudharsan,
1. Actually there is no similarity, the functinality of both is entirely
different.
2. into corresponding fields,
puts the data in the internal table
WHOSE FIELD NAMES MATCH.
3. For all entries,
is JUST LIKE WHERE CONDITION,
where we specify another internal table for Where Matching.
regards,
amit m.
2006 Nov 24 12:55 PM
Hi,
FOR ALL ENTRIES...
restricts the number of lines included in the result set by the statement SELECT, by using a logical expression sql_cond. The logical expression compares the content of columns in the database with the content of ABAP data objects, or with the content of other columns.
The logical expression sql_cond is either true, false, or unknown. The expression is unknown if one of the columns involved in the database contains a null value and is evaluated with another comparison as IS NULL. A line is only included in the resulting set if the logical expression is true.
CORRESPONDING FIELDS...
Before any assignment of a line of the result set, an initial row of the internal table itab is created and the line of the result set is assigned to this row. When assigning a line of the result set to a row of the internal table with or without CORRESPONDING FIELDS,
<b>See, if when you are declaring your structure or type, In declaration part. Choosen the fields, in that order only in select then no need for any Corresponding, Because, it reduces the performance.</b>Cheers,
Manju.
Help ful reward
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |