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: 

Diff b/w Data Type and Data Object

Former Member
0 Kudos

Hi ,

Can u plz explain me the Diff b/w Data Type and Data Object.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

DATA OBJECT will have memory..

DATA TYPE will not have any memory..

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 data object which has some memory and can store a value !!

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

Data types can be divided into

elementary,

reference, and

complex types.

Elementary Types

Elementary types are the smallest indivisible unit of types. They can be grouped as those with fixed length and those with variable length.

Fixed-Length Elementary Types

There are eight predefined types in ABAP with fixed length:

Four character types:

Character (C),

Numeric character (N),

Date (D),

and Time (T).

One hexadecimal type:

Byte field (X).

Three numeric types:

Integer (I),

Floating-point number (F)

and Packed number (P).

Variable-Length Elementary Types

There are two predefined types in ABAP with variable length:

STRING for character strings

XSTRING for byte strings

Reference Types

Reference types

describe data objects that contain references (pointers) to other objects (data objects and objects in ABAP Objects).

Data Types

1) As well as occurring as attributes of a data object, data types can also be defined independently.

2)You can then use them later on in conjunction with a data object.

3) The definition of a user-defined data type is based on a set of predefined elementary data types.

4) You can define data types either locally in the declaration part of a program using the TYPESstatement) or globally in the ABAP Dictionary.

5) You can use your own data types to declare data objects or to check the types of parameters in generic operations.

Data Objects

1)Data objects are the physical units with which ABAP statements work at runtime.

2) The contents of a data object occupy memory space in the program.

3) ABAP statements access these contents by addressing the name of the data object and interpret them according to the data type..

4) For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.

5) Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type).

6) You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures).

7) As well as fields in the memory area of the program, the program also treats literals like data objects.

Regards,

Priyanka.

6 REPLIES 6

Former Member
0 Kudos

Hi,

DATA OBJECT will have memory..

DATA TYPE will not have any memory..

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 data object which has some memory and can store a value !!

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

Data types can be divided into

elementary,

reference, and

complex types.

Elementary Types

Elementary types are the smallest indivisible unit of types. They can be grouped as those with fixed length and those with variable length.

Fixed-Length Elementary Types

There are eight predefined types in ABAP with fixed length:

Four character types:

Character (C),

Numeric character (N),

Date (D),

and Time (T).

One hexadecimal type:

Byte field (X).

Three numeric types:

Integer (I),

Floating-point number (F)

and Packed number (P).

Variable-Length Elementary Types

There are two predefined types in ABAP with variable length:

STRING for character strings

XSTRING for byte strings

Reference Types

Reference types

describe data objects that contain references (pointers) to other objects (data objects and objects in ABAP Objects).

Data Types

1) As well as occurring as attributes of a data object, data types can also be defined independently.

2)You can then use them later on in conjunction with a data object.

3) The definition of a user-defined data type is based on a set of predefined elementary data types.

4) You can define data types either locally in the declaration part of a program using the TYPESstatement) or globally in the ABAP Dictionary.

5) You can use your own data types to declare data objects or to check the types of parameters in generic operations.

Data Objects

1)Data objects are the physical units with which ABAP statements work at runtime.

2) The contents of a data object occupy memory space in the program.

3) ABAP statements access these contents by addressing the name of the data object and interpret them according to the data type..

4) For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.

5) Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type).

6) You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures).

7) As well as fields in the memory area of the program, the program also treats literals like data objects.

Regards,

Priyanka.

Former Member
0 Kudos

Hi,

Data element (semantic domain)

Data element

A data element is an elementary type. It describes the type attributes

(data type, field length and possibly the number of decimal places) and

screen information (explanatory text or field help) about unstructured

data objects (table fields and structure fields or variables).

Table fields and structure fields with the same contents should refer to

the same data element. This ensures that the attributes of these fields

are always consistent.

A data element can be referenced in ABAP programs with TYPE. This

permits you to define variables that take on the type attributes of the

data element in an ABAP program.

goto Se11

Check F1 help for Datatype

You will get the required info

Data objects:

Data objects are the physical units with which ABAP statements work at runtime. Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running. The technical attributes of a data object are its length, number of decimal places, and data type. ABAP statements work with the contents of data objects and interpret them according to their data type. You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.

ABAP contains the following kinds of data objects

Literals

Named Data Objects

Predefined Data Objects

Dynamic Data Objects

<b>Reward points</b>

Regards

Former Member
0 Kudos

DATA TYPE : It is the type which can be used 2 declare a variable(object.).It doesn't occupy any memory.

DATA OBJECT : It is something whch can store some value after declaring with some DATA TYPE. In fact DATA OBJECT occupies memory.

E.g :

data : Var1 type c,

Var2 type i.

Here Var1, Var2 are DATA OBJECTS.....and c,i are DATA TYPES.

Former Member
0 Kudos

Hi

<b>Datatypes</b>

Data types are a subtree of the ABAP type hierarchy. Data types are only type descriptions. Data types do not have any attached memory for storing working data, but they may require space for administration information. A data type characterizes the technical properties of all data objects that have this type. In ABAP, data objects occur as attributes of data objects, but they can also be defined as stand-alone data types.

The definition of stand-alone data types is based on a set of predefined data types. Stand-alone data types can either be defined internally in the program using the statement TYPES in the global declaration section of a program, in the declaration section of a class, locally in procedures, or for all programs in the ABAP Dictionary. Data types in the ABAP Dictionary are either created directly as repository objects or in a type group.

Predefined and self-defined data types can be used to generate data objects and for typing. For the latter in particular, predefined generic data types are available. A generic data type is a data type that does not determined all the properties of a data object. Generic data types can only be used for typing formal parameters and field symbols.

Data types can be divided into elementary, reference, and complex types.

Elementary types are 'atomic' in the sense that they are not composed of other types. They are further classified into elementary types of fixed length and of variable length.

There are eight predefined elementary data types of fixed length in ABAP. There are four character-type types: text fields (c), numeric text fields (n), date fields (d), and time fields (t). There are three numeric types: Integer , floating point numbers (f), and packed numbers (p). Byte-like type: Byte fields (x). The data types c, n, x, and p are generic in terms of length. p is also generic in terms of the number of decimal places.

There are two predefined elementary data types of variable length in ABAP. There is one character-type type: text string (string), and one byte-liker type: byte string (xstring).

Reference types describe data objects that contain references to other objects (data objects and instances of classes), which are known as reference variables. There are no predefined reference types in ABAP. A reference type must either be defined in the ABAP program or in the ABAP Dictionary. Reference types form a hierarchy, which represents the hierarchy of the objects to which the references can point.

Complex data types are composed of other types. They enable the administration and processing of semantically related datasets under one name. A data object of a complex type can be accessed overall or by component. With the exception of the structure sy, there are no predefined complex data types in ABAP. A complex type must either be defined in the ABAP program or in the ABAP Dictionary. There are two types of complex data type:

A structured type is a sequence of any elementary reference or complex data types. Structures are used for grouping together work areas that logically belong together.

Table types consist of a sequence of any number of lines of the same data type. Table types are characterized by a row type, which can be any elementary data type, a reference data type, or a complex data type. They are also characterized by the table type, which defines how tables can be accessed, and by a table key, which is used to identify the table rows.

<b>Dataobject</b>

Data objects are instances of data types and contain the concrete data that a program uses at runtime. This is done by specifying data objects in operand positions.

Every data object has a certain data type, and every data object uses memory to store the data. The data type of a data object is defined either with reference to a stand-alone data type or, when the data object is created, as a bound data type.

The data type of a data object is always uniquely defined at the runtime of the program and cannot be changed. In the case of anonymous data objects, this data type determines the dynamic type of the related reference variables.

Former Member
0 Kudos

hi

good

data types->

The TYPE addition allows you to construct new data types in the TYPES, DATA; CONSTANTS; and STATICSstatements. In the TYPES statement, these are local data types in the program. In the other statements, they are attributes of new data objects, meaning that the newly defined data types are not free-standing. Rather, they are linked to database objects.This means that you can refer to them using the LIKEaddition, but not using TYPE.

To construct new data types, the addition TYPE can be used with the following type constructors:

· Construction of reference types

REF TO type|dobj

· Construction of structured data types

BEGIN OF struc_type.

...

END OF struc_type.

· Construction of table types

tabkind OF linetype

These data types only exist during the runtime of the ABAP program.

data objects->

Using the additions TYPE or LIKE in the TYPESstatement, local data types in a program can be referred to known data types or data objects. This is mainly the case with user-defined elementary data types. If you declare variables using the additions TYPE type or LIKE dobj with statement DATA, the data type of var is already fully defined before the declaration is made.

The known types or data that are referred to must be visible at the point where the data type or variable is declared.

A known data type can be any of the following:

· A predefined ABAP type to which you refer using the TYPE addition

· An existing local data type in the program to which you refer using the TYPE addition

· The data type of a local data object in the program to which you refer using the LIKE addition

· A data type in the ABAP Dictionary to which you refer using the TYPE addition. To ensure compatibility with earlier releases, it is still possible to use the LIKE addition to refer to database tables and flat structures in the ABAP Dictionary. However, you should use the TYPE addition in new programs.

The LIKE addition takes its technical attributes from a visible data object. As a rule, you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context. The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.

· In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.

· You can also refer to the data objects of other visible ABAP programs. These might be, for example, the visible attributes of global classes in class pools. If a global class cl_lobal has a public instance attribute or static attribute attr, you can refer to it as follows in any ABAP program:

DATA dref TYPE REF TO cl_global.

DATA: f1 LIKE cl_global=>attr,

f2 LIKE dref->attr.

You can access the technical properties of an instance attribute using the class name and a reference variable without first having to create an object. The properties of the attributes of a class are not instance-specific and belong to the static properties of the class.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm

thanks

mrutyun^

Former Member
0 Kudos

hi,

data types:

Data type C can b used for bothe character and numeric values. it Accepts both. But when its specifically numeric values only, u can use data type N.

some of the links below for data types may b useful for u:

1.http://help.sap.com/saphelp_nw04/helpdata/en/79/c5545eb3dc11d5993800508b6b8b11/frameset.htm

2.http://help.sap.com/saphelp_nw04s/helpdata/en/43/5d2ea0e84b3e2be10000000a1553f6/frameset.htm

Data objects:

Data objects are the physical units with which ABAP statements work at runtime. Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running. The technical attributes of a data object are its length, number of decimal places, and data type. ABAP statements work with the contents of data objects and interpret them according to their data type. You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.

ABAP contains the following kinds of data objects

Literals

Named Data Objects

Predefined Data Objects

Dynamic Data Objects