ABAP - Sintaxa
ABAP - Sintaxa
ABAP - Sintaxa
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)
Modularization Statements
Procedures
FUNCTION ... ENDFUNCTION Defines a function module
METHOD ... ENDMETHOD Defines a method
Dialog Modules
Event Blocks
Declarative Statements
Object Creation
Calling Programs
Control Structures
Program Interruption
Exception Handling
Assignments
Special Assignments
MOVE-CORRESPONDING Assignment according to structure components
UNPACK Unpacks a packed number
Setting References
Initializations
Calculation Statements
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
Meshes
Native SQL
EXEC SQL ... ENDEXEC Defines an area for embedded Native SQL.
Data Clusters
File Interface
Data Consistency
Program Parameters
SAP Memory
Language Environment
Program Editing
OLE Interface
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
Lists
Messages
Enhancements
Contexts
Internal Statements
Program Editing
External Interface
Operators
o ABAP contains the following operators:
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.
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.
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 classes, all other blocks for reporting Yes Yes
function pool is 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)
External call of local Event block LOAD-
Local interfaces and
Subroutine procedures OF-PROGRAM,
classes, all other No Yes
pool (subroutines or subroutines,
declarative statements
methods) 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.
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 classes, all other blocks for reporting Yes Yes
function pool is 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)
External call of local Event block LOAD-
Local interfaces and
Subroutine procedures OF-PROGRAM,
classes, all other No Yes
pool (subroutines or subroutines,
declarative statements
methods) 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.
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 classes, all other blocks for reporting Yes Yes
function pool is 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)
External call of local Event block LOAD-
Local interfaces and
Subroutine procedures OF-PROGRAM,
classes, all other No Yes
pool (subroutines or subroutines,
declarative statements
methods) 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.
The data objects of the numeric data types are used to handle number values.
Properties
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 are permitted. Depending on the field length len and the
p 0
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.
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 the negative range, 0 and +1E-383 to
decfloat16 1E385(1 - 1E-16) for the positive range. Values lying between the ranges form the 0
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 with the IEEE-754-2008 standard; valid values are numbers
between 1E6145(1E-34 - 1) and -1E-6143 for the negative range, 0 and +1E-6143
decfloat34 and 1E6145(1 - 1E-34) for the positive range. Values lying between the ranges form 0
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 -
f 1.7976931348623157E+308 and -2.2250738585072014E-308 for the negative 0
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.
The data objects of the numeric data types are used to handle number values.
Properties
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
p 0
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 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.
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 the negative range, 0 and +1E-383 to
decfloat16 1E385(1 - 1E-16) for the positive range. Values lying between the ranges form the 0
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 with the IEEE-754-2008 standard; valid values are numbers
between 1E6145(1E-34 - 1) and -1E-6143 for the negative range, 0 and +1E-6143
decfloat34 and 1E6145(1 - 1E-34) for the positive range. Values lying between the ranges form 0
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 -
f 1.7976931348623157E+308 and -2.2250738585072014E-308 for the negative 0
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.
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
Standard table
table
table Standard table
x Byte field with generic length
xsequence Byte-like (x, xstring)