2007 Jul 19 12:21 PM
When <u>INTO CORRESPONDING FIELDS OF</u> is used in a select statement?
When <u>INTO CORRESPONDING FIELDS OF</u> is used in a select statement?
2007 Jul 19 12:23 PM
Hi,
INTO CORRESPONDING FIELDS OF TABLE is transferring the value from select clause to itab where the field names are same.
suppose you have
data : begin of itab occurs 0,
matnr like mara-matnr,
menge like mseg-menge,
lgort like mard-lgort,
end of itab.
select matnr lgort into table from mard where....
it may give an error because you are not filling menge here or it may fetch the value in matnr and menge field.
but if you use INTO CORRESPONDING FIELDS OF TABLE then it will fetch the data to matnr and lgort field only.
INTO CORRESPONDING FIELDS OF TABLE is only matching by name not by datatype be careful.
reward points if it helps,
Regards,
Omkar.
2007 Jul 19 12:23 PM
Hi,
INTO CORRESPONDING FIELDS OF TABLE is transferring the value from select clause to itab where the field names are same.
suppose you have
data : begin of itab occurs 0,
matnr like mara-matnr,
menge like mseg-menge,
lgort like mard-lgort,
end of itab.
select matnr lgort into table from mard where....
it may give an error because you are not filling menge here or it may fetch the value in matnr and menge field.
but if you use INTO CORRESPONDING FIELDS OF TABLE then it will fetch the data to matnr and lgort field only.
INTO CORRESPONDING FIELDS OF TABLE is only matching by name not by datatype be careful.
Thanks.
2007 Jul 19 12:24 PM
Hi!
If your internal table has NOT the same structure as the ddic table you are selecting from, but it has the SAME FIELDNAMES, then you have to use the INTO CORRESPONDING FIELDS OF statement.
Regards
Tamá
2007 Jul 19 12:24 PM
Hi,
in this below kind of internal table declaration we will use "into corresponding fields of table" to fill the data from database table
data:begin of itab occurs 0,
matnr like mara-matnr,
mbrsh type mara-mbrsh,
ersda type mara-ersda,
end of itab.
select * from mara into corresponding fields of table itab.
loop at itab.
write:/ itab-matnr,itab-mbrsh,itab-ersda.
endloop.
rgds,
bharat.
2007 Jul 19 12:24 PM
hi,
1.- Change the declaration of the Itab as a type table of Dbtab.
Ex: data: t_xxx type table of xxx (with header line).
2- If the the fields of both tables have the same you can use
Ex: select * INTO CORRESPONDING FIELDS....
3- Use the statement:
Select a b c into ( a b c ) from xxx into table t_xx where...
2007 Jul 19 12:27 PM
HI
The INTO clause defines the target area into which the selection from the SELECT clause is written. Suitable target areas are variables whose data type is compatible with or convertible into that of the selection in the SELECT clause.
The SELECT clause determines the data type of the target area as follows:
· The linesspecification in the SELECT clause determines the depth of the target area, that is, whether it is a flat or a tabular structure.
· The colsspecification in the SELECT clause determines the structure (line type) of the target area.
To read data into one, use the following in the INTO clause
The target area wa must be at least as large as the line to be read into it. When you read the data into wa, its previous contents are overwritten. However, the components of wa that are not affected by the SELECTstatement retain their previous values.
If the work area is structured, you can use the CORRESPONDING FIELDS addition. This transfers only the contents of fields whose names are identical in the database table and the work area. This includes any alias column names that you specified in the selection.
Reward all helpfull answers
Regards
Pavan
2007 Jul 19 12:25 PM
Hi,
When you dont know the order of selecting fields order is same with the order of feilds in internal table.
this command will automatically put the data into corresponding fields
reward if helpful
Regards
Azad.
2007 Jul 19 12:25 PM
Hi,
This is used in those select queries where you are selecting some fields from a databse table into an internal table which has some fields other than what you have selected from the database.
It is used to differentiate the fields of an internal table so that the correct fields get populated from the field values of the database fetch.
Thanks,
Sandeep.
2007 Jul 19 12:26 PM
Hi,
When u have large no. of fields with large no. of records then sequence of fields is not known to map these sequence u have to use,
select * from mara into corresponding fields of table itab where .... .
pls reward points.
Regards,
Ameet
2007 Jul 19 12:28 PM
Hi Debarshi,
When use to select table fields in the different order from a table, then we will use corresponding fields of but the field what ever u have named in the local internal table should match the fieldname of the table .
MATNR MATNR CHAR 18 0 Material Number
ERSDA ERSDA DATS 8 0 Created On
ERNAM ERNAM CHAR 12 0 Name of Person who LAEDA LAEDA DATS 8 0 Date of Last Change
egdata : begin of itab occurs 0,
matnr type matnr,
Ernam type Ernam,
Ersda type ersda,
end of itab.
select matnr ernam ersda into corresponding fields of table itab.
<b>Reward pts for usefull answers :)</b>
regards
sathish
2007 Jul 19 12:31 PM
Hi
TABLES: MARA.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATNR,
MAKTX LIKE MAKT-MAKTX,
BRGEW LIKE MARA-BRGEW,
END OF ITAB.
*
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 10 ROWS.
*
LOOP AT ITAB.
WRITE: / ITAB-MATNR, ITAB-MATKL, ITAB-MAKTX, ITAB-BRGEW.
ENDLOOP.
you can see that maktx is not filled, it does'n correspond to mara.
Regards, Dieter
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |