Beruflich Dokumente
Kultur Dokumente
ABAP Overview
MOVE
IF ...
DATA ...
WHILE...
WRITE ...
SEARCH ...
*Comment...
DO ...
SELECT ...
LOOP AT ...
ABAP/4 overview
SE80 - Repository Browser: Used to display and edit hierarchical lists of development
objects.
SE11 - Dictionary : Used to define and save data definitions You can also store
documentation, help information, data relationships, and other information. You also use the
Dictionary to generate database objects like tables and indexes.
The Dictionary is a central storage area for system-wide data definitions. Because definitions
are stored centrally, they are available for use anywhere in any program throughout the
system
SE38 - ABAP editor : Create/edit/Display program code
SE37 - Function Builder : define and store function modules, use the library to write new
modules and look up information on existing modules
SE16 - Data browser : Display data in Transparent table or Database view
SM30 - Table maintenance : Maintain data
ABAP
Advanced
Business
Application
Programming
Executable program(Report/Interface)
Can be started with transaction code/directly/background
(via SE38 or SA38 - For example: RMCB0100 )
I
INCLUDE program
Can not run on its own, has been included in other program
M
Module pool
Processing step of screens, can be executed via transaction code or
Menu function (For example: SAPMV45A - Sale order processing)
F
Function group
Contain function modules (SE37)
S
Subroutine pool
Externally-called subroutines
ABAP Feature
ABAP
ABAP Programming
ABAP Report
Dialog Programming(Transaction)
Report Program
: attribute type 1
(executable)
Reading
Data
Database
Reading data
10
1
3
1. Report Listing
2. Drill-down Report
3. Control-break Report
4. ALV Report
11
Dialog Program
: attribute type M
(Module Pool)
Reading
Data
Writing
Database
13
Transaction : SE38
15
Program Attribute
16
ABAP Editor
17
18
Literal
Text Literal
Numeric Literal
19
Chained Statements
20
Chained Statements
21
Chained Statement
22
Chained Statement
23
Comments
24
25
Variable
Structure
Memory Space
Internal Table
Table Structure
Constants
<Field-symbols>
27
Variable
Variable
REPORT ZTEST.
DATA firstname TYPE STRING.
firstname = John.
29
Description
Initial Value
Character
Space
Date
Floating Point
0.0
8 bytes
Integer
4 bytes
Numeric Text
Packed Decimal
Time
000000
6 characters
Hexadecimal
00
1 65535
String
Variable-length
Space
Variable
xstring
Variable-length
Hexadecimal
Blank string
Variable
00000000
0
0
Length
1 65535
8 characters
1 65535
1 16 bytes
30
* Syntax
DATA var[(length)] [Type type] [Decimals number].
DATA var LIKE Table-Field [VALUE initial value].
31
* Data Declaration
DATA: tmp(10) TYPE C,
tmp1
TYPE I,
tmp2(8) TYPE P DECIMALS 2 VALUE 1.5
DATA: tmp3(5) TYPE N,
tmp4.
32
* Data Declaration
DATA customerno LIKE customers-id.
DATA matnr LIKE mara-matnr.
33
ABAP Predefined
Data Types
Complete Types
(I,F,D,T,STRING
and XSTRING)
Incomplete Types
(C,N,P and X)
34
Variable
Data Type C,N and X length between 1 65535 (Default 1)
DATA tmp(10) TYPE C.
35
Data type N
36
ABAP Error
ABAP Error
Syntax
Error
Runtime
Error
User Runtime
Error
System Runtime
Error
Cannot Allocate
Space
Time Exceed
(10 Minutes)
37
38
39
40
Non-elementary Type
* Data Declaration
TYPES tname(30) TYPE c.
DATA: customer_name TYPE tname,
firstname TYPE tname.
41
Value Assignment
* Value assignment
DATA: name1(30),
first_num TYPE I,
next_num
TYPE I.
MOVE XXXX TO name1.
MOVE 5 TO first_num.
COMPUTE next_num = first_num + 5.
name1 = SAP.
ADD 1 TO next_num.
2012 SAP AG. All rights reserved.
42
Value Assignment
* Value assignment
DATA: tmp1 TYPE i,
tmp2 TYPE i.
tmp1 = tmp2 = 10.
43
Structure
Structure
* Syntax
DATA BEGIN OF <structure name>.
DATA field1.
DATA field2.
45
Structure
wa
id
name
city
* Syntax
00000000
DATA BEGIN OF wa.
DATA id LIKE customers-id.
DATA name LIKE customers-name.
DATA city LIKE customers-city.
DATA END OF wa.
MOVE 9 TO wa-id.
WRITE wa-id.
46
* Include Structure
DATA BEGIN OF wa.
INCLUDE STRUCTURE customers.
DATA tel(7).
DATA END OF wa.
47
Defining Structure
* LIKE option
DATA wa LIKE customers.
wa-id = 1.
wa-name = John.
WRITE: wa-id, wa-name.
48
Constants
Constants
* Constant variable
CONSTANTS max_no TYPE I VALUE 999.
DATA counter TYPE I VALUE max_no.
WRITE: max_no, counter.
50
* Constant variable
CONSTANTS ctext(11) TYPE C VALUE Hello Wor
WRITE ctext.
WRITE ctext.
WRITE ctext.
WRITE ctext.
WRITE ctext.
51
System Fields
sy-datum
sy-uzeit
sy-datlo
sy-timlo
sy-mandt
sy-subrc
syst-datum
52
53
DATE
* Fixed Length 8
* Include Representation YYYYMMDD
DATA today TYPE D.
today = sy-datum.
WRITE today.
today = 19991231.
WRITE today.
54
TIME
* Fixed Length 6
* Format HHMMSS
DATA times TYPE T.
times = sy-uzeit.
WRITE times.
HHMMSS
55
MOVE Statement
56
MOVE-CORRESPONDING Statement
DATA: begin of wa1,
f1,f2,f4,
end of wa1.
DATA: begin of wa2,
f2,f1,f3,
end of wa2.
57
Field-symbols
Field-symbols
Data: name(4) Value Test,
num Type I Value 10,
today Type D Value 19980429.
Field-symbols <temp>.
Assign name To <temp>.
Write <temp>.
Assign num To <temp>.
Write <temp>.
Assign today To <temp>.
Write <temp>.
2012 SAP AG. All rights reserved.
59
Field-symbols : UNASSIGN
60
CLEAR Statement
Example:
DATA tmp type i value 9.
tmp = 10.
CLEAR tmp.
61
CLEAR Structure
CLEAR wa.
62
Report ztest.
*Data objects declaration
data ...
data begin of ...
*Program Logic(Data objects processing)
write .
2012 SAP AG. All rights reserved.
63