Application Development and Automation 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: 
Read only

Difference B/W

Former Member
0 Likes
608

1) DATA BEGIN OF struc [READ-ONLY].

...

{DATA comp ...} | {INCLUDE {TYPE|STRUCTURE} ...}.

...

DATA END OF struc.

2) TYPES BEGIN OF struc_type.

...

{TYPES dtype ...} | {INCLUDE {TYPE|STRUCTURE} ...}.

...

TYPES END OF struc_type.

Please let me know what is difference b/w there 2 decleartion excep memory allocation .

Regards

Ajay

5 REPLIES 5
Read only

Former Member
0 Likes
566

type refers to the dataelement of field only where as in first declaration attributes are also copied of that field.so type is better for future enhancement of data elements.

reward if useful plz........

vivek

Read only

Former Member
0 Likes
566

Hi Ajay,

The first syntax would create a Structure for you in which you can hold a collection of many fields.

The second one shall allow you to create a local Structure Type which you can use further to define any structure. You cannot directly use this Structure Type to hold any values. You need to define one more structure based on this type.

For ex:

TYPES: BEGIN OF YSTRU,

MATNR TYPE MATNR,

MATKX TYPE MATKX,

END OF YSTRU.

DATA STRU1 TYPE YSTRU.

Now STRU1 is a structure of type YSTRU.

Hence by using TYPES you shall have reusability of the local structure.. You need not define it multiple times for multiple structures with the same definition.

Reward points if this clarifies your doubt,

Kiran

Read only

Former Member
0 Likes
566

Hi,

If you are declaring any sturcture using types then no memory space is allocated for that. If you are using DATA statement then the memory space is allocated to that structure depends on size of all the fields.

Rgds,

Bujji

Read only

Former Member
0 Likes
566

types: a user-defined type can be based on th edefination of a afield string . this is known as Structured type. using these types can reduce and make maintenance easier.

data:a field string defined using the data statement is a modifiable data object.

include statemnt is not part of the data statemnt. it is a separete statent.

therefore it cannot be chained to a data statement.

reward if its useful

Read only

Former Member
0 Likes
566

Hi Ajay Pandey ,

These 2 are different syntaxs of internal table declaration i.e

The first declaration is WITH HEADER LINE declaration. Here u can INCLUDE or APPEND SAP standard or user-defined structure (set of fields) created by u in SE11. This is performance wise not good.

The second declaration is WITHOUT HEADER LINE declaration i.e how many fields u want to use according to u'r requirement, those many fields u can declare in a structure by using TYPES:BEGIN OF ......END OF ........it is perfromance wise good.

cheers!

gyanaraj

****Pls reward points if u find this helpful