2007 Mar 08 10:20 AM
2007 Mar 08 10:25 AM
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.
regards
shiba dutta
why we use INTO CORRESPONDING FIELDS OF TABLE
2007 Mar 08 10:22 AM
We use INTO CORRESPONDING FIELDS INTO TABLE ...
to populate the selected data into the fields with similar name that is there in the actual table structure. If the order of the fields in the table structure and the order u r selecting in a select statement is different and if u r not using corresponding fields, uwill get runtime error.
If u use INTO CORRESPONDING FIELDS OF TABLE it will not trigger runtime error . it just copies the data into internal table by comparing the names of the fields...
reward helpful answers...
sai ramesh
2007 Mar 08 10:24 AM
It is used in the case when your internal table in which you are populating the data having more number or in different order of fields than the table from where you are fetching the data.
data : begin of itab occurs 0,
include structure mara.
data : end of itab.
select matnr mktxt from mara into corresponding fields of table itab
from mara
where conditions.
Here if you will not use into corresponding fields of table you will not get the correct result
2007 Mar 08 10:24 AM
INTO CORRESPONDING FIELDS OF TABLE is very inefficient. It is much better to set up the internal table with the same structure as the database table and use INTO TABLE.
2007 Mar 08 10:25 AM
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.
regards
shiba dutta
2007 Mar 08 10:26 AM
Hi Shailendra,
Actually we use INTO CORRESPONDING FIELDS OF TABLE to map exactly the fields of our internal table with the exact fields of the database table and avoid reduced performance.
We can also go without this into corresponding syntax but performance decreases without this as all the fields are checked for the mapping. So We go for this syntax.
Hope this resolves ur query.
Reward if helpful.
Regards.
2007 Mar 08 10:27 AM
HI ,
IF U R TABLE HAS FIELDS WHICH ARE NOT IN THE ORDER IN THE ACTUAL D/B TABLE AND IF U R TABLE HAS FIELDS FROM DIFFERENT D/B TABLES THEN U USE CORRESPONDING...
EG
TYPES: BEGIN OF GS_ITAB,
MATNR TYPE MARA-MATNR,
MATKL TYPE MARA-MATKL,
END OF GS_ITAB.
DATA : ITAB TYPE TABLE OF GS_ITAB.
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE...
2007 Mar 08 10:27 AM
Hi,
If the fields you are selecting from tables is not in the same order as it is in table,then this is needed.
If the no. of fields you are selecting is less than the no. of fields in the table,then also it is needed.
2007 Mar 08 10:34 AM
Hi
If the target structure has less number of fields than selected from the database ,
its recommended to use INTO CORRESPONDING FIELDS, by this field having the same data type goes into the correct target fields , otherwise it will cause dump .
Its always good the select the number of fields in the target area in your select statement .
Thanks .
2007 Mar 08 10:36 AM
hi......
Instead of using INTO in selecting data its better to use INTO CORRESPONDING FIELDS OF TABLE if the internal table has different line type as database table but similar fields.....
while retrieving from data base through INTO statement it will assume that the table has same line type/structure of database table...but if the structure is not same it will goto dump.In such cases it is better to use INTO CORRESPONDING FIELDS OF TABLE.in this case data will be retrieved into the fields by searching the names of the internal table...........
with regards
jay
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |