2007 Jul 11 10:19 AM
2007 Jul 11 11:08 AM
Hi
see the doc
DATA - TYPE, LIKE
Syntax
DATA var { {TYPE [LINE OF] type}
| {LIKE [LINE OF] dobj} }
[VALUE val|{IS INITIAL}]
[READ-ONLY].
Effect
In the specification of a data type type or a data object dobj, the data type of the variable var is already fully defined before the declaration. The syntax and meaning of the additions TYPE and LIKE has exactly the same meaning as the definition of data types with TYPES, except that for DATA after TYPE a standard table type with a generic table key can be specified. In this case, a bound table type with a standard key is created.
Prior to Release 6.10, no VALUE addition was possible if the data type deep, specified using TYPE or LIKE, was a string, a reference type, a table type, or a structured type with deep components. As of Release 6.10, the VALUE addition can also be used for deep data types; however, with the limitation that a start value val can only be specified for the ABAP type string, and otherwise only IS INITIAL.
Example
These statements define two data objects, both of which have the same data type as the database table spfli.
DATA: spfli_wa1 TYPE spfli,
spfli_wa2 LIKE spfli_wa1.
<b>Reward points for useful Answers</b>
Regards
Anji
2007 Jul 11 12:05 PM
<b>There is a conceptual difference between the TYPE keyword and LIKE keyword.
One the first hand TYPE indicates the variable type (like that of a valid type). When using TYPE, the length of the field is specified as part of the name. That means using TYPE we are defining the variable attributes internally in the program.
exp. NEW_BUKRS(4) TYPE C, defines variable NEW_BUKRS as a character field of 4 bytes.
Whereas defining variables using LIKE keywords we attain the attributes from a field defined in the data dictionary. Using LIKE keyword, if the table field referenced is modified, the change is also effected to the program variables. Simultaneously other benefits are also there,
1)F1 help is aquired from the documentation button in the data element.
2)F4 help is aquired if parameter is like one that has a check table.
3)A field label is aquired from the data element.</b>
2007 Jul 11 2:49 PM
After LIKE, you must specify a data object directly. For the casting, the data type of the data object is used. Within a procedure, for dobj you must not specify a completely generically typed formal parameter.
After TYPE, you can specify either a data type type directly or a character-type data object name in brackets, which must, during execution, contain the label of a data object. The data type specified after TYPE can be generic. However, you cannot specify table types or REF TO.
2007 Jul 12 12:54 PM
Hi Ravi,
<b>TYPE</b>
You use the TYPE addition in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The TYPE addition can have various meanings depending on the syntax and context.
<b>LIKE</b>
You use the LIKE addition, similarly to the TYP E addition , in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The addition
<b>LIKE <obj></b>
can be used in the same ABAP statements as the TYPE addition to refer to any data object <obj> that is already visible at that point in the program. The expression <obj> is either the name of the data object or the expression.
You use LIKE to make the new object or type inherit the technical attributes of an existing data object.
<b>FOR</b>
We use FOR statement for processing the selection table
<b>Reward pts if usefull :)</b>
Regards
Sathish