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

STRUCTURE

Former Member
0 Likes
1,119

Why is the difference between

TYPES:begin of ty_bseg,

bukrs type bseg-bukrs,

belnr type bseg-belnr,

gjahr type bseg-gjahr,

end of ty_bseg.

AND

DATA:begin of it_bseg,

bukrs type bseg-bukrs,

belnr type bseg-belnr,

gjahr type bseg-gjahr,

end of it_bseg.

With regards

Vijay

8 REPLIES 8
Read only

Former Member
0 Likes
1,070

Hi

The basic difference between Types and DATA statement is

Types only define the data type of any structure

DATA define type and also allocate the memory for that structure.

Regards

Aditya

Read only

Former Member
0 Likes
1,070

Hi vijay,

Difference is very simple.

1.When you declare using 'Types' only one type will create no memory will allocate for the same.

2.If you are using DATA it will allocate memory for the same.

3.if you want to use the same structure repeatedly you can create one type using TYPES statement .

regards

shibu

Read only

Former Member
0 Likes
1,070

Hi Vijay

Using TYPE u have declared only structure and not work area or body.

Using DATA statement u have declared a STRUCTURE with WORK AREA and not BODY.

Regards

Lakshman

Read only

Former Member
0 Likes
1,070

Hi..,

When u create itab with DATA ,, the initial memory will be allocated for the internal table ...( Here the object is created )

But when with TYPES no memory will be created !!!( Here the object is not yet created, it just stores the type of the table..thats it )..

again u need to define a table with DATA statement of this TYPE.

Try this simple code..

*************

data w_value type i.

w_value = 2.

*************

types w_value type i.

w_value = 2.

*************

The first case is correct .. because w_value is a variable which has some memory and can store a value !!

But the second case gives an error !!! because w_value doesnot have any memory !!! its type is just created , not the object..

i hope u understood !!

reward points

Regards,

pankaj

Read only

0 Likes
1,070

Hi,

TYPES: BEGIN OF structype,

...

END OF structype.

Defines the structured type structype, where all of the fields defined between " BEGIN OF structype" and "ENDOFstructype" are components of type structype. You can address individual components of the type using the prefix "structype-",

DATA: BEGIN OF struc [READ-ONLY],

...

END OF struc.

The structured field struc is defined, and all of the fields defined between " BEGIN OF struc" and "END OF struc" are combined into the structure struc. The field names are always prefixed by "struc-". You can nest structured fields to any depth .

You can also declare structured fields with reference to existing structures using the TYPE and LIKE additions.

If, for a structured field, you require components of a predefined structure as well as your own components, you can use INCLUDE STRUCTURE to include them.

Regards,

Sreekanth.G

Read only

Former Member
0 Likes
1,070

Hi

types -


this is only to declare the structure ,it doesnt allocate any memory.

data-----this wil allocate memory at runtime.

Read only

Former Member
0 Likes
1,070

s

Read only

Former Member
0 Likes
1,070

hi

1) consider for example: u need to create an employee. wat does it mean, u r creating attributes like name, age, salary etc. but in real world no one exist as employee.

for the attributes mentioned above u can enter data, example: kavi , 22 , 40000.

if u use DATA for each entry like this u have to declare data, instead if u use types u can refer to these types and create several entries.

here u r creating entries for the above mentioned structure.

2) types: no memory

data: memory at runtime

3)Using TYPE u have declared only structure and not work area or body.Using DATA statement u have declared a STRUCTURE with WORK AREA and not BODY.

reward if helpful.

regards

mano