Beruflich Dokumente
Kultur Dokumente
Contents
Objectives Elements of ABAP/4 Syntax Defining Data Objects Summary Q&A
Contents
Objectives
Objectives
Understand the elements of ABAP/4 syntax. Describe the concept of data objects and their visibility. Use literals and understand how to code each type. Define and use constants. Use the data statement to define variables and field strings. Understand ABAP/4 data types, and be able to identify the character and numeric data types. Understand the ABAP/4 definition of common DDIC data types.
Contents
Elements of ABAP/4 Syntax
Contents
Defining Data Objects
Data Objects
Data Objects: memory locations to hold data while running 2 types:
modifiable:
variables field strings (~ structures) and internal tables (~ arrays)
non-modifiable:
literals constants
Data Objects
Literals
Literal: a non-modifiable data object. 4 types:
character string:
'Hello SAP world 'Caesar''s tail Caesar's tail
numeric
256, -99, 10.5
floating-point: '<mantissa>E<exponent>
'9.99E9', '-10E-32', '+1E09'
hexadecimal:
character string (0-9, A-F) must be an even number of characters in the string must be in uppercase '00', 'A2E5', 'F1F0FF'
Literals
Variables
2 statements are commonly used to define variables:
data
variables can be declared for the program variables are assigned to a data type and can have defaults
parameters
like data statement the parameters are displayed as input fields on a selection screen.
DATA statement
Syntax:
data v1[(l)] [type t] [decimals d] [value 'xxx']. data v1 like v2 [value 'xxx'].
where:
v1 is the variable name. v2 is the name of a variable previously defined in the program, or is the name of a field that belongs to a table or structure in the Data Dictionary. (l) is the internal length specification. t is the data type. d is the number of decimal places (used only with type p). 'xxx' is a literal that supplies a default value.
DATA statement
Examples of Variables Defined with the DATA Statement 1 2 3 4 data data data data f1(2) type c. f2 like f1. max_value type i value 100. cur_date type d value '19980211'.
default length: depends on the data type default data type: c (character) default initial value: 0, (for data type c: blank) cannot use a variable to supply a default value.
N Numeric text:
hold unsigned positive integer in character used as unique identifiers: document no, account no
PARAMETERS statement
The maximum length is 8 can use a variable to supply a default value. Syntax:
parameters p1[(l)] [type t] [decimals d] ... parameters p1 like v1 ...... [default 'xxx'] [obligatory] [lower case] [as checkbox] [radiobutton group g].
where:
p1 is the parameter name. v1 is the name of a previously defined variable or parameter, or is the name of a field that belongs to a table or structure in the Data Dictionary. (l) is the internal length specification. t is the data type. d is the number of decimal places (used only with type p). 'xxx' is a literal or previously defined variable that supplies a default value.
PARAMETERS statement
parameters parameters parameters parameters obligatory. parameters obligatory. p1(2) type c. p2 like p1. max_value type i default 100. cur_date type d default '19980211' cur_date like sy-datum default sy-datum
PARAMETERS statement
Example
report ztx0706. parameters: p1(15) type c, p2 like p1 obligatory lower case, p3 like sy-datum default sydatum, cb1 as checkbox, cb2 as checkbox, rb1 radiobutton group g1 default 'X', rb2 radiobutton group g1, rb3 radiobutton group g1. write: / 'You entered:', / ' p1 =', p1, / ' p2 =', p2, / ' p3 =', p3, / ' cb1=', cb1, / ' cb2=', cb2, / ' rb1=', rb1, / ' rb2=', rb2, / ' rb3=', rb3.
Parameter Labels
LIKE addition
F1 help: from Documentation in data element F4 help: from check table
obtain a list of valid values the value entered is NOT validated against the check table.
Contents
Summary
Summary
An ABAP/4 program, statement, keyword. A data object is a memory location that contains data during the runtime of the program.
non-modifiable: literals and constants. modifiable: variables, field strings, and internal tables.
Literals are data that is hard-coded in your program. Data types: character and numeric.
Character: c, n, d, t, and x Numeric: i, p, and f
data and parameters statements. parameter input field labels: menu path Goto->Text Elements.