Professional Documents
Culture Documents
Objectives
2
Table of Content
◼ ABAP Overview
◼ ALV Report
◼ Basic ABAP
◼ Revisit Basic ABAP
◼ Transaction Code
◼ ABAP Dictionary
◼ Internal Table
◼ Open SQL
◼ Selection Screen
◼ Function Module
◼ Revisit ALV Report
◼ Conclusion
3
ABAP Overview
Overview of ABAP
T h e A B A P /4 P ro g ra m m in g L a n g u a g e
A dvanced
B u s in e s s
A p p lic a tio n
P ro g ra m m in g
/
4
© SAP AG
5
Overview of ABAP
◼ ABAP is tightly integrated across all the modules like SD, MM, FI, CO, HCM, etc.
and most or all of the modules and transactions (note that the screens are
created using ABAP)
◼ All application programs, along with parts of the R/3 Basis system, are written in
the ABAP Workbench using ABAP
◼ Not every SAP user is allowed to create ABAP objects in SAP system, only user
with developer key is allowed
6
ABAP Workbench
◼ The ABAP Workbench provides access to development tools which cover the
entire software development cycle
◼ All applications created with the ABAP Workbench can run without further
modifications on any platforms, database systems and graphical user interfaces
supported by SAP
◼ ABAP Workbench consists of many tools for like ABAP Editor, Screen Painter,
Function Builder, Menu painter… for you to create or write Programs like
Reports or Screens or Menus etc ...
7
ABAP Objects
A B A P /4 P ro g ra m O b je c ts
D e v e lo p m e n t c la s s
D e v . c la s s o b je c t ty p e s P ro g ra m
D ic tio n a ry o b je c ts G lo b a l d a ta
P ro g ra m s P B O m o d u le s
F u n c tio n g ro u p s P A I m o d u le s
In c lu d e s S u b ro u tin e s
T ra n s a c tio n s S c re e n s
L o g ic a l d a ta b a s e s G U I s ta tu s
M e s s a g e c la s s e s In c lu d e s
.
. T ra n s a c tio n s
.
© SAP AG
8
ALV Report
Introducing ALV
10
Navigating ALV Report
11
Sorting Record
2 1
12
Showing Record Details
13
Filtering Record
2 1
14
Counting Total
15
Counting Total
16
Counting Subtotal
2
1
17
Counting Subtotal
18
Downloading Report as HTML Format
19
Downloading Report as Text Format
20
Changing Layout
21
Basic ABAP
Creating an ABAP Program
23
Maintaining an Existing Program
◼ To edit an existing program, enter its name on the initial screen of the ABAP
Editor (Transaction code SE38), select one of the following components, and
then choose Display or Change
◼ Source Code – Starts the ABAP Editor
◼ Variants – Allows you to define fixed values for the input fields on the
selection screen of a report
◼ Attributes – Allows you to change the program attributes
◼ Documentation – Allows you to write documentation for a particular
executable program (report)
◼ Text elements – Allows you to maintain text elements including title and
headers, selection texts, and numbered texts, the text elements are
language independence of your program
24
Naming Convention
25
Types of ABAP Program
◼ Report Program
◼ Generates a list from database tables in a user defined format
◼ Does not alter the data in the database but only analysis (reads) them
◼ Can display the results on the screen or send to a printer
◼ Can either be run online or as background job
26
ABAP Syntax
A B A P /4 S y n ta x
DATA COUNTER TYPE I.
DATA NAME(20).
MOVE 1 TO COUNTER.
MOVE 'ABC' TO NAME.
. A B A P /4 p ro g ra m
.
. s ta te m e n t
WRITE NAME.
WRITE COUNTER.
w o rd 1 w o rd 2 w o rd 3
w o rd 4 .
k e y w o rd p a ra m e te r, fie ld ,
c o n s ta n t
© SAP AG
27
ABAP Syntax
28
Chain Statement
C h a in S ta te m e n ts
WRITE 'XYZ'.
WRITE NAME.
WRITE COUNTER.
ADD 1 TO COUNTER1.
ADD 1 TO COUNTER2.
ADD 1 TO COUNTER3.
© SAP AG
29
Formatting ABAP Statement
◼ You must separate word within a statement with at least one space
◼ You can write several statements on one line, or spread a single statement over
several lines
◼ You can concatenate consecutive statements with an identical first part into a
chain statement by writing the identical part only once and placing a colon (:)
after it
◼ Example - WRITE: SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-AIRPTO.
30
Comment
31
ABAP Program Layout
◼ To write a high quality program, you should keep certain layout standards for
ABAP Program
◼ Follow when structuring your program flow, and use as many as informative
comments as possible
32
ABAP Program Layout
33
Pretty Printer
34
Pretty Printer
35
WRITE Statement
* Syntax
WRITE <f> <AT position(length)>
<OPTION>
<AS CHECKBOX>
<AS SYMBOL>
<AS ICON>
<AS LINE>
36
WRITE Statement
◼ Common example:
37
WRITE Statement
◼ Consecutive WRITE
statements output data
on the same line
38
Common System Fields
39
Common Functions in ABAP Editor
◼ Pretty Printer
◼ Use to standardize the
layout of your program
◼ Activate
◼ When you activate a
program, the activation
process saves the
program in inactive
version first, checks
for syntax errors and
then generates the
active version
◼ Direct Processing
◼ Use to run the
program
40
Using ABAP Help
41
Tutorial
42
Revisit Basic ABAP
Data Type
44
Standard Data Type
45
Local Data Type
◼ Use the TYPES statement to define your own local data type
◼ For examples:
46
Global Data Type
47
DATA Statement
* Syntax
DATA var[(length)] [TYPE type] [Decimals number].
DATA var LIKE Table-Field [VALUE initial value].
48
CLEAR Statement
* Syntax
CLEAR <data object>.
49
Arithmetic Operation
◼ ABAP supports the four basic arithmetic operations, as well as power calculation
+ Addition
- Subtraction
* Multiplication
/ Division
DIV Integral division without remainder
MOD Remainder after integral division
** Exponentiation
50
Looping Operation
51
Looping Operation - DO Statement
◼ DO Statement:
DO <n> TIMES.
statements
ENDDO.
52
Looping Operation – WHILE Statement
◼ WHILE Statement:
ENDWHILE.
53
Looping Operation – LOOP Statement
◼ LOOP Statement:
statements
ENDLOOP.
54
IF Statement
IF <logical expression>.
statements
ENDIF.
IF <logical expression>.
statements
ELSE.
statements
ENDIF.
IF <logical expression>.
statements
ELSE.
statements
ENDIF.
55
CASE Statement
WHEN OTHERS.
statements
ENDCASE.
56
CHECK Statement
WHILE COUNTER GT 0.
◼ Bypass the following
statements and go to statements
next record CHECK FLAG NE SPACE.
statements
ENDWHILE.
57
EXIT Statement
EXIT.
ENDDO.
2 EXIT outside loop structure.
◼ Terminate a statements
subroutine without IF ... .
any condition EXIT.
ENDIF.
statements
58
CONTINUE Statement
CONTINUE.
DO 100 TIMES.
statements
◼ Terminate loop pass
immediately without IF SY-INDEX GE 10
any condition AND SY-INDEX LE 20.
CONTINUE.
ENDIF.
statements
ENDDO.
59
Logical Expression
◼ AND
COUNTER GE 0
◼ OR
◼ NOT
COUNTER GT 0 AND
FLAG IS INITIAL
60
MESSAGE Statement
* Syntax
MESSAGE text TYPE mtype.
MESSAGE { ID mid TYPE mtype NUMBER num | tn(id) }.
61
MESSAGE Statement
◼ Example:
62
MESSAGE Statement
◼ Example:
63
Message (SE91)
64
Tutorial
65
Transaction Code
Transaction (SE93)
1
2
67
Tutorial
68