2007 Feb 07 5:23 AM
Hi,
I have a question on TYPE...
what TYPE offer that LIKE does't ?
can we use LIKE any where where TYPE is used?
Thanks & Regards
Mahesh.
2007 Feb 07 5:31 AM
Hi,
TYPE - Type is used to tell the system what is the type of data object(variable) you want to create .
LIKE: If there is already a data object declared and you want to declare a similar data object you can just refer to the previous data object using like.
Check this thread.
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=2270752
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=512214
Thanks,
Shankar
Hi,
I have a question on TYPE...
what TYPE offer that LIKE does't ?
can we use LIKE any where where TYPE is used?
Thanks & Regards
Mahesh.
2007 Feb 07 5:27 AM
Hi,
You can data element using type statement..But you cannot use data element in LIKE statement..You cannot use table type created in ddic..
<b>You cannot use</b>
DATA: V_MATNR LIKE MATNR.
DATA: V_TABLETYPE LIKE BSEG_T.
<b>Can be used.</b>
DATA: V_MATNR TYPE MATNR.
DATA: V_TABLETYPE TYPE BSEG_T.
Thanks,
Naren
2007 Feb 07 5:32 AM
Hi Naren,
Thanks for ur reply,
Can U explain at Memory level how these two works? (LIKE and TYPE)
Thanks and Regards
Mahesh.
2007 Feb 07 5:28 AM
hi
type is used for data types defined in dictionary and like is used to refer to data type of variable already defined in program.
2007 Feb 07 5:28 AM
2007 Feb 07 5:30 AM
Hi
DATA - TYPE, LIKE
Syntax
DATA dobj { {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 dobj 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.
regards
Shiva
2007 Feb 07 5:31 AM
Hi,
TYPE - Type is used to tell the system what is the type of data object(variable) you want to create .
LIKE: If there is already a data object declared and you want to declare a similar data object you can just refer to the previous data object using like.
Check this thread.
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=2270752
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=512214
Thanks,
Shankar
2007 Feb 07 5:32 AM
Hi..
TYPE can be used in place of like..
Please see these examples..
DATA : t TYPE kna1-kunnr. " correct
DATA : r LIKE kna1-kunnr. " correct
DATA : l_var TYPE c. " correct
DATA : y_var LIKE c. "error..
DATA : u_var LIKE l_var. " correct
I declred u_var as a LIKE of l_var..I
but l_var is initilly a TYPE of C..
So.. u can use LIKE when u r declaring it against a type data that is already existing..
Hope its clear..
Mark if useful
Rajiv
2007 Feb 07 5:33 AM
HI Mahesh,
You use the TYPE addition in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols.
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
Definition of local program types using
TYPES <t> TYPE <type>.
Definition of local types in a program using
TYPES <t> LIKE <obj>.
Regards
Sudheer
2007 Feb 07 5:34 AM
HI Mahesh ,
DATA dobj { {TYPE [LINE OF] type}
| {LIKE [LINE OF] dobj} }
In the specification of a data type type or a data object dobj, the data type of the variable dobj 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.
I hope this solcves ur problem
Note: rewrad if useful
2007 Feb 07 6:02 AM
Hi,
Type is Abstract description of an object. Either a data type for a data object or an object type for an object inABAP Objects. The corresponding generic data type is any. Wont occupy any memory at the time declaration.
But Like refers to the existing data object. Occupy memory according to the referred data object.
Regards,
U. Uma
2007 Feb 07 6:11 AM
Hi Uma,
Thanks for Ur reply.
Is memory of a variable declared with LIKE changes according to the change made to the refering one?
Thanks and Regards
Mahesh.
2007 Feb 07 6:50 AM
Hi mahesh,
1.Is memory of a variable declared with LIKE changes according to the change made to the refering one
Absolutely NO.
2. LIKE only specifies information for data type, length etc.
3. The memory of that variable is its own memory, and is independent
of other variables/memory.
regards,
amit m.
2007 Feb 07 12:56 PM
2007 Feb 07 2:02 PM
Thanks all ...
Thanks for your valuble suggestion..
Thanks and Regards
Mahesh.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |