Thursday 9 May 2013

ABAP Data Types and Constants


ABAP Data Types and Constants


Data Type describes the technical characteristics of a Variable of that type. Data type is just the blue print of a variable.
Predefined ABAP Types
DATA TYPEDESCRIPTIONDEFAULT LENGTHDEFAULT VALUE
CCharacter1‘ ‘
NNumeric10
DDate800000000
TTime6000000
XHexa Decimal1X’0′
IInteger40
PPacked80
FFloat80
User defined data types
Use TYPES keyword to define the data types.
TYPES: name(10) TYPE c,
       length   TYPE p DECIMALS 2,
       counter  TYPE i,
       id(5)    TYPE n.
Structured data types
Structured data type is grouping of several simple data types under one name.
Use the keywords BEGIN OF and END OF to create a structured data type.
TYPES: BEGIN OF student,
        id(5)     TYPE n,
        name(10)  TYPE c,
        dob       TYPE d,
        place(10) TYPE c,
        END OF student.
Constants
Constants are used to store a value under a name. We must specify the value when we declare a constant and the value cannot be changed later in the program.
Use CONSTANTS keyword to declare a constant.
CONSTANTS: pi  TYPE p DECIMALS 2 VALUE '3.14',
           yes TYPE c VALUE 'X'.

No comments:

Post a Comment