Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

why type?

Former Member
0 Kudos

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?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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

Former Member