Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

why type?

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?

Tags:
Former Member
Former Member replied

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

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question