DATA TYPES


To work with data at run time, you need to store it in the program at run time and address it from your program. The system needs to know the type of the data.

A data object is the name of a memory location, used to store or change values of a specific data type.


Predefined Data Types:


Defining & Declaring Data Objects:


Key Words:
                                         DATA    -   Used to define data objects.
                                         TYPE     -   Used to specify the data type.


Syntax:
DATA  <Object Name> TYPE <Data Type>.


Example
DATA A TYPE I.


NOTE: For Integer and Float Values are assigned directly. But for Packed Decimal, Character, Numeric Character, Date, Time, String values are assigned within the single quotes.

User defined Data Types:


Local Data Types: Data types defined and used within a program.

Local Data Types are defined within a program unit with the key word "TYPES".

Syntax:
TYPES  <new data type name> TYPE <data type>.


Example:
TYPES A TYPE I.


TYPES A TYPE I                                                                           DATA A TYPE I
            |                                                                                                  |
            |                                                                                                  |
    Data Type                                                                                   Data Object


  • Data Type is a specification, it provides the characteristics of the data type specified.
  • Data Object is the name of a memory location with a specific data type to store or change the values.
Using Keyword : Like


"LIKE" is used in place of  "TYPE" to define user defined data types od data objects with reference to existing data objects.

Example1 :   DATA A TYPE I.
                     DATA B LIKE A.

Example2 :   DATA NAME(10) TYPE C.
                     DATA EMPNAME LIKE NAME.

Example3 :  DATA : BEGIN OF EMP,
                                EMPNO(3) TYPE N,
                                EMPNAME(10) TYPE C,
                                EMPSAL TYPE I,
                                END OF EMP.
                     DATA : EMP1 LIKE EMP.


1 comment:

  1. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific nice content. And tell people specific ways to live their lives.Sometimes you just have to yell at people and give them a good shake to get your point across.

    SAP HR Training in Chennai

    SAP SD Training in Chennai

    SAP Basis Training in Chennai

    ReplyDelete