2015 Dec 23 8:37 AM
Hello!
I found this declaration in a method (part of a Web Dynpro, but that souldn't matter here):
DATA lv_sysid TYPE sy-sysid.
In the ABAP basic course, I learned that I can use DATA ... TYPE in combination with a type or DATA .... LIKE in combination with an existing data object.
From my understanding, sy-sysid is a data object, so why can it be used in combination with DATA ... TYPE? Shouldn't it be DATA lv_sysid LIKE sy-sysid?
Best regards
Jan
2015 Dec 23 10:12 AM
Your question makes perfect sense!
In a better world, there would be the dictionary structure SYST and the ABAP data object SY and it would be
TYPE SYST-SYSID
LIKE SY-SYSID
and nothing else.
Alas, and as documented, in ABAP, SYST as well as SY are both built-in types and objects and you can mix TYPE and LIKE as you will .
Horst
2015 Dec 23 9:40 AM
Hi Jan,
We use Like only against DATA OBJECTS & data objects inturn are created with respect to elementary data types or dictionary data types.
e.g:
DATA: data_obj type data_type.
DATA: DATA_another_obj like data_obj (Valid)
or
DATA: DATA_another_obj type data_type is also valid.
In your example,
DATA lv_sysid TYPE sy-sysid is perfect as the created object/variable lv_sysid is of type SYSID of the dictionary structure SYST, base type of the variable lv_sysid will be character with length 8
Hope this explains your query!
Feel free to add further questions.
---BR----
Tapomay
2015 Dec 23 9:56 AM
Thank you, Tapomay
I was a bit confused because sy-sysid can also contain a value, which I thought is specific for a object/variable. Seems that sy-sysid is both - a type and a data object.
Best regards
Jan
2015 Dec 23 10:12 AM
Your question makes perfect sense!
In a better world, there would be the dictionary structure SYST and the ABAP data object SY and it would be
TYPE SYST-SYSID
LIKE SY-SYSID
and nothing else.
Alas, and as documented, in ABAP, SYST as well as SY are both built-in types and objects and you can mix TYPE and LIKE as you will .
Horst
2015 Dec 23 11:26 AM
2015 Dec 23 10:26 AM