You are on page 1of 32

Introduction to ABAP Programming

Course Objectives

In this Course, the participant will learn:


• ABAP Workbench Environment and Tools
• An Introduction to ABAP Programming
• Advanced techniques in ABAP Programming
• BDCs and Interfacing in the SAP Environment
• Enhancements & Modifications to SAP R/3
• Designing and Using SAP Forms (SAP Script)
• Dialog Programming
Topic Objectives

In this Topic, the participant will learn about:


• ABAP Editor and basics of an ABAP Program
• Simple Output Statement
• Data Declarations in ABAP
• Selection Criteria for ABAP Report Programs
• Control Statements
• SELECT Statement
• Internal Tables
• Workbench Organizer & Transport System
Topic Objectives

In this Topic, the participant will learn about:


• ABAP
ABAP Editor
Editor and ofBasics
and basics an ABAPof an ABAP
Program Program
• Simple Output Statement
• Data Declarations in ABAP
• Selection Criteria for ABAP Report Programs
• Control Statements
• SELECT Statement
• Internal Tables
• Workbench Organizer & Transport System
In this section, we will…

• Introduce the ABAP Programming Language


• Explain the ABAP Programming Environment
• Elucidate the different functions of ABAP editor
• Learn about the Basic ABAP Program structure
• Describe the different Program Attributes for
different types of programs
• Describe the various methods to run an ABAP
program
ABAP Programming Language

Advanced Business Application Programming


Introduction to ABAP
• Advanced Business Application Programming
• SAP’s proprietary language
• Byte-code interpreted language
• Event-Driven
• Tightly integrated with ABAP workbench
• Not case sensitive
• COBOL-like language
• Statement termination mark is Period (“.”)
• No line-continuation mark
• Commenting with Asterisk (*) and double-quote (“)
Reporting using ABAP

• “Lists” or “Reports” are produced using Report Programs


• Reports can be made interactive by using some ABAP techniques
• Programs can be executed both online and in background
• Background jobs can be scheduled to run at specified intervals
Components of an ABAP Program

Screens Values in
variants
xy 007
Source code xz 008 Docum entation
Text elem ents Application Help

INCLUDE mz_test_top. Use


H allo W elt!
INCLUDE mz_test_i01. ...
INCLUDE mz_test_o01.
INCLUDE mz_test_f01. H ello w orld! Integration
... ...
PROGRAM sapmz_test_.
Interface ¡H ola m u nd o!
TYPES: ...
DATA: .... O bject E dit G oto E xtras S ettings System Help
... O bject E dit GContinue
o to E xtras E nvironm ent S ystem Help
Continue
First line
MODULE s_100 OUTPUT. First line Zeile
Letzte
... LastZurück
line
ENDMODULE. Back
M ehr Ziele < Erstes Bild
M ore
Tabellentyp
< First screenBild
Letztes
MODULE ok_100 INPUT. Table type LastErstes
Zurück screen
Feld
... Back First field Feld
Letztes
ENDMODULE. Last field

FORM calc using ....


Changing .
...
ENDFORM.
Structure of a Program

D e c la r a tio n s P R O G R AM s apbc402_rund_test.
T Y P E S : . . .
D A T A : .. . .
D ia lo g m o d u le C O N S T ANT S : ...
M O D U L E s _ 100 OUTPUT.
. . .
E N D MODULE.
. . .
. . .
E v e n t b lo c k
I N I TIALIZATION.
. . .
. . .
S T A RT-OF-SELECTION.
. . .
. . .
. . .
. . .
. . .
P ro c e d u re F O R M calc USING ...
CHANGING ...
...
ENDFORM.
Terms to Remember

Program
•A series of ABAP statements.

Report:
An ABAP program whose output is a list:

Module Pool:
A dialog program which is a collection of screens

List:
The output generated by an ABAP report
program.
The ABAP Editor
Programming Environment: ABAP Editor
Programming Environment: Online Debugging
Basic Functions of the ABAP Editor

Standard toolbar
Find and
Repeat Find

Syntax
SyntaxCheck
Check Execution (F8)
(Ctrl+F2) ABAP help (F1)

Display/change mode Where used list


Activation (Ctrl+Shift+F3)
(Ctrl+F3)
(Ctrl+F1) .
General ABAP Program Execution

A B A P P ro g ra m

P ro c e s s in g
D e c la ra tio n s
b lo c k
p a s s iv e p a s s iv e
ABAP
ru n tim e
s y s te m

P ro c e s s in g P ro c e s s in g a c tiv e
b lo c k b lo c k
p a s s iv e p a s s iv e
Basic ABAP Program syntax

DATA COUNT TYPE I.


DATA TITLE(25).
MOVE 1 TO COUNT.
MOVE ‘President’ TO TITLE.
WRITE TITLE.
WRITE COUNT. ABAP Program

Statement.

Word 4
Word 1 Word2 Word3
.

Keyword or Parameters, fields, Additions or End of statement


Statement or constants clauses
ABAP Program Structure

Program Name Area


Use REPORT for listing programs
Use PROGRAM for online programs

Declaration Section
Used for defining tables,variables and constants

Statement Section

Used for coding executable ABAP statement


Chaining Statements in ABAP

DATA COUNT TYPE I.


DATA TITLE(25).
MOVE 1 TO COUNT.
MOVE ‘President’ TO TITLE.
WRITE TITLE.
WRITE COUNT. DATA: COUNT TYPE I,
TITLE(25).

MOVE: 1 TO COUNT,
‘President’ TO TITLE.

WRITE: TITLE, COUNT.


Comments in ABAP

A double quotation mark(“) anywhere on


a line makes everything
that follows a comment.

An asterisk (*) in column 1


makes the entire line
a comment line.
ABAP Program Attributes
ABAP Program Attributes (contd.)
Running an ABAP Program

An Alternative Method:
From the system
Menu,choose Services
->Reporting to launch
the program.

OR
From the ABAP Editor: From the ABAP Editor: Initial Screen, type
With the program displayed, the program name, then click on the
“Execute” push-button.
program->Execute
Topic Objectives

In this Topic, the participant will learn about:


• ABAP Editor and basics of an ABAP Program
• Simple
Simple Output
Output Statement
Statement
• Data Declarations in ABAP
• Selection Criteria for ABAP Report Programs
• Control Statements
• SELECT Statement
• Internal Tables
• Workbench Organizer & Transport System
In this section, we will…

• Define a simple “Hello World” program


• Explain the “WRITE” statement and its
variations
• Know about ABAP format specifications
• Define the NEW-PAGE statement
• Explain Page Headers in reports
• Describe the use of Text Symbols
The ABAP “Hello World” Program

report zitatrg1.
write ‘Hello World – SAP R/3’.
“WRITE” Statement – Simple Form

• Syntax:
WRITE [AT] [/P(L)] v1[+O(SL)]
[UNDER v2 | NO-GAP].
• Used to output contents of a field (or sub-field)
in a certain format
• The output of the WRITE statement is printed
as a “List”
• Specify additions to position, color, mask,
and format variables and print Symbols,
Icons and Lines
“WRITE” Statement (contd.)
WRITE ‘**************************’
SKIP 2.
WRITE: ‘The date today is:’, SY-DATUM,
‘The current time is:’ SY-UZEIT.
Note that there is an automatic
SKIP 2. space between the fields written
WRITE ‘***************************’. to the list.

< program title>


1
---------------------------------------------------------------------------------
******************************

The date today is: 11/14/2001 The current time is:


12:32:06

******************************
ABAP Format Specifications
Write 10 ‘****City of Mumbai****’.
SKIP2.
WRITE: 10 ‘Ticket Date’ , SY-DATUM.
WRITE: /10 ‘Ticket Time’ , SY-UZEIT.
ULINE /10(60).
SKIP2.
WRITE 10 ‘****Department of Public Safety****’

**** City of Mumbai****

Ticket Date 11/14/2003


Ticket Time 18:01:00
--------------------------------------------------------------------
****Department of Public Safety****
“NEW-PAGE” Statement
WRITE ‘****City of Mumbai****’
SKIP.
WRITE: / ‘Ticket Date’,15 SY-DATUM.
WRITE: / ‘Ticket Time’,15 SY-UZEIT.
SKIP.
WRITE ‘****Department of Public Safety****’.
NEW-PAGE. <program title> 1
WRITE: ‘Comments:’. ------------------------------------------------------------------------------
****City of Mumbai****
Ticket Date 11/14/2003
Ticket Time 18:01:00
****Department of Public Safety****
<program title> 2
_________________________________________________
Comments:
Maintaining Page Headers

List header will replace


title on first line of
standard header

Up to four lines of
column headings can
be maintained for the
list.
Numbered Texts ( Text Symbols )

WRITE: /TEXT-001,
TEXT-002,
SY-DATUM.

Text symbols
are referenced
by a unique
three character
code.

You might also like