You are on page 1of 22

ABAP

 ABAP Repository -> contine toate obiectele SAP din sistem independent de client
 contine atat obiecte standard SAP cat si obiectele custom (create la cerinta
clientului
 obiectele sunt disponibile in toti clientii sistemului
 contine: programe, functii, definitii ale tabelelor, tipuri de date, clase etc.
 ABAP Repository este impartit in functie de componenta de aplicatie (de ex
MM); aceste componente sun ierarhizate intr-o structura arborescenta (in
principiu pe module si sub-module; sub ele se afla pachetele)
 In cadrul unei componente obiectele sunt impartite logic in pachete; fiecare
obiect trebuie sa fie atribuit unui pachet
 Tool-uri de Workbench:
o ABAP Editor(SE38) – pentru editarea codului
o ABAP Dictionary(SE11) – pentru crearea si editarea obiectelor de baza de date(tabele,
elemente de date, domenii, table views etc)
o Screen painter(SE51) – utilizat pentru crearea layouturilor ecranelor folosite in
progamele ABAP
o Menu painter(SE41) – pentru configurarea meniurilor
o Function Builder(SE37) – pentru crearea si modificarea functiilor SAP(Function modules)
o Class Builder(SE24) – pentru lucrul cu clase si interfete globale (ABAP OO)
o Object Navigator(SE80) – ofera acces la toate cele de mai sus + obiecte de transport and
others
 Crearea programelor ABAP
o Dezvoltarea progamelor ABAP se realizeaza in sistemul de dezvoltare, apoi se transporta
catre sistemele de Quality Assurance si Productiv cu ajutorul Transport
Organizer(SE09/SE10/SE01)
 SINTAXA

Introductory Statements for Programs (In blue the most common ones)

CLASS-POOL Introduces a class pool


FUNCTION-POOL Introduces a function group
INTERFACE-POOL Introduces an interface pool
PROGRAM Introduces a module pool or subroutine pool
REPORT Introduces an executable program
TYPE-POOL Introduces a type pool
Modularization Statements

Procedures
FUNCTION ... ENDFUNCTION Defines a function module
METHOD ... ENDMETHOD Defines a method

Dialog Modules
MODULE ... ENDMODULE Defines a dialog module

Event Blocks
AT LINE-SELECTION List Event
AT SELECTION-SCREEN Selection Screen Event
AT USER-COMMAND List Event
END-OF-PAGE List Event
END-OF-SELECTION Reporting Event
GET Reporting Event
INITIALIZATION Reporting Event
LOAD-OF-PROGRAM Program Constructor Event
START-OF-SELECTION Reporting Event
TOP-OF-PAGE List Event

Source Code Modules


DEFINE ... END-OF-DEFINITION Defines a macro
INCLUDE Includes an include program

Declarative Statements

Data Types and Data Objects


CONSTANTS Declares a constant
DATA Declares a variable
FIELD-SYMBOLS Declares a field symbol
INCLUDE Includes a structure
NODES Declares a table work area
STATICS Declares a static variable
TABLES Declares a table work area
TYPES Defines a separate data type

Classes and Interfaces


ALIASES Declares an alias name
CLASS ... ENDCLASS Defines a class
CLASS-DATA Declares a static attribute
CLASS-EVENTS Declares a static event
CLASS-METHODS Declares a static method
EVENTS Declares an instance event
INTERFACE ... ENDINTERFACE Defines an interface
INTERFACES Includes an interface
METHODS Declares an instance method
PRIVATE SECTION Introduces the package visibility section
PROTECTED SECTION Introduces the protected visibility section
PUBLIC SECTION Introduces the public visibility section

Object Creation

CREATE DATA Creates an anonymous data object


CREATE OBJECT Creates an object

Calling and Exiting Program Units

Calling Programs

CALL TRANSACTION Calls a transaction


LEAVE TO TRANSACTION Calls a transaction
SUBMIT Calls an executable program

Calling Processing Blocks

CALL FUNCTION Calls a function module


CALL METHOD Calls a method dynamically
PERFORM Calls a subroutine
RAISE EVENT Triggers an event
SET HANDLER Registers an event
SET USER-COMMAND Triggers a list event

Exiting Program Units

CHECK Exits a loop pass or processing block


CONTINUE Exits a loop pass
EXIT Exits a loop or processing block
LEAVE PROGRAM Exits an ABAP program
REJECT Exits a processing block
RETURN Exits a processing block
STOP Exits a processing block

Program Flow Logic

Control Structures

DO ... ENDDO Loop


CASE ... WHEN ... ENDCASE Branch
IF ... ELSEIF ... ELSE ... ENDIF Branch
WHILE ... ENDWHILE Loop

Program Interruption

WAIT UP TO Program interruption for a certain amount of time

Exception Handling

RAISE Triggers a non-class-based exception


RAISE EXCEPTION Triggers a class-based exception
TRY ... CATCH ... CLEANUP ... ENDTRY Handles class-based exceptions
RESUME Resumes after a resumable exception

Assignments

Special Assignments

MOVE-CORRESPONDING Assignment according to structure components


UNPACK Unpacks a packed number

Setting References

ASSIGN Sets a field symbol


UNASSIGN Initializes a field symbol
GET REFERENCE Sets a data reference
Initializations

CLEAR Initializes a data object


FREE Initializes a data object

Processing Internal Data

Calculation Statements

ADD Adds numeric data objects


DIVIDE Divides numeric data objects
MULTIPLY Multiplies numeric data objects
SUBTRACT Subtracts numeric data objects

Character String and Byte String Processing

CONCATENATE Concatenates character strings or byte chains


CONDENSE Condenses a character string
CONVERT TEXT Converts a character string
FIND Searches in a character string or byte chain
GET BIT Reads individual bits in a byte chain
OVERLAY Replacement in a character string
REPLACE Replacement in a character string or byte chain
SET BIT Sets individual bits in a byte chain
SHIFT Moves a character string or byte chain
SPLIT Splits a character string or byte chain
TRANSLATE Converts a character string
WRITE TO Formats values as a character string

Date and Time Processing

CONVERT INTO TIME STAMP Converts date and time into time stamp
CONVERT TIME STAMP Converts a time stamp into data and time
GET TIME Fills the system fields for date and time
GET TIME STAMP Creates a time stamp
Internal Tables

APPEND Attaches rows to an internal table


COLLECT Condensed insertion of rows into an internal table
DELETE Deletes rows from an internal table
FIND IN TABLE Searches in an internal table
INSERT Inserts rows into an internal table
LOOP AT itab ... ENDLOOP Loop across an internal table
LOOP AT GROUP ... ENDLOOP Loop across a row group in an internal table
AT Control Level Processing
MODIFY Changes rows in an internal table
READ TABLE Reads a row of an internal table
REPLACE IN TABLE Replacement in an internal table
SORT Sorts an internal table
SUM Summation of numeric fields in an internal table

Meshes

SET ASSOCIATION Sets an association for a mesh path.

Attributes of Data Objects

DESCRIBE Determines the attributes of a data object

Processing External Data

Open SQL

CLOSE CURSOR Closes a database cursor


DELETE Deletes rows from a database table
FETCH NEXT CURSOR Reads rows using a database cursor
INSERT Inserts rows into a database table
MODIFY Changes or inserts rows in a database table
OPEN CURSOR Opens a database cursor
SELECT ... ENDSELECT Reads rows from a database table
UPDATE Changes rows in a database table

Native SQL

EXEC SQL ... ENDEXEC Defines an area for embedded Native SQL.

ABAP and HANA

CALL DATABASE PROCEDURE Calls a database procedure of SAP HANA database.

Secondary Database Connections

COMMIT CONNECTION Completes an SAP LUW on a secondary database connection


ROLLBACK CONNECTION Cancels an SAP LUW on a secondary database connection

Data Clusters

DELETE Deletes data clusters


EXPORT Exports data objects into a data cluster
FREE MEMORY Deletes data clusters from the ABAP memory
IMPORT Imports data objects from a data cluster
IMPORT DIRECTORY Creates the interval directory of a data cluster

File Interface

CLOSE DATASET Closes a file


DELETE DATASET Deletes a file
GET DATASET Specifies the properties of a file
OPEN DATASET Opens a file Data Consistency
READ DATASET Reads a file
SET DATASET Sets the properties of a file
TRANSFER Fills a file
TRUNCATE DATASET Changes the size of a file
AUTHORITY-CHECK Checks an authorization
COMMIT WORK Completes a SAP-LUW
ROLLBACK WORK Cancels a SAP-LUW
SET UPDATE TASK LOCAL Sets the local update

Program Parameters

SAP Memory

GET PARAMETER Reads an SPA/GPA parameter


SET PARAMETER Sets an SPA/GPA parameter

Language Environment

GET LOCALE Specifies the text environment.


SET COUNTRY Sets the formatting settings of the language environment
SET LANGUAGE Loads a text pool
SET LOCALE Sets the text environment

Program Editing

Testing and Checking Programs

ASSERT Defines an assertion


BREAK-POINT Defines a breakpoint
LOG-POINT Defines a logpoint
GET RUN TIME Specifies a measuring interval
SET RUN TIME ANALYZER Controls the runtime analysis
SET RUN TIME CLOCK Sets the measurement accuracy for measuring intervals

Dynamic Program Development

GENERATE SUBROUTINE POOL Generates a subroutine pool


INSERT REPORT Stores an ABAP program
INSERT TEXTPOOL Stores a text pool
READ REPORT Imports an ABAP program
READ TEXTPOOL Imports a text pool
SYNTAX-CHECK Calls the syntax check

ABAP Data and Communication Interfaces

Remote Function Call

CALL FUNCTION DESTINATION Remote Function Call


RECEIVE Receives parameters for the remote function call
WAIT FOR ASYNCHRONOUS TASKS Waits for completion of the remote function call
WAIT FOR MESSAGING CHANNELS Wait for messages communicated using AMC

ABAP and XML

CALL TRANSFORMATION Calls an XSLT program or a simple transformation

OLE Interface

CALL METHOD Calls a OLE automation method


CREATE OBJECT Create an OLE automation object
FREE OBJECT Releases memory in the OLE automation
GET PROPERTY Reads an attribute in the OLE Automation
SET PROPERTY Sets an attribute in the OLE Automation

User Dialogs

Dynpros

CALL SCREEN Calls a dynpro sequence


CONTROLS Declares a control
EXIT FROM STEP-LOOP Exits a table control or step loop
GET CURSOR Reads the cursor position
GET PF-STATUS Sets the GUI status
LEAVE [TO] SCREEN Exits a dynpro
LOOP AT SCREEN ... ENDLOOP Loop across screen elements
MODIFY SCREEN Modifies a screen element
REFRESH CONTROL Initializes a table control
SET CURSOR Sets the cursor position
SET HOLD DATA Activates/deactivates standard menu entries
SET PF-STATUS Sets the GUI status
SET SCREEN Sets the next dynpro
SET TITLEBAR Sets the GUI title
SUPPRESS DIALOG Suppresses the screen

Selection Screens

PARAMETERS Defines a parameter


SELECTION-SCREEN Defines a selection screen or a screen element
SELECT-OPTIONS Defines a selection criterion

Lists

BACK Relative positioning of list cursor


DESCRIBE LIST Specifies the properties of a list in the list buffer
FORMAT Formats a list
GET CURSOR Reads the cursor position
HIDE Saves a data object in a list level
LEAVE TO LIST-PROCESSING Calls the list processing
LEAVE LIST-PROCESSING Exits list processing
MODIFY LINE Changes a list in the list buffer
NEW-LINE Line break in a list
NEW-PAGE Page break in a list
POSITION Positions the list cursor
PRINT-CONTROL Formats a spool list.
READ LINE Reads a list in the list buffer
RESERVE Relative page break in a list
SCROLL LIST Scrolls in a list
SET BLANK LINES Controls the blank characters in a list
SET CURSOR Sets the cursor position
SET MARGIN Sets the margin of a spool list
SET PF-STATUS Sets the GUI status
SET LEFT SCROLL-BOUNDARY Sets the scroll boundaries of a list
SET TITLEBAR Sets the GUI title
SKIP Positions the list cursor
ULINE Displays a line in a list
WINDOW Displays a list in a dialog box
WRITE Displays data in a list

Messages

MESSAGE Sends a message

Enhancements

Source Code Enhancements

ENHANCEMENT ... ENDENHANCEMENT Implements a source code enhancement


ENHANCEMENT-POINT Defines a source code enhancement
ENHANCEMENT-SECTION ... END-ENHANCEMENT-SECTION Defines a source code enhancement

Enhancements Using BAdIs

GET BADI Creates a BAdl object


CALL BADI Calls BAdI methods

Statements for Experts

INFOTYPES Declares an internal table for HR info types


PROVIDE ... ENDPROVIDE Loop across multiple internal tables

Native SQL
EXIT FROM SQL Exits implicit cursor processing of Native SQL

Contexts

CONTEXTS Data type for contexts


DEMAND Requests a context
SUPPLY Fills the key fields of a context

Internal Statements

Program Editing

DELETE DYNPRO Deletes a dynpro


DELETE REPORT Deletes an ABAP program
DELETE TEXTPOOL Deletes a text pool
EXPORT DYNPRO Exports a dynpro
GENERATE DYNPRO Generates a dynpro
GENERATE REPORT Generates an ABAP program
LOAD REPORT Loads an ABAP program
IMPORT DYNPRO Imports a dynpro
SCAN Splits an ABAP program into tokens
SYNTAX-CHECK FOR DYNPRO Syntax check for a dynpro
SYNTAX-TRACE Influences the syntax check

External Interface

CALL Calls a c function of the ABAP runtime environment

 Operators
o ABAP contains the following operators:
 Operators that perform special operations in operand positions:

 Declaration operators
The declaration operators DATA and FIELD-SYMBOL declare variables or field
symbols in operand positions.

 Constructor operators
The constructor operators NEW, VALUE, CONV, CORRESPONDING, CAST, REF,
EXACT, REDUCE, FILTER, COND, and SWITCH construct values for data objects of
specific data types in constructor expressions.

 Operators that join multiple operands in a single expression:

 Assignment operators
The assignment operator = joins the source field and target field of an
assignment. In the case of assignments, the special casting operator ?= performs
a down cast. The operator = also joins actual parameters with formal
parameters, for example in procedure calls or when working with data clusters.

 Arithmetic operators
The arithmetic operators +, -, *, /, DIV, MOD, and ** join two or more numeric
operands with an arithmetic expression. In addition, the characters + and - act
as plus/minus signs in arithmetic expressions.

 Bit operators
The bit operators BIT-AND, BIT-OR, and BIT-XOR join two or more byte-like
operands with a bit expression. The bit operator BIT-NOT negates a byte-like
operand.

 String operators
The string operator && chains two character-like operands to a string
expression.

 Relational operators
Relational operators occur in relational expressions, which themselves are
components of logical expressions. The relational operators =, <>, <, >, <=,>=,
BETWEEN, and so on join two or more operands of any data type as a
comparison expression. There are additional relational operators for specific
data types. The predicate operator IS qualifies an operand.

 Boolean operators
The Boolean operators AND, OR, and EQUIV join the results of individual logical
expressions with a logical expression. The result of a logical expression is either
true or false. The Boolean operator NOT negates the result of a logical
expression.

 Operator that joins two operands in compilations:


 Literal operator
The literal operator & joins two literals or two string templates with a literal or a
string template.

ABAP Program Types

The type of an ABAP program determines (among other things) which declarations and processing
blocks a program can contain and how the program can be executed in the ABAP runtime environment.

The following table shows all program types for standalone programs (compilation units) and how the
attributes of the programs are affected by the type.

Text
Program Type Execution Global Declarations Processing Blocks Dynpros
Pools
Statement SUBMIT or a
Local interfaces and
Executable dynpro or selection All (except function
classes, all other Yes Yes
program screen is called using a modules)
declarative statements
transaction code
A global class from the
Call of a visible method class library, local
Class pool or a call using a interfaces and classes, Methods only No Yes
transaction code statements TYPES and
CONSTANTS
A function module is
Function called using CALL Local interfaces and All (except event
group or FUNCTION or a dynpro is classes, all other blocks for reporting Yes Yes
function pool called using a declarative statements events)
transaction code
A global interface from
Interface pool None None No No
the class library
All (except function
Local interfaces and
A dynpro is called using modules and event
Module pool classes, all declarative Yes Yes
a transaction code blocks for reporting
statements
events)
Event block LOAD-
External call of local Local interfaces and
Subroutine OF-PROGRAM,
procedures (subroutines classes, all other No Yes
pool subroutines,
or methods) declarative statements
methods
Type group or None Statements TYPES and None No No
type pool CONSTANTS

The second column of the table shows which category of execution the program type is designed for.
The third column shows which declarations can be made in the global declaration section of a program
with the specified type. The fourth column shows which processing blocks the program can contain. The
fifth indicates whether the program can support its own dynpros. The final column indicates whether
the program can create its own text pools.

ABAP Program Types

The type of an ABAP program determines (among other things) which declarations and processing
blocks a program can contain and how the program can be executed in the ABAP runtime environment.

The following table shows all program types for standalone programs (compilation units) and how the
attributes of the programs are affected by the type.

Text
Program Type Execution Global Declarations Processing Blocks Dynpros
Pools
Statement SUBMIT or a
Local interfaces and
Executable dynpro or selection All (except function
classes, all other Yes Yes
program screen is called using a modules)
declarative statements
transaction code
A global class from the
Call of a visible method class library, local
Class pool or a call using a interfaces and classes, Methods only No Yes
transaction code statements TYPES and
CONSTANTS
A function module is
Function called using CALL Local interfaces and All (except event
group or FUNCTION or a dynpro is classes, all other blocks for reporting Yes Yes
function pool called using a declarative statements events)
transaction code
A global interface from
Interface pool None None No No
the class library
All (except function
Local interfaces and
A dynpro is called using modules and event
Module pool classes, all declarative Yes Yes
a transaction code blocks for reporting
statements
events)
Subroutine External call of local Local interfaces and Event block LOAD- No Yes
pool procedures (subroutines classes, all other OF-PROGRAM,
subroutines,
or methods) declarative statements
methods
Type group or Statements TYPES and
None None No No
type pool CONSTANTS

The second column of the table shows which category of execution the program type is designed for.
The third column shows which declarations can be made in the global declaration section of a program
with the specified type. The fourth column shows which processing blocks the program can contain. The
fifth indicates whether the program can support its own dynpros. The final column indicates whether
the program can create its own text pools.

ABAP Program Types

The type of an ABAP program determines (among other things) which declarations and processing
blocks a program can contain and how the program can be executed in the ABAP runtime environment.

The following table shows all program types for standalone programs (compilation units) and how the
attributes of the programs are affected by the type.

Text
Program Type Execution Global Declarations Processing Blocks Dynpros
Pools
Statement SUBMIT or a
Local interfaces and
Executable dynpro or selection All (except function
classes, all other Yes Yes
program screen is called using a modules)
declarative statements
transaction code
A global class from the
Call of a visible method class library, local
Class pool or a call using a interfaces and classes, Methods only No Yes
transaction code statements TYPES and
CONSTANTS
A function module is
Function called using CALL Local interfaces and All (except event
group or FUNCTION or a dynpro is classes, all other blocks for reporting Yes Yes
function pool called using a declarative statements events)
transaction code
A global interface from
Interface pool None None No No
the class library
All (except function
Local interfaces and
A dynpro is called using modules and event
Module pool classes, all declarative Yes Yes
a transaction code blocks for reporting
statements
events)
Subroutine External call of local Local interfaces and Event block LOAD- No Yes
pool procedures (subroutines classes, all other OF-PROGRAM,
or methods) declarative statements subroutines,
methods
Type group or Statements TYPES and
None None No No
type pool CONSTANTS

The second column of the table shows which category of execution the program type is designed for.
The third column shows which declarations can be made in the global declaration section of a program
with the specified type. The fourth column shows which processing blocks the program can contain. The
fifth indicates whether the program can support its own dynpros. The final column indicates whether
the program can create its own text pools.

Predefined Numeric Types

The data objects of the numeric data types are used to handle number values.

Properties

Type Length Standard Length Name


b 1 byte   1-byte integer (internal)
s 2 byte   2-byte integer (internal)
i 4 byte   4-byte integer
p 1 to 16 bytes 8 byte Packed number
decfloat16 8 byte   Decimal floating point number with 16 places
decfloat34 16 byte   Decimal floating point number with 34 places
f 8 byte   Binary floating point number with 17 places

Value Ranges and Initial Values

Initial
Type Value Range
Value
b 0 to 255 0
s -32,768 to +32,767 0
i -2,147,483,648 to +2,147,483,647 0
The valid length for packed numbers is between 1 and 16 bytes; two places are packed into
one byte, where the last byte only contains one place and the sign (the number of places
or digits is calculated from 2 * len-1); after the decimal separator, up to 14 decimal places
p are permitted. Depending on the field length len and the number of decimal places dec, 0
the following applies to the value range: (-10^(2len-1) +1) / (10^(+dec)) to (+10^(2len-1) -1)
/(10^(+dec)) in increments of 10^(-dec); any intermediate values are rounded (decimal);
invalid content produces undefined behavior.
decfl Decimal floating point numbers of this type are represented internally with 16 places in 0
accordance with the IEEE-754-2008 standard; valid values are numbers between 1E385(1E-
16 - 1) and -1E-383 for the negative range, 0 and +1E-383 to 1E385(1 - 1E-16) for the
oat1
positive range. Values lying between the ranges form the subnormal range and are
6
rounded; outside of the subnormal range, each 16-digit decimal number can be
represented precisely with a decimal floating point number of this type
Decimal floating point numbers of this type are represented internally with 34 places in
accordance with the IEEE-754-2008 standard; valid values are numbers between
decfl
1E6145(1E-34 - 1) and -1E-6143 for the negative range, 0 and +1E-6143 and 1E6145(1 - 1E-
oat3 0
34) for the positive range. Values lying between the ranges form the subnormal range and
4
are rounded; outside of the subnormal range, each 34-digit decimal number can be
represented precisely with such a decimal floating point number
Binary floating point numbers are represented internally in accordance with the IEEE-754
standard (double precision); in ABAP, 17 places are represented (one integer digit and 16
decimal places). Valid values are numbers between -1.7976931348623157E+308 and -
f 2.2250738585072014E-308 for the negative range and between +2.2250738585072014E- 0
308 and +1.7976931348623157E+308 for the positive range, plus 0. Both validity intervals
are extended in the direction of zero using subnormal numbers in accordance with the
IEEE-754 standard.
Predefined Numeric Types
The data objects of the numeric data types are used to handle number values.
Properties
Type Length Standard Length Name
b 1 byte   1-byte integer (internal)
s 2 byte   2-byte integer (internal)
i 4 byte   4-byte integer
p 1 to 16 bytes 8 byte Packed number
decfloat16 8 byte   Decimal floating point number with 16 places
decfloat34 16 byte   Decimal floating point number with 34 places
f 8 byte   Binary floating point number with 17 places

Value Ranges and Initial Values (IV – 0)

T Value Range
b 0 to 255
s -32,768 to +32,767
i -2,147,483,648 to +2,147,483,647
The valid length for packed numbers is between 1 and 16 bytes; two places are packed into one byte,
where the last byte only contains one place and the sign (the number of places or digits is calculated
from 2 * len-1); after the decimal separator, up to 14 decimal places are permitted. Depending on the
p
field length len and the number of decimal places dec, the following applies to the value range: (-
10^(2len-1) +1) / (10^(+dec)) to (+10^(2len-1) -1) /(10^(+dec)) in increments of 10^(-dec); any
intermediate values are rounded (decimal); invalid content produces undefined behavior.
decfl Decimal floating point numbers of this type are represented internally with 16 places in accordance
with the IEEE-754-2008 standard; valid values are numbers between 1E385(1E-16 - 1) and -1E-383 for
oat1 the negative range, 0 and +1E-383 to 1E385(1 - 1E-16) for the positive range. Values lying between the
6 ranges form the subnormal range and are rounded; outside of the subnormal range, each 16-digit
decimal number can be represented precisely with a decimal floating point number of this type
Decimal floating point numbers of this type are represented internally with 34 places in accordance
decfl with the IEEE-754-2008 standard; valid values are numbers between 1E6145(1E-34 - 1) and -1E-6143
oat3 for the negative range, 0 and +1E-6143 and 1E6145(1 - 1E-34) for the positive range. Values lying
4 between the ranges form the subnormal range and are rounded; outside of the subnormal range, each
34-digit decimal number can be represented precisely with such a decimal floating point number
Binary floating point numbers are represented internally in accordance with the IEEE-754 standard
(double precision); in ABAP, 17 places are represented (one integer digit and 16 decimal places). Valid
values are numbers between -1.7976931348623157E+308 and -2.2250738585072014E-308 for the
f
negative range and between +2.2250738585072014E-308 and +1.7976931348623157E+308 for the
positive range, plus 0. Both validity intervals are extended in the direction of zero using subnormal
numbers in accordance with the IEEE-754 standard.

Generic ABAP Types

The following table shows the predefined generic ABAP types. A generic data type is an incomplete type
specification that includes multiple complete type specifications. With the exception of object, all
generic types can be used after TYPE for the typing of field symbols and formal parameters. When a data
object is assigned to generically typed field symbols using the statement ASSIGN, or to a formal
parameter in procedure calls, the system checks whether its concrete data type is compatible with it,
that is whether it is a subset of the generic type.

The only generic types that can be used after TYPE REF TO are data, for the generic typing of data
references, and object for the generic typing of object references.

Type Description
any Any data type
any table Internal table with any table category
c Text field with a generic length
clike Character-like (c, d, n, t, string, and character-like flat structures)
csequence Text-like (c, string)
data Any data type
decfloat Decimal floating point number (decfloat16, decfloat34)
hashed table Hashed table
index table Index table
n Numeric text with generic length
numeric Numeric (i (b, s), p, decfloat16, decfloat34, f)
object Any object type (root class of the inheritance hierarchy)
p Packed number with generic length and generic number of decimal places
Elementary data type including structured types with exclusively character-like flat
simple
components
sorted table Sorted table
standard table Standard table
table Standard table
x Byte field with generic length
xsequence Byte-like (x, xstring)

ABAP predefined data types such as Char, Date, Time, integer ABAP
Code

*& TITLE: ABAP predefined data types such as Char, Date, Time, integer
*&-------------------------------*
*& Report ZABAP_DATA_TYPES
*&-------------------------------*
*& Simple ABAP code to demonstrate the predefined ABAP data types.
*& Note you would usually have all the WRITE statements after all the data
*& declarations but just makes it clearer to put them together for this
example
*&-------------------------------*
REPORT ZABAP_DATA_TYPES.

*Type I (Integer)
*----------------
*This is the basic numeric integer type which only accepts whole numbers
DATA: ld_int type I.
ld_int = 200.
WRITE:/ ld_int.

*Type F (Floating point number)


*------------------------------
*This is a numeric values with decimal places used for calculation results
DATA: ld_float type f.
ld_float = ld_int / 22.
WRITE:/ ld_float.

*Type P (Packed number)


*----------------------
* This is a numeric value with decimals places, packed data tyoes
* also allow you to define the number of decimal places
DATA: ld_packed type p decimals 2 value '88.345'.
WRITE:/ ld_packed. "notice because it is only 2 decimal places the value is
rounded

*Type C (Character)
*------------------
*This is an alpha numeric text value of what ever lenght you specify up
*to the maximum length
DATA: ld_char type c, "length = 1
ld_char2(30) type c value 'Hello'. "length = 30
WRITE:/ ld_char2.

*Type D (Date)
*-------------
*This field stores a date value in the format YYYYMMDD
DATA: ld_date type d value '19991230',
ld_date2 type begda. "using a dictionary type

ld_date2 = sy-datum. "set value to todays date


*Although the value is stored in YYYYMMDD it is displayed in a different
*format either based on the users setting or specifying the put put i.e.
WRITE:/ ld_date2 DD/MM/YYYY,
/ ld_date2 DDMMYY."etc

*Type N (Numeric)
*----------------
*This stores a numeric text value, fills any unused capacity with zeros
DATA: ld_numc type n, "1 char long
ld_numc2(10) type n value 1025. "30 chars long
WRITE:/ ld_numc2. "0000001025

*Type T (Time)
*-------------
*This stores a time value, the value is stored in seconds but displayed in
HHMMSS
DATA: ld_time type t value 1, "displayed as 00:00:01 i.e. 1 second
ld_time2 type t value 60, "displayed as 00:01:00 i.e. 1 minute
ld_time3 type t value 3661. "displayed as 01:01:01 i.e. 1 hour,1
minute & 1 second
WRITE:/ ld_time, "000001
/ ld_time2, "000100
/ ld_time3. "010101

*Type X (Hexadecimal)
*--------------------
*This stores a hexadecimal values, could be used for creating files and
inserting
*hexedecimal characters to insert tabs a new line
DATA: ld_hex type x value '09', "Tab
ld_hex2 type x value '0D'. "Carriage Return(new line)
WRITE:/ ld_hex,
/ ld_hex2.

**********************
*END-OF-SELECTION.
END-OF-SELECTION.

You might also like