11-17-2007 9:57 AM
Please refer to the following link
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
& please find the following code at the beginning of the program
REPORT DEMO.
DATA: SUM TYPE I, CNT TYPE I.
NODES: SPFLI, SFLIGHT, SBOOK.
DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
TAB_SFLIGHT TYPE TABLE OF SFLIGHT,
TAB_SBOOK TYPE TABLE OF SBOOK.
Q] M y question is that why instead of "LIKE" we are using"TYPE" here?
11-17-2007 10:07 AM
The basic difference between TYPE and LIKE
- When you want to create a data object referring to a data type then you use TYPE
- When you want to create a data object referring to an already existing data object then you use LIKE
This could be understood well with the following analogy:
You can say "Saurav is rich" or you can say "Saurav is LIKE Bill Gates". In the first statement you are referring to a TYPE (Rich) whereas in the second statement you are refferring to an already existing (Rich Person)
<b>
Refer here for technical attribute.</b>
Now when you only want the technical attribute of SPFLI-CARRID that is say NUMC of length 10 then you create a variable using TYPE. When you want to use the details like field formatting/ field labels etc then you create a variable using LIKE.
In your example VAR TYPE SPFLI-CARRID, this means VAR is a variable with NUMC as type and length 10. VAR LIKE SPFLI-CARRID means VAR is a variable with NUMC as type and length 10 and the field format and labels exactly same as that of the field SPFLI-CARRID.
Thanks.
Sakthi.C
11-17-2007 10:07 AM
The basic difference between TYPE and LIKE
- When you want to create a data object referring to a data type then you use TYPE
- When you want to create a data object referring to an already existing data object then you use LIKE
This could be understood well with the following analogy:
You can say "Saurav is rich" or you can say "Saurav is LIKE Bill Gates". In the first statement you are referring to a TYPE (Rich) whereas in the second statement you are refferring to an already existing (Rich Person)
<b>
Refer here for technical attribute.</b>
Now when you only want the technical attribute of SPFLI-CARRID that is say NUMC of length 10 then you create a variable using TYPE. When you want to use the details like field formatting/ field labels etc then you create a variable using LIKE.
In your example VAR TYPE SPFLI-CARRID, this means VAR is a variable with NUMC as type and length 10. VAR LIKE SPFLI-CARRID means VAR is a variable with NUMC as type and length 10 and the field format and labels exactly same as that of the field SPFLI-CARRID.
Thanks.
Sakthi.C
11-17-2007 10:16 AM
Hi Learner,
Read this page
http://help.sap.com/saphelp_47x200/helpdata/en/9b/239fa610de11d295390000e8353423/content.htm
Regards,
Satish