Professional Documents
Culture Documents
Objectives:
Content
Introduction R/3 Basis system overview
ABAP/4 overview
Component, Program, ABAP dictionary, Function Module ,
Message/Transaction code, etc.
R/3 user
R/3 user
Presentation component
ABAP
Workbench
R/3 Basis
system
R/3
R/3
Application 1 ... Application N
Database
Content
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
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
SE41 - Menu Painter : Used to design the menus that appear in your
interface
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
Executable program(Report/Interface)
Can be started with transaction code/directly/background
(via SE38 or SA38 - For example: RMCB0100 )
INCLUDE program
Can not run on its own, has been included in other program
Module pool
Processing step of screens, can be executed via transaction code or
Menu function (For example: SAPMV45A - Sale order processing)
Function group
Contain function modules (SE37)
Subroutine pool
Externally-called subroutines
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
ABAP Dictionary
SE11 - Data dictionary
View
Table
Structure
Data element
ABAP Dictionary
Domain
F4
Search help
Lock object
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
Function module
Function Module
- ABAP/4 program: Include program
- Special external subroutines (include) stored in a central library
- Different from normal ABAP routine is the clearly defined interface
for passing data to and from the function module. The calling
program
and the called function module have separate work areas
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
Message
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
Transaction code
Transaction type:
Dialog transaction - Flow by sequence of screens (for example FB03)
Report transaction - Start program with type 1 (for example MCBA)
Variant transaction - (client specific) start another transaction with variant
(for example UPAR)
Note :
ABAP/4 overview
Topics:
Often used transactions
What is ABAP/4 program?
ABAP dictionary
Function Module
Message
Transaction code
Authorization in ABAP object
Program authorization
Transaction code
Table maintenance/Data browser
Content
Topics:
Event in ABAP/4 program
- Dialog module
- Executable program (Selection screen,
lists)
100
Transaction code
has been
requested from
R/3 user
200
300
PBO Module.
Module xxxx
Module yyyy
PAI Module
Module aaaa
PBO
Module.
Module
bbbb
Module xxxx
Module yyyy
PAI Module
ModulePBO
aaaaModule.
Module Module
bbbb xxxx
Module yyyy
PAI Module
Module aaaa
Module bbbb
Module pool
Question??
Topics:
Event in ABAP/4 program
- Dialog module
- Executable program (Selection screen,
lists)
Statement
The ABAP programming language consists of the following
element types: STATEMENT, KEYWORD, COMMENT.
An ABAP program consists of individual ABAP statements.
Each statement begins with a keyword and ends with a
period. There might be comment in the same line as a
statement
For example:
PROGRAM ZTEST.
Keywords
Declarative keywords :
Declarative keywords
TYPES create user-defined elementary data types and structured data types
Example TYPES: surname(20) TYPE C.
DATA define local/global variable for structure/internal table/memory block
address OCCURS 0
Example DATA: BEGIN OF address,
address_number(10) TYPE C,
street(30),
Internal
structure
table
Modularization keywords
Event define keywords
INITIALIZATION
AT SELECTION-SCREEN
START-OF-SELECTION
GET <table>
END-OF-SELECTION
TOP-OF-PAGE
END-OF-PAGE
AT LINE-SELECTION
AT USER-COMMAND
Define subroutine
FUNCTION...ENDFUNCTION
Define Function module
MODULE...ENDMODULE
After process selection screen
Built in function
Arithmetic & string function
ABS
SIGN
CEIL
FLOOR
TRUNC
FRAC
STRLEN
1. SELECT statements
2. SAP tables vs. Internal Tables
3. LOOP-ENDLOOP
4. WRITE statements
5. Comment in ABAP
6. Expressions and Operations in ABAP
7. Subroutines: FORMS, FUNCTION MODULE
SELECT statement
to read table entries (records) from a table (database)
the return code is stored in system field SY-SUBRC
- 0: if one or more table entries were retrieved
- 4: if no table entries were retrieved (table is
empty/ no data match the criteria)
SELECT statement
For selecting individual columns from a table:
( full key )
SELECT
AVG( <f1> )
COUNT( DISTINCT <f1> )
COUNT( * )
MAX( <f1> )
MIN( <f1> )
SUM( <f1>
FROM <dbtab> . . .
INTO (<g1> . . . <gn>)
SAP Table
Table fields
Foreign keys
Technical Settings
Indexes
Internal Table
One way to process large quantities of data in ABAP
Internal table is a dynamic sequential dataset in which
all records have the same structure and a key
The data is taken from a fixed structure, stored line by
line in the memory
LOOP Command
To perform looping operation in the flow logic
Four kinds of loops in ABAP:
Unconditional loops using the DO statement
Conditional loops using the WHILE statement
Loops through internal tables and extract datasets
using the LOOP statement
Loops through datasets from database tables using
SELECT statement
DO Command
DO
<n>
TIMES.
statements
ENDDO.
SY-INDEX
Loop index
ENDWHILE.
SY-INDEX
Loop index
LOOP AT IT_T001K.
WRITE: / IT_T001K-BWKEY.
ENDLOOP.
WRITE Command
The basic ABAP statement for displaying data on the
screen
WRITE <f> <AT position(length)>
<option>
<AS CHECKBOX>
<AS SYMBOL>
<AS ICON>
<AS LINE>
WRITE Command
<OPTION> behind the WRITE statement is for formatting options
E.g. : ..NO-ZERO, NO-SIGN, No GROUPING, DD/MM/YY,
WRITE: / Write.
WRITE: it_bseg-dmbtr CURRENCY it_bkpf-hwaer.
WRITE: text-t01 LEFT-JUSTIFIED.
Comment
Written between statements of the ABAP program to
explain its purpose to a reader / for internal
documentation
Helps to understand and change the program
Flagged by special character:
Asterisk (*) entire line to be a comment
Double quotation mark () part of a line to be a
comment
Ignored by the system
Comment example
* Write Sales Order number to the screen
Write: Sales Order : ,
20 it_vbak-vbeln. Sales Order Number
Relational Operator
String Comparison
Logical Expression
If/Case/Check Statement
Exit/Continue Statement
Display
Relational Operator
EQ =
Equal to
NE <> ><
Not equal to
GT >
Greater than
GE >= =>
LT <
Smaller than
LE <= =<
Meaning
Interval
Initial value
CA
<f2>
<f1> CS <f2>
'ABCDE'
CS
<f1> CP <f2>
'ABXDE'
CP
'DE'
contains pattern: f1 corresponds to the model f2
Model:
* any string
+ any character
# escape symbol
'*B+D*'
Logical Expression
1. AND
2. OR
3. NOT
COUNTER GE 0
COUNTER GT 0 AND
FLAG IS INITIAL
( FLAG1 NE SPACE OR FLAG2
NE SPACE ) AND COUNTER
BETWEEN 0 AND 100
COUNTER EQ 0 AND NOT
( FLAG1 EQ SPACE AND FLAG2
EQ SPACE )
IF Statement
IF <logical expression>.
statements
ENDIF.
IF <logical expression>.
statements
ELSE.
ENDIF.
statements
IF <logical expression>.
statements
ELSE.
statements
ENDIF.
CASE statement
Execute different
statement blocks
depending on the contents
of particular data fields
WHEN OTHERS:
contents of <field>
does not equal to any
of the <value?>
contents
CASE <field>.
WHEN <value1>.
statements
WHEN <value2>.
statements
WHEN <value3>.
statements
WHEN OTHERS.
statements
ENDCASE.
CHECK statement
1
Within Loop:
to terminate loop
pass conditionally
statements
ENDWHILE.
2
CHECK <condition>.
statements
Terminate loop
entirely without
any condition
Terminate a
subroutine
without any
condition
EXIT.
1
statements
IF COUNTER GE 100.
EXIT.
ENDIF.
statements
ENDDO.
EXIT outside loop structure.
statements
IF ... .
EXIT.
ENDIF.
statements
CONTINUE.
DO 100 TIMES.
Terminate loop
pass
immediately
without any
condition
statements
IF SY-INDEX GE 10
AND SY-INDEX LE 20.
CONTINUE.
ENDIF.
statements
ENDDO.
PROGRAM RSDEMO01.
Call calculate_tax
..
.
Subroutine
Calculate_tax
PROGRAM RSDEMO02.
..
.
Call calculate_tax
..
.
PROGRAM RSDEMO03.
..
.
Call calculate_tax
Function module
Avoid redundancy
Modularization:
easy to read
easy to call
PROGRAM RSDEMO04.
Subroutine SUB1
Subroutine
Calculate_tax
ABAP/4 function library
Function module
Calculate_tax
Define
FORM <name> [<parameters>].
<statement block>
ENDFORM.
Calling internally
PERFORM <name> [<parameters>].
Calling external subroutine
PERFORM <name>(program name) <parameters>
[IF FOUND]
Parameters:
p_path like rlgrap-filename.
..............................
perform f_check_file_exists using p_path.
Content
Introduction R/3 Basis system overview
ABAP/4 overview
Component, Program, ABAP dictionary, Function Module ,
Message/Transaction code, etc.
PgmID:
Program Id in request and task, normally there are 2 types for ABAP objects
R3TR - name for R/3 Repository objects and Customizing objects
Version management
serves different purposes and user groups:
- The developer can keep track of his or her work ("What have I changed?")
- The developer can restore a previous version by reactivating it.
- The system administrator can monitor work ("Which objects were changed and
how were they changed in a specific time interval?")
- It provides the basis for the auditor, who requires a complete history of
changes.
- It enables customers to adjust data with the help of the system after upgrading
to a new Release.
Content
Type of problems
ABAP Runtime Error
Cause: Program error, system exception, database process error, etc.
Using transaction code ST22 to analyze error.
Unexpected message
Update Terminate
Cause: Update module can not be completed
Program bug
Cause: Written code is not correct
Double click to
display detail
Unexpected message
Update terminate
Program bug
Simple Debugging
How to:
Switch on the debugger.
Set and delete static and dynamic breakpoints.
Set Watch points.
Stop a program at specific key words or events or when a fields
contents change.
Continue processing after an interrupt.
Display field contents during runtime.
Display the contents of an internal table.
Change field contents for testing purposes.
Change the contents of an internal table.
Display and use the debuggers six different views.
Simple Debugging
Start debugging:
/h
Start the debugger in Normal mode. Press enter to start.
/hs
Start the Debugger in System mode, for example, in order to debug
the system program (program with type S)
Appropriate menu options under system -> Utilities -> Debug ABAP
Break-points Command.
SE38 Start of programs in the debugging of transaction code SE38
SM50/SM51 via debugging menu
SE80 - Object browser
Simple Debugging
Set and delete static and dynamic breakpoints
Static break-point
Command BREAK-POINT. Or BREAK <User name>
Dynamic break-point
In ABAP Editor SE38 --> Utilities --> Breakpoints --> Display/Set
In Debugging mode
Place the cursor on the statement
Choosing break-point -> Set/Delete
At ABAP command
At Event/Subroutine
At Function module
System exception
Simple Debugging
Stepping
Display mode
Execute (F6)
Return (F7)
Continue (F8)
Simple Debugging
Caution when debugging in Production system
Since only a restricted number of dialog work processes can be
switched to debugging mode, you should leave the debugger as soon as
possible when you have finished working with it. Otherwise, the work
process is not released for other users
Question ??