SAP data type and variable data

1. The data type classification:

Data type SAP ABAP development inside (data type) is the type of means which may be used in the program data.
Divided into three categories:

  • ABAP basic data types
    like C \ common data types in JAVA, the data type defined within the system
  • Local data type
    in the local data type defined within the program may also define a plurality of data types include a type of structure (Structure)
    defines the syntax:
    the TYPES DTYPE the TYPE type.
    The TYPES DTYPE the LIKE Dobj.
    The TYPES: the BEGIN. OF t_struct,
    col1 the TYPE C,
    col2 I the TYPE,
    col3 the TYPE D,
    the END. OF t_struct.
  • Global data type
    is the data type of the amount of all programs can use.
    Definition Syntax:
    the TYPES:. Table TYPE types
    TYPE-POOLS hktst ... (statement TYPE GROUP, after the combination of a plurality of set TYPE use)

2. Data classification variables:

Variable data (data variable)
This is the variable that can store data, and the data type (data type) is not storing data.

  • Variable reference to the basic data type definition
    DATA: gv_num TYPE i.
  • Referring to the local variable data type definition of
    such variables can only be used within the program.
    The DATA: gs_struct the TYPE t_struct,
    gv_var the LIKE gs_struct-col1.
  • Referring variable global data type definition
    here mainly refers to the use ABAP dictionary data (ABAP DICTIONARY) variables defined method, this type of data can be used in all programs.
    The DATA: gv_carrid the TYPE s_carr_id,
    gv_connid the TYPE-SFLIGHT Carried,
    gv_matnr the TYPE Mara-MATNR.

3. DATA Statement

DATA statement is used to define the data variable. Variable names can include "_", you can define up to 30.

  • LIKE TYPE and
    data type definitions of the variables can be specified with a particular type TYPE, you can specify the type of a variable with the same LIKE.
    For example:
    the DATA:. Gv_num the TYPE I
    the DATA: gv_num1 the LIKE gv_num.
    • Of VALUE
      of VALUE initial value assigned to the variable.
      DATA: gv_num TYPE i VALUE 123.
  • LENGTH
    specifies the length field, but only applies only to C \ N \ P \ X type.
    DATA: gv_num TYPE n LENGTH 2.
  • DECIMALS
    used to define the number of decimal places, decimals from 1-14, apply only to the data type P (compression type)
    the DATA: gv_num the TYPE P DECIMALS. 3.


Small practice

defines a data type, the data type definition and then a data variable, after the assignment output.
SAP data type and variable data
SAP data type and variable data

Guess you like

Origin blog.51cto.com/14078874/2466568