‎2011 Feb 09 4:32 AM
Dear All,
When learning abap i encountered a strange situation . Consider the program below.
Report ztest.
data : BEGIN OF stru,
du type c LENGTH 10,
du2 type c LENGTH 12,
END OF stru.
data stru1 type stru.
stru-du = '12345678'.
stru-du2 = '9999999'.
stru1 = stru.
If i put breakpoint and look at the data type of stru1 it is N(10) and the absolute type(?) is '\TYPE=STRU' the value in stru1 is '6789999999' . Can anyone pls explain why data type of stru1 is N(10) .I am aware that like should have been used if i wanted stru1 data type similar to that of stru.
Thanks,
Kiran A.
‎2011 Feb 09 5:27 AM
Hello Kiran,
DATA : BEGIN OF stru,
du TYPE c LENGTH 10,
du2 TYPE c LENGTH 12,
END OF stru.
data stru1 type stru.
here stru1 is defined from standard data element (STRU) Structure Description, not from your structure declaration of stru,
if you want to do so you need to declare using TYPES not data, then your code will go like this,
types : BEGIN OF stru,
du TYPE c LENGTH 10,
du2 TYPE c LENGTH 12,
END OF stru.
DATA stru1 TYPE stru.
DATA stru2 TYPE stru.
stru1-du = '12345678'.
stru1-du2 = '9999999'.
stru2 = stru1.
thanks,
Swanand Paranjape.
‎2011 Feb 09 5:27 AM
Hello Kiran,
DATA : BEGIN OF stru,
du TYPE c LENGTH 10,
du2 TYPE c LENGTH 12,
END OF stru.
data stru1 type stru.
here stru1 is defined from standard data element (STRU) Structure Description, not from your structure declaration of stru,
if you want to do so you need to declare using TYPES not data, then your code will go like this,
types : BEGIN OF stru,
du TYPE c LENGTH 10,
du2 TYPE c LENGTH 12,
END OF stru.
DATA stru1 TYPE stru.
DATA stru2 TYPE stru.
stru1-du = '12345678'.
stru1-du2 = '9999999'.
stru2 = stru1.
thanks,
Swanand Paranjape.
‎2011 Feb 09 5:30 AM
Hi Akiran,
There is already a built-in type stru in SAP system whose datatype is NUMC(10).You can check it by TCode SE11 and select the radio button and write stru in the DATA TYPE field.
For that reason when you are defining stru1 TYPE stru the stru1 is created with datatype numc(10) or N(10) as technical type.Instead of that you declare DATA:stru1 LIKE stru.
Regards,
Suvajit.
‎2011 Feb 09 5:33 AM