Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
33K views

ABAP Programming Overview

The document provides an overview of ABAP (Advanced Business Application Programming) programming. It discusses the ABAP course outline which covers topics like list processing, open SQL, event-driven programming, modularization and debugging. It also describes the structure of ABAP programs, data objects in ABAP like variables, constants, structures and system fields. The document explains how to create and work with ABAP programs using transactions in SAP.

Uploaded by

Duy Sơn
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33K views

ABAP Programming Overview

The document provides an overview of ABAP (Advanced Business Application Programming) programming. It discusses the ABAP course outline which covers topics like list processing, open SQL, event-driven programming, modularization and debugging. It also describes the structure of ABAP programs, data objects in ABAP like variables, constants, structures and system fields. The document explains how to create and work with ABAP programs using transactions in SAP.

Uploaded by

Duy Sơn
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 393

ABAP Programming Overview

ABAP Course Outline


 Chapter 1 :
Introduction to ABAP
 Chapter 2 :
List Processing in ABAP
 Chapter 3 :
Open SQL & Internal Table
 Chapter 4 :
Event-driven Programming &
Selection Screen
 Chapter 5 : Modularization & Catch Statement
 Chapter 6 : Message, Debugging, File Transfer and
Type Group
ABAP Chapter 1
 Introduction to SAP Architecture
 ABAP Overview
 Data Object in ABAP
SAP System : 3 Tier Client/Server
SAP GUI SAP GUI SAP GUI Presentation
Server

SAP
Application
Server

DB Server
SAP SYSTEM (3 Tier Architecture)
SAP GUI SAP GUI

Presentation Layer
(Windows based)

SAP Instance
Application Layer
Dispatcher M
(Windows Server/UNIX)
Request SAP Buffer
Queue
(Shared Mem)

D D B V S E
G

Oracle
Database Layer
Informix
(Windows Server/UNIX)
DB2
Database Server
MS SQL Server
MaxDB
ABAP Programming Overview
ABAP Overview
MOVE … IF ...
DATA ...
WHILE...

WRITE ... SEARCH ...

*Comment... SELECT ...

DO ... LOOP AT ...


ABAP

Advanced
Business
Application
Programming
ABAP Feature

 Declaring data with various types and structure


 Operational elements for data manipulation
 Control elements for controlling the program
flow
 Event elements for reacting to external events
ABAP

 Operating/Database system-independent
programming
 ABAP contains a subset of SQL called Open SQL
for comfortable database access for various
database
ABAP Programming

 ABAP Report
 Dialog Programming(Transaction)
ABAP Program : Report

Report Program
: attribute type 1
(executable)
Reading
Data

Database

 Reading data
Types of ABAP Report

1. Report Listing
2 2. Drill-down Report
3. Control-break Report
4. ALV Report
ABAP Program : Dialog Program

Dialog Program
: attribute type M
(Module Pool)
Reading
Data

Writing

Database

 Reading and changing data


Dialog Program : Transaction
ABAP Programming
How to create ABAP program

Transaction Code : SE38


Transaction : SE38
Program Attribute
ABAP Editor
The Structure of the Language
 Each statement must end with a period

DATA tmp TYPE I.


WRITE ‘Hello World’. WRITE ‘OK’.
Literal

DATA tmp TYPE I. Text Literal


WRITE ‘Hello World’.
WRITE ’10’. Text Literal
MOVE 9 TO tmp.
Numeric Literal
Chained Statements
 Successive statements that have the same string
segment can be combined to form a single
chained statement
 To do so, you specify the identical starting
segment once and conclude it with a colon (:),
the remaining segments are then listed,
separated by commas (,) and concluded with a
period (.)
 At runtime, a chained statement is treated like
an equivalent sequence of individual ABAP
statements
Chained Statements

WRITE ‘Hello World’.


WRITE ‘OK’.
=
WRITE: ‘Hello World’, ‘OK’.

DATA tmp1 TYPE I.


DATA tmp2 TYPE C.
=
DATA: tmp1 TYPE I,
tmp2 TYPE C.
Chained Statement

MOVE sy-subrc TO tmp1.


MOVE sy-subrc TO tmp2.
MOVE sy-subrc TO tmp3.
=
MOVE sy-subrc TO: tmp1,
tmp2,
tmp3.
Chained Statement

PERFORM cal_1 USING a1 a2.


PERFORM cal_1 USING a3 a4.
=
PERFORM cal_1 USING: a1 a2,
a3 a4.
Comments

* This is full line comment


WRITE ‘Hello World’. “ Write data (partial line comment)
WRITE ‘Test’.
ABAP Command : Case Sensitivity
 ABAP command is not case sensitive

WRITE ‘Hello World’.


WriTe ‘Hello World’.
wRiTE ‘Hello World’.
Data Objects in ABAP
Data Objects in ABAP
Memory Space
Variable Structure

Table Structure Internal Table

Constants <Field-symbols>
Variable
Variable

 Variables can be declared at any point in a program


 Variables can be up to 30 characters in length

REPORT ZTEST.
DATA firstname TYPE STRING.
firstname = ‘John’.
Predefined ABAP Data Types
Type Description Initial Value Length
C Character Space 1 – 65535

D Date ‘00000000’ 8 characters

F Floating Point 0.0 8 bytes

I Integer 0 4 bytes

N Numeric Text ‘0’ 1 – 65535

P Packed Decimal 0 1 – 16 bytes

T Time ‘000000’ 6 characters

X Hexadecimal ’00’ 1 – 65535

String Variable-length Space Variable

xstring Variable-length Blank string Variable


Hexadecimal
Defining Variable with DATA Statement

* Syntax
DATA var[(length)] [Type type] [Decimals number].

DATA var LIKE Table-Field [VALUE initial value].


Defining Variable with DATA Statement

* Data Declaration
DATA: tmp(10) TYPE C,
tmp1 TYPE I,
tmp2(8) TYPE P DECIMALS 2 VALUE ‘1.50’.
DATA: tmp3(5) TYPE N,
tmp4.
Defining Variable with DATA Statement

* Data Declaration
DATA customerno LIKE customers-id.
DATA matnr LIKE mara-matnr.

DATA customerno TYPE customers-id.


DATA matnr TYPE mara-matnr.
ABAP Predefined Data Types

ABAP Predefined Data Types

Complete Types Incomplete Types


(I,F,D,T,STRING and XSTRING) (C,N,P and X)
Variable

 Data Type C,N and X length between 1 – 65535 (Default


1) DATA tmp(10) TYPE C.

 Data Type P length between 1 – 16 (Default 8) and


decimals length between 0 – 31 DATA tmp(5) TYPE P DECIMALS 2.

 Data Type I value between – 231 to 231 – 1


or –2,147,483,648 to 2,147,483,647
DATA tmp TYPE I.
tmp = 1000000.
Data type N

data tmp(5) type N.


tmp = ‘Xca9yy23K6’.
ABAP Error
ABAP Error
Syntax Runtime
Error Error

User Runtime System Runtime


Error Error

Cannot Allocate Time Exceed


Space (10 Minutes)
User Runtime Error

DATA result TYPE i.


result = 10 / 0.
System Runtime Error : Space Allocation
System Runtime Error : Time Exceed
Non-elementary Type

* Data Declaration
TYPES tname(30) TYPE c.
DATA: customer_name TYPE tname,
firstname TYPE tname.
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.
Value Assignment

* Value assignment
DATA: tmp1 TYPE i,
tmp2 TYPE i.
tmp1 = tmp2 = 10.
ABAP Practice
Structure

* Syntax
DATA BEGIN OF <structure name>.
DATA field1.
DATA field2.


DATA END OF <structure name>.
Structure
wa

* Syntax id name city


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.
Defining Structure (Include Structure)

* Include Structure
DATA BEGIN OF wa.
INCLUDE STRUCTURE customers.
DATA tel(7).
DATA END OF wa.
Defining Structure

* LIKE option
DATA wa LIKE customers.
wa-id = 1.
wa-name = ‘John’.
WRITE: wa-id, wa-name.
ABAP Practice
Constants

* Constant variable
CONSTANTS max_no TYPE I VALUE 999.
DATA counter TYPE I VALUE max_no.
WRITE: max_no, counter.
Constants Using Example

* Constant variable
CONSTANTS ctext(11) TYPE C VALUE ‘Hello World’.
WRITE ctext.
WRITE ctext.
WRITE ctext.
WRITE ctext.
WRITE ctext.
System Fields
 The system fields (structure syst) are filled by
the runtime environment. You can use them
to query the system status in an ABAP
program
 You should access them only for reading
 sy-datum = Current date of application server
syst-datum  sy-uzeit = Current time of application server
 sy-datlo = Current date of SAP GUI
 sy-timlo = Current time of SAP GUI
 sy-mandt = Current client logon
 sy-subrc = Return value of ABAP statement
ABAP System Fields : Structure SYST (SE11)
DATE

* Fixed Length 8
* Include Representation ‘YYYYMMDD’
DATA today TYPE D.
today = sy-datum.
WRITE today.
today = ‘19991231’.
WRITE today.
TIME

* Fixed Length 6
* Format ‘HHMMSS’
DATA times TYPE T.
times = sy-uzeit.
WRITE times.
HHMMSS
MOVE Statement

DATA wa LIKE customers.


DATA vender LIKE customers.
wa-id = ‘1234’.
wa-name = ‘Test#1’.
MOVE wa TO vender. “vender = wa.
WRITE: wa-id, vender-name.
MOVE-CORRESPONDING Statement

DATA: begin of wa1,


f1,f2,f4,
end of wa1.
DATA: begin of wa2,
f2,f1,f3,
end of wa2.

MOVE-CORRESPONDING wa1 TO wa2.
WRITE: wa1-f1,wa2-f1 .
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>.
Field-symbols : UNASSIGN

data: name(4) Value ‘Test’,


field-symbols <temp>.
assign name To <temp>.
write <temp>.
unassign <temp>.
CLEAR Structure

Example:
DATA tmp type i value 9.
tmp = 10.
CLEAR tmp.
DATA wa like customers.

CLEAR wa.
ABAP Report : Program Structure

Report ztest.
*Data objects declaration
data ...
data begin of ...
*Program Logic(Data objects processing)

write ….
ABAP Chapter 2
 Report Statement
 Write & Format Statement
 Flow Control in ABAP
 Manipulating Character Data
 Report Driven : Page Report (List Header)
List Processing

Report
Header
Report
Listing
(Body)
Report Statement
* Syntax
REPORT <report name>
[NO STANDARD PAGE HEADING]
[LINE-SIZE no of columns]
[LINE-COUNT no of lines[(no of footer)]].

REPORT ztest1 NO STANDARD PAGE HEADING.


REPORT ztest LINE-SIZE 132 LINE-COUNT 65(2).
sy-linsz
Text Element : Title&Headers
Report ztest.
Write ‘Hello World’.

 Text Element
 Title and Headers
List Header This is test program by Prapoj
Column Header
Column Column
#1 #2
Creating Lists
 ABAP statement that create list
 WRITE
 SKIP
 ULINE
 The complete report list will appears
automatically at the end of the
processing block
List Buffer

Dialog WP Local Memory

Memory Space
TaskHandler

ABAP Processor
List Buffer
WRITE,SKIP,ULINE
Dynpro Processor

DB Interface
WRITE Statement

* Write data
WRITE ‘Hello World’.
WRITE: ‘OK’, ‘Test data’.
WRITE: /15(10) ‘ABCDEFGHIJKLMNOPQ’.
WRITE /20 ‘Test data’.
Breaking to a New Line

* Write data
WRITE: / ‘First Line’, ‘Data 1’,
/ ‘Second Line’, ‘Data 2’,
/(20) ‘Third Line’, ‘Data 3’,
/35 ‘Fourth Line’, ‘Data 4’.
sy-colno
Text Symbol

Report ztest.
Write: Text-001,
Text-002.
 Text Element
 Text Symbols
 Text Symbol Text

001 Text 1

002 Text 2
Text Symbol
write: / Text-001.
write: / Text-001.
write: / Text-001.
write: / Text-001.
write: / Text-001.
Column Position

DATA colno type I value 10.


write: /5 ‘Hello’, at colno ‘World’.
write: at /colno ‘OK’.
Options of the WRITE Statement

* Write Syntax
WRITE var [NO-ZERO]
[NO-SIGN]
[NO-GROUPING]
[NO-GAP]
[DECIMALS no of decimals]
Suppressing Blanks(NO-ZERO)

* No Zero
DATA: number(10) TYPE N VALUE 23.
WRITE: number, number NO-ZERO.
Suppressing Number(+ / -) Sign

* No Sign
DATA: v_integer TYPE I VALUE -1.
WRITE: v_integer, v_integer NO-SIGN.
NO-GROUPING

* No grouping
DATA: v_integer TYPE I VALUE 120000.
WRITE: v_integer, v_integer NO-GROUPING.
NO-GAP

* No gap
WRITE: ‘Hello’ NO-GAP, ‘World’.
DECIMALS

* Decimals
DATA: v_pack TYPE P DECIMALS 4
VALUE ‘1234.5678’.
WRITE: v_pack, v_pack DECIMALS 2.
Formatting Options

* Format options of WRITE statement


* LEFT-JUSTIFIED for Integer data
* RIGHT-JUSTIFIED for Character data
* CENTERED
Data tmp1(20) value ‘test’. test
WRITE: tmp1 CENTERED.
Inserting Blank Lines(SKIP)

*Skip Statement
SKIP.
WRITE: ‘Hello World’, sy-linno.
SKIP.
WRITE: ‘Test 1’.
SKIP 5.
WRITE: ‘Test 2’.
SKIP TO LINE 20.
WRITE ‘This is line 20’.
Inserting Horizontal Lines(ULINE)

* Uline
WRITE: ‘Hello World’.
WRITE: /5(35) sy-uline, sy-vline.
ULINE /5(35).
ULINE.
WRITE: / ‘This is an underline’.
ULINE /(18).
Frame

uline: /(45).
write: /1 sy-vline, 'Column #1',
15 sy-vline, 'Column #2',
30 sy-vline, 'Column #3',
45 sy-vline.
uline: /(45).
Exercise I

sy-datum sy-uzeit
FORMAT Statement

FORMAT [INTENSIFIED]
[INTENSIFIED OFF]
[COLOR <color>]
[COLOR OFF]
[HOTSPOT ON]
[HOTSPOT OFF]
[RESET]
FORMAT Statement

FORMAT COLOR 1.
WRITE: / ‘Hello World’, ‘Test’ COLOR 7.
FORMAT COLOR OFF.
FORMAT COLOR
FORMAT COLOR col_heading. “color 1
FORMAT COLOR col_normal. “color 2
FORMAT COLOR col_total. “color 3
FORMAT COLOR col_key. “color 4
FORMAT COLOR col_positive. “color 5
FORMAT COLOR col_negative. “color 6
FORMAT COLOR col_group. “color 7
FORMAT COLOR col_background. “color off
Exercise I
Include Program
 You can create a program with program type include program
in the program attribute
 Include program do not have to have an introductory statement
 During the syntax check and during program generation by the
ABAP compiler, the INCLUDE statement is replaced by the
source text of the defined include program

REPORT ztest1.
Include Program : ZINCLUDE1
INCLUDE zinclude1. Data tmp(10).
… Data tmp1 type i.
Data tmp2 type p. REPORT ztest2.
Data tmp3.
INCLUDE zinclude1.

Symbols and Icons
* Display Icon or Symbol in List
INCLUDE <LIST>.
WRITE: / ‘Phone :’, SYM_PHONE AS SYMBOL.
WRITE: / ‘Alarm :’, ICON_ALARM AS ICON.
WRITE: / ‘Green Light :’,
ICON_GREEN_LIGHT AS ICON HOTSPOT.
FORMAT HOTSPOT ON.
WRITE: / ‘Hello ABAP’, ’Hi!’.
FORMAT HOTSPOT OFF.
Flow Control in ABAP
Flow Control in ABAP

 Branching ==> IF, CASE.


 Looping ==> DO, WHILE.
IF Statement

IF <Condition>.
<Statement Block>
ELSEIF <Condition>.
<Statement Block>
ELSEIF <Condition>.
<Statement Block>
ELSE.
<Statement Block>
ENDIF.
IF Statement

IF sy-mandt = ‘100’.
WRITE: / ‘This is Production Client’.
ELSEIF sy-mandt = ‘800’.
WRITE: / ‘This is Development Client’.
ELSE.
WRITE: / ‘This is Test Client’.
ENDIF.
CASE Statement
CASE <field>.
WHEN <value1>.
<Statement Block>
WHEN <value2>.
<Statement Block>
...
WHEN OTHERS.
<Statement Block>
ENDCASE.
CASE Statement
CASE sy-mandt.
WHEN ‘100’.
WRITE: / ‘Production Client’.
WHEN ‘800’.
WRITE: / ‘Development Client’.
WHEN OTHERS.
WRITE: / ‘Test Client’.
ENDCASE.
DO Statement

DO.
WRITE sy-index.
IF sy-index = 3.
EXIT.
ENDIF.
WRITE: sy-index.
ENDDO.
CONTINUE Statement

DO 5 TIMES.
IF sy-index = 3.
CONTINUE.
ENDIF.
WRITE: sy-index.
ENDDO.
CHECK Statement

DO 4 TIMES.
CHECK sy-index BETWEEN 2 AND 3.
WRITE: sy-index.
ENDDO.
WHILE Statement

DATA: count TYPE I value 1.


WHILE count <> 4.
WRITE: sy-index.
count = count + 1.
ENDWHILE.
Logical Expressions
>,GT
<,LT
>=, =>, GE
<=, =<, LE
=, EQ
<>, ><, NE
BETWEEN value1 AND value2
IS INITIAL
Arithmetic Operators
+ , - , * , / , **
DIV
MOD

Example :
9 / 2 = 4.5
9 DIV 2 = 4.0
9 MOD 2 = 1
SQRT( 2 ) = 1.41
2 ** 4 = 16
Character String Operator

T
if ‘AABB’ co ‘AB’. F
if ‘ABCD’ co ‘ABC’.
T
if ‘AXCZ’ ca ‘AB’.
F
if ‘ABCD’ ca ‘XYZ’.
T
if ‘ABCD’ cp ‘+B*’.
Manipulating Character Data
Manipulating Character Data

* Substrings with offsets


DATA tmp(10) VALUE ‘ABCDEFGHIJ’.
DEFGHIJ
DATA tmp1(2).
WRITE: tmp+3(7), BCDE
tmp+1(4), ABCDEFGH
tmp+0(8),
HIJ
tmp+7(3).
MOVE tmp+4(2) TO tmp1.
SHIFT Statement
* SHIFT Statement
DATA tmp(5) VALUE ‘12345’.
SHIFT tmp. 2345_
SHIFT tmp BY 2 PLACES. 345__
SHIFT tmp BY 2 PLACES CIRCULAR. 34512
SHIFT tmp UP TO ‘3’. 345__
SHIFT tmp UP TO ‘3’ RIGHT. __123
SHIFT tmp UP TO ‘3’ RIGHT CIRCULAR. 45123
SHIFT tmp RIGHT DELETING TRAILING SPACE.
SHIFT tmp LEFT DELETING LEADING SPACE.
SHIFT
* Shift
DATA name(30)
VALUE ‘Alexander Bill Charles’.
SHIFT name UP TO ‘Bill’.
WRITE: / name. Bill Charles
SEARCH(Non Case-sensitive
)
* Search
DATA tmp(5) VALUE ‘ABCDE’.
SEARCH tmp FOR ‘C’.

DATA tmp1(10) VALUE ‘Till Bill’.


SEARCH tmp1 FOR ‘Bill’.
IF SY-SUBRC = 0.
WRITE: / SY-FDPOS.
ENDIF.
TRANSLATE

* Translate
DATA tmp(5) VALUE ‘abc ‘.
TRANSLATE tmp TO UPPER CASE.
TRANSLATE tmp TO LOWER CASE.
TRANSLATE tmp USING ‘ 0’.
TRANSLATE tmp USING ‘ 0aA’.
REPLACE

* Replace
DATA tmp(20) VALUE ‘I was a boy’.
REPLACE ‘was’ WITH ‘am’ INTO tmp.
IF sy-subrc = 0.
write ‘Replace OK’.
ELSE.
write ‘Cannot find data to be replaced’.
ENDIF.
Removing Spaces(CONDENSE)

* Condense
DATA: tmp(20) VALUE ‘I am a boy’.
CONDENSE tmp. I am a boy
CONDENSE tmp NO-GAPS.

Iamaboy
Concatenation String(CONCATENATE)

* Concatenate
DATA: tmp1(2) VALUE ‘AB’,
ABCDE
tmp2(3) VALUE ‘CDE’,
tmp3(10).
CONCATENATE tmp1 tmp2 INTO tmp3.
CONCATENATE tmp1 tmp2 INTO tmp3
SEPARATED BY ‘ ‘.
AB CDE
Split

* Split
DATA: name(30) value ‘David, John, Peter’,
one(10), two(10), three(30).
split name at ‘,’ into one two three.
Working with Date Variables
* Date
DATA today TYPE D.
today = sy-datum.
WRITE: today, sy-
datum+0(4)
‘Year :’ , today+0(4),
‘Month :’, today+4(2),
‘Day :’ , today+6(2).
WRITE … TO …
DATA: today TYPE D, tmp(10).
today = sy-datum.
tmp = today.
WRITE tmp.
WRITE today TO tmp.
WRITE tmp.
CLEAR today.
WRITE today NO-ZERO TO tmp.
WRITE tmp.
Invalid Date

DATA: today TYPE D.


today = ‘20061321’.
today = today + 0.
if today is initial.
write: / ‘invalid date’.
else.
write: / today.
endif.
Built-in Functions
 ABAP provides a lot of built-in functions
 A Built-in function calculates a return
value from an argument
 abs = Absolute value of argument
 sign = +/- sign of argument
 sqrt = Square root
 strlen = Number of characters in arg
 xstrlen = Number of bytes in arg
STRLEN Built-in Function

DATA: tmp(20) VALUE ‘Test String’,


count TYPE I.
count = strlen( tmp ).
WRITE count.
STRLEN Built-in Function Example
DATA: tmp(20) VALUE ‘xxax’,
cntlen TYPE I.
cntlen = strlen( tmp ).
cntlen = cntlen – 2.
if tmp+cntlen(1) = ‘a’. “cntlen >= 0
write: / ‘OK’.
endif.
WRITE ‘

*If we need the word like this I’m a boy


WRITE: ‘I’’m a boy’.
Exercise
 Create program to display current month in text for example
October
Report Driven : Page Report
Application Driven Programming
REPORT ztest.
DATA: today TYPE D.
today = ‘20061321’.
today = today + 0.
IF today IS INITIAL.
WRITE: / ‘invalid date’.
ELSE.
WRITE: / today.
ENDIF.
Event Driven Programming
REPORT ztest.
DATA today TYPE D.
TOP-OF-PAGE.
<ABAP statement>
END-OF-PAGE.
<ABAP statement>
START-OF-SELECTION.
<ABAP statement>
Report Driven List Header
REPORT ztest NO STANDARD PAGE HEADING.
TOP-OF-PAGE.
FORMAT COLOR 1.
WRITE: /5 ‘User Name’, 25 ‘Program Name’.
ULINE.
START-OF-SELECTION.
WRITE: /5 sy-uname, 25 sy-repid.
Report Driven Page Footer
REPORT ztest no standard page heading LINE-COUNT 10(2).
TOP-OF-PAGE.
FORMAT COLOR 1.
WRITE: / ‘Page :’, sy-pagno.
ULINE.
END-OF-PAGE.
ULINE.
WRITE: / ‘To be continue on next page…’ .
START-OF-SELECTION.
DO 20 TIMES.
WRITE: / sy-index.
ENDDO.
TOP-OF-PAGE
REPORT ztest no standard page heading.

TOP-OF-PAGE.
FORMAT COLOR 1.
WRITE: / 'Report Header'.
ULINE.

START-OF-SELECTION.
DO 100 TIMES.
WRITE: / sy-index.
ENDDO.
ABAP Program Structure
Report ztest.
*Data declaration
data ...
data begin of ...

*Top-of-Page event
top-of-page.

*End-of-Page event
end-of-page.

*Start-of-selection
Start-of-selection.
ABAP Practice
Exercise II

sy-datum sy-uzeit

sy-uname
sy-repid
ABAP Chapter 3
 Open SQL
 Internal Table
SAP System : 3 Tier Client/Server
SAP GUI SAP GUI SAP GUI Presentation
Server

SAP
Application
Server

DB Server
SAP SYSTEM (3 Tier Architecture)
SAP GUI SAP GUI

Presentation Layer

(Windows based)
SAP Instance
Application Layer
Dispatcher
M
(Windows Request SAP Buffer
Server/UNIX) Queue
(Shared Mem)

D D B V S E G

Oracle
Database Layer
Informix
(Windows Database Server DB2
Server/UNIX) MS SQL Server
SAP DB/MaxDB
SAP System : Dialog Processing
SAP GUI

Report zpsm1.
Request Tables customers.
List Select single * from

1 Generate
10
customers where id =
1.
Application Server
Send Request
Screen(List) Write: / customers-
name.

Store request
3 Dispatcher
to queue Send 2 SAP Buffer
Search for
Request List9 7
Check
free5WPProgram in Program
Queue Send request Execute
4 Program Buffer Table
to WP D D D … D ABAP
… stateme
8 6
nt
Database Server SQL Load&Gen
Request Program
Dialog Work Process Architecture
Dialog Work Process Local Memory

Memory Space
TaskHandler

ABAP Processor
List buffer

DYNPRO Processor

DB Interface
Result Set Memory

Database Server
Open SQL
 SELECT ...
 INSERT ...
 UPDATE ...
 DELETE ...
DB Interface
SAP Application Server

Dialog WP Local Memory

TaskHandler Memory Space


ABAP Processor
DYNPRO
List Buffer
DB Interface

Result Set

~ 32 KB in length
Database Server

Data Data
Data Data
Data
Example Tables in DB

customers
spfli id name city

carrid connid cityfrom cityto distance


1 John New York
LH 0400 LA NY 100 2 Peter Singapore
LH 0402 BK NY 540 3 David London
SQ 0110 SQ BK 250
Example Tables in DB
sflight
carrid connid fldate price

LH 0400 20010101 150

LH 0400 20010110 145

LH 0400 20010228 130

SQ 0110 20010226 75
Select Overview
Select <result> Which Columns?
From <table> Which Table?
Into <destination> Where to place?
Where <condition> Which Lines?
Select Statement
 Select multiple records from database
SELECT * FROM customers.

ENDSELECT.

 Select single record from database


SELECT SINGLE * FROM customers WHERE id = 1.

Select Multiple Records
Tables spfli.
Seclect * from spfli.
write: / spfli-carrid, spfli-connid,
spfli-cityto.
endselect.
if sy-subrc <> 0.
write: / ‘No Data’.
endif.
Dialog WP
Dialog WP Local Memory
Memory Space
TaskHandler

ABAP Processor

List buffer
DYNPRO Processor

DB Interface
Result Set

Database
SELECT Statement Working Steps
1. Transform open SQL to DB SQL and return result
set into result set work area

SELECT * FROM spfli. SELECT * FROM spfli;



ENDSELECT.

2. Loop with data in result set and transfer each


record to work area in memory space
Table Structure in Memory
SELECT * FROM spfli. Space

ENDSELECT.
Select … Into Table Structure
Tables spfli.
Seclect * from spfli into spfli.
write: / spfli-carrid, spfli-connid,
spfli-cityfrom, spfli-cityto.
endselect.
if sy-subrc <> 0.
write: / ‘No Data’.
endif.
Select … Into Work Area
Data wa like spfli.
Seclect * from spfli into wa.
write: / wa-carrid, wa-connid,
wa-cityfrom, wa-cityto.
endselect.
if sy-subrc <> 0.
write: / ‘No Data’.
endif.
Exercise I

custome customer custome


rs-id s-name rs-city
SELECT with WHERE Clause
Loop Processing with Restriction
Tables spfli.
Select * from spfli
where cityfrom = ‘FRANKFURT’.
write: / spfli-carrid, spfli-cityto.
endselect.
If sy-subrc <> 0.
write / ‘no data’.
endif.
Select With Range
Tables sflight.
Select * From sflight
Where price between 100 and 1000.
Write: / sflight-carrid, sflight-connid,
sflight-price.
Endselect.
SELECT … With IN List
Tables sflight.
Select * From sflight
Where price in ( 100, 1000 ).
Write: / sflight-carrid, sflight-connid,
sflight-price.
Endselect.
Select Single Record
Select Single Record
Tables spfli.
Select single * from spfli
where carrid = ‘LH’ and
connid = ‘0400’.
if sy-subrc = 0.
write: / spfli-carrid, spfli-connid,
spfli-cityfrom, spfli-cityto.
else.
write: / ‘Data not found’.
endif.
Select Column List
Select * : Example

SELECT *
Reading Selected Column
Data: id like customers-id,
name like customers-name,
city like customers-city.
Select id name city
into (id, name, city)
from customers.
write: / id, name, city.
endselect.
if sy-subrc <> 0.
write / ‘No Data found’.
endif.
Reading Selected Column
Data: begin of wa,
id like customers-id,
name like customers-name,
city like customers-city,
end of wa.
Select id name city
into wa
from customers.
write: / wa-id, wa-name , wa-city.
endselect.
if sy-subrc <> 0.
write / ‘No Data found’.
endif.
Select Column : Example I
Reading Selected Column
Tables customers.
Select id name city
into (customers-id, customers-name, customers-city)
from customers.
write: / customers-id, customers-name, customers-city.
endselect.
if sy-subrc <> 0.
write / ‘No Data found’.
endif.
Select Column : Example II
Corresponding Fields of...
Tables: customers.
Select id name city
into corresponding fields of customers
from customers.
Write: / customers-id, customers-name,
customers-city.
Endselect.
Select Statement : Special Topics
DB Count : SY-DBCNT
Tables customers.
Select * from customers.
write: / sy-dbcnt, customers-id, customers-name.
endselect.
if sy-subrc <> 0.
write: / ‘No Data found’.
else.
write: / sy-dbcnt, ‘Record found’.
endif.
SELECT … ORDER BY ...
Tables: spfli.
Select * from spfli
Order by cityfrom.
Write: / spfli-carrid, spfli-connid,
spfli-cityfrom.
Endselect.
SELECT … With Template
Tables customers.
Select * From customers
Where name Like ‘_r%’.
Write: / customers-id,customers-name.
Endselect.
Aggregate Functions
Data: maxdat like sflight-distance,
mindat like sflight-distance,
counter type I.
Select COUNT( * ) MIN( distance ) MAX( distance )
into (counter ,mindat, maxdat)
from spfli.
Write: / ‘Count :’ , counter,
/ ‘Min :’ , mindat,
/ ‘Max :’ , maxdat.

Aggregate Functions : COUNT,MIN,MAX,AVG and SUM


SELECT … GROUP BY ...
Data: carrid like sflight-carrid,
carrid connid fldate Price
mindat Type P Decimals 2, sflight
maxdat Type P Decimals 2.
Select carrid Min( price ) Max( price ) LH 0400 20010101 150
Into (carrid, mindat, maxdat)
From sflight LH 0400 20010110 145
Group by carrid.
Write: / carrid, mindat, maxdat. LH 0400 20010228 130
Endselect.
SQ 0110 20010226 75
Sub Query
tables customers. Sub Query with
select * conditon ID = 1
from customers
where id <> 1 and
city =
( select city
from customers
where id = 1 ).
write: / customers-id, customers-name.
endselect.
Exercise I

SELECT *

custome customer custome


rs-id s-name rs-city
Exercise II

SELECT *

usr02- usr02- usr02-


bname trdat ltime
ABAP : Inner Join
Tables Join

sflight
spfli
carrid connid fldate price
carrid connid cityfrom cityto distance
LH 0400 20010101 150
LH 0400 NY BK 100
LH 0400 20010110 145
LH 0402 BK NY 540
LH 0400 20010228 130
SQ 0110 SQ BK 250
SQ 0110 20010226 75
Tables Join
Question: Select carrid, connid and cityto from spfli
and fldate,price from sflight where carrid = ‘LH’

spfli-carrid spfli-connid sflight-fldate spfli-cityto sflight-price


Standard SQL

Select spfli.carrid, spfli.connid, sflight.fldate,


sflight.price
From spfli, sflight
Where spfli.carrid = sflight.carrid and
spfli.connid = sflight.connid and
spfli.carrid = ‘LH’;
Tables Join Methods
 Nested select statement
 Internal table
 View
 Inner join of Select statement
Nested Select Statement
Tables: spfli,sflight.
Select * from spfli where carrid = ‘LH’.
Select * from sflight
where carrid = spfli-carrid and
connid = spfli-connid.
Write: / spfli-carrid, spfli-connid, sflight-fldate,
sflight-price.
Endselect.
Endselect.
Open SQL – Inner Join
Tables: spfli,sflight.
Select spfli~carrid spfli~connid sflight~fldate spfli~cityto sflight~price
into (spfli-carrid, spfli-connid, sflight-fldate, spfli-cityto, sflight-price)
from spfli inner join sflight
on spfli~carrid = sflight~carrid and
spfli~connid = sflight~connid
where spfli~carrid = ‘LH’.
Write: / spfli-carrid, spfli-connid, sflight-fldate,
spfli-cityto, sflight-price.
Endselect.
Open SQL – Inner Join
Tables: A,B.
A-a B-b B-c
Select A~a B~b B~c
into (A-a,B-b,B-c)
from A inner join B
on A~b = B~b. Table : B
Write: / A-a,B-b,B-c.
b c
Endselect.
Table : A b1 c1
a b b2 c2
a1 b1 b3 c3
a2 b2
Open SQL – Inner Join
Table : A Table : B
Data a b b c
base a1 b1 b1 c1
Serve a2 b2 b2 c2
r b3 c3

Application Single Result Table(Result set) 1


Server 2
Select … A~a B~b B~c
inner join.. a1 b1 c1
Endselect. a2 b2 c2
Open SQL – Alias Table Name
Tables: spfli,sflight.
Select a~carrid a~connid b~fldate a~cityto b~price
into (spfli-carrid, spfli-connid, sflight-fldate, spfli-cityto, sflight-price)
from spfli as a inner join sflight as b
on a~carrid = b~carrid and
a~connid = b~connid
where a~carrid = ‘LH’.
Write: / spfli-carrid, spfli-connid, sflight-fldate, spfli-cityto, sflight-price.
Endselect.
Inner Join/Outer Join Example
ZCUSTOMERS ZSALEREPS
id name city tel sale_id name
1 John New York 111111 01 Somchai
2 Peter London 222222 02 Pipop
3 David Singapore 432555
4 Micheal Bangkok 234111
ZSALES
cust_id prod_id sale_date qty sale_id
ZPRODUCTS
1 A1 20020318 10 01
p_id prod_name on_hand
1 A2 20020318 50 01
A1 Pen 100
3 X1 20020321 90 02
A2 Pencil 125
B1 Ruler 80
X1 Tape 120
Y1 CD 99
Open SQL – Inner Join
REPORT ZINNERJOIN01 .
TABLES: ZCUSTOMERS,ZSALES.
SELECT A~NAME B~PROD_ID
INTO (ZCUSTOMERS-NAME,ZSALES-PROD_ID)
FROM ZSALES AS B INNER JOIN ZCUSTOMERS AS A
ON B~CUST_ID = A~ID.
WRITE: / ZCUSTOMERS-NAME,ZSALES-PROD_ID.
ENDSELECT.
Open SQL – Inner Join > 2 Tables
Table : C
Tables: A,B,C. A-a B-c C-y
Select A~a B~c C~y x y
into (A-a,B-c,C-y) … ...
from A inner join B
on A~b = B~b Table : B
inner join C
on C~x = B~c. b c
Write: / A-a,B-c,C-y. … ...
Endselect. … ...
Table : A … …
a b
… …
Open SQL – Inner Join > 2 Tables
REPORT ZINNERJOIN02 .
TABLES: ZCUSTOMERS,ZPRODUCTS,ZSALES.
SELECT A~NAME C~PROD_NAME B~QTY
INTO (ZCUSTOMERS-NAME, ZPRODUCTS-PROD_NAME, ZSALES-QTY)
FROM ZSALES AS B INNER JOIN ZCUSTOMERS AS A
ON B~CUST_ID = A~ID
INNER JOIN ZPRODUCTS AS C
ON C~P_ID = B~PROD_ID.
WRITE: / ZCUSTOMERS-NAME,ZPRODUCTS-PROD_NAME,ZSALES-QTY.
ENDSELECT.
Exercise
 List customers who buy product from
company as following fields:

zcustomers-id
 zcustomers-name
 zsales-sale_date
 zproducts-prod_name
 zsales-qty
 zsalereps-name
Exercise : User Master
USR02-BNAME USR02-TRDAT ADCP-TEL_NUMBER Tables Relationship

USR02

BNAME
USR21
PERSNUMBER
ADDRNUMBER

ADCP
ABAP : Outer Join
Open SQL – Outer Join
REPORT ZOUTERJOIN .
TABLES: ZCUSTOMERS,ZSALES.
SELECT A~NAME B~PROD_ID
INTO (ZCUSTOMERS-NAME,ZSALES-PROD_ID)
FROM ZCUSTOMERS AS A LEFT OUTER JOIN ZSALES AS B
ON A~ID = B~CUST_ID.
WRITE: / ZCUSTOMERS-NAME,ZSALES-PROD_ID.
ENDSELECT.
Single Result
Table
A~NAME B~PROD_ID
John A1
John A2
Peter
David X1
Micheal
Exercise
 List customers name who do not buy any
product from company
Internal Table
Data Objects in ABAP
Memory Space
Variable Structure

Table Structure Internal Table

Constants <Field-symbols>
INTERNAL TABLE
Flight (Structure)
Carrid Connid Date Price

Internal Table
Flight (Internal Table) Header Line
Carrid Connid Date Price
Structure
Data: Begin of flight,
carrid like sflight-carrid,
connid like sflight-connid,
date like sflight-fldate,
price like sflight-price.
Data: End of flight.
flight-carrid = ‘LH’.
Write: / flight-carrid.
INTERNAL TABLE
Data: begin of tab occurs 10,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price.
Data end of tab.
USING ABAP DICTIONARY STRUCTURE

Data: begin of tab occurs 0.


Include structure sflight.
Data end of tab.
INTERNAL TABLE USING LIKE

Data tab LIKE sflight OCCURS 0 WITH HEADER LINE.


FILLING INTERNAL TABLE (APPEND)

Tables sflight.
Data flight like sflight occurs 0 with header line.
Select * from sflight.
Move sflight to flight.
Append flight.
Endselect.
Standard Key of Internal Table
tab

Data: begin of tab occurs 0, f1 f2 f3 f4


f1 type C,
f2 type I,
f3 type N,
f4 type P,
end of tab.
Reading Data From Internal Table
Data tab like sflight occurs 0 with header line.
Select * from sflight into table tab.
If sy-subrc = 0.
Loop at tab.
Write: / tab-carrid, tab-price.
Endloop.
Else.
Write: / ‘No Data’.
Endif.
Access Database Without Internal Table
Access Database Using Internal Table
Reading Data From Internal Table
Data: begin of tab occurs 0,
id like customers-id,
name like customers-name,
end of tab.
Select id name from customers into table tab.
If sy-subrc = 0.
Loop at tab.
Write: / tab-id, tab-name.
Endloop.
else.
Write: / ‘No Data’.
Endif.
Exercise I : Change

Using Internal Table


SORTING INTERNAL TABLE (SORT)

Sort flight.
Sort flight by price fldate.
Sort flight by price ascending
fldate descending.
SORTING INTERNAL TABLE
Data tab like spfli occurs 0 with header line.
Select * from spfli into table tab.
Sort tab by cityfrom.

Loop at tab.
write: / tab-carrid, tab-connid,tab-cityfrom.
Endloop.
PROCESSING INTERNAL TABLE
...
Loop at flight.
Write: / flight-carrid, flight-connid.
Endloop.

Loop at flight where carrid = ‘LH’.


Write: / flight-carrid, flight-connid.
Endloop.
Loop at flight from 1 to 10.
Write: / sy-tabix ,flight-carrid, flight-connid.
Endloop.
Internal Table Template Condition
...
loop at tab where name cp ‘+r*’.
...
Reading Single Record
...
Sort flight by carrid connid fldate.
Read table flight
with key carrid = ‘LH’
connid = ‘0400’
fldate = ‘19990201’
Binary Search.
if sy-subrc = 0.
write : / flight-carrid,flight-connid,
flight-fldate, flight-price.
endif.
Reading Single Record using Index
...
Read table flight index 3.
If sy-subrc = 0.
write: / flight-carrid, flight-connid.
Endif.
CHANGING INTERNAL TABLE

...
Delete flight index 5.
Delete flight where carrid = ‘LH’.

flight-carrid = ‘XX’.
flight-price = 100.

Insert flight index 1.
DELETING INTERNAL TABLE
DATA flight LIKE sflight occurs 0 with header line.

Clear flight.
Refresh flight.
Free flight.
Total Record of Internal Table

Data: line_count type i.


Data tab like sflight occurs 0 with header line.
Select * from sflight into table tab.
Describe table tab lines line_count.
Write: / line_count.
Exercise I
Internal Table Processing
Data tab like spfli occurs 0 with Header line.

Select * from spfli
appending table tab
where carrid = ‘LH’.
SELECT … INNER JOIN
REPORT ZINNERJOIN01 .
TABLES: ZCUSTOMERS,ZSALES.
SELECT A~NAME B~PROD_ID
INTO (ZCUSTOMERS-NAME,ZSALES-PROD_ID)
FROM ZSALES AS B INNER JOIN ZCUSTOMERS AS A
ON B~CUST_ID = A~ID.
WRITE: / ZCUSTOMERS-NAME,ZSALES-PROD_ID.
ENDSELECT.
Inner Join into Internal Table
REPORT ZJOIN01 .
DATA: begin of tab occurs 0,
name like zcustomers-name,
prod_id like zsales-prod_id,
end of tab.
SELECT A~NAME B~PROD_ID
INTO TABLE tab
FROM ZSALES AS B INNER JOIN ZCUSTOMERS AS A
ON B~CUST_ID = A~ID.

LOOP AT tab.
WRITE: / TAB-NAME,TAB-PROD_ID.
ENDLOOP.
Internal Table Without Header Line
DATA tab LIKE customers OCCURS 0.
DATA wa LIKE customers.

LOOP AT tab INTO wa.
WRITE: / wa-id, wa-name.
ENDLOOP.
Internal Table Declaration
DATA tab TYPE TABLE OF customers.
DATA wa LIKE LINE OF customers.

ABAP Practice
Database Table Processing

 INSERT
 UPDATE
Database
 MODIFY
 DELETE
Insert (Table)
Tables customers.
customers-id = ‘999’.
customers-name = ‘Test’.
Insert customers.
if sy-subrc <> 0.
write: / ‘Data Already Exists’.
endif.
Update Statement

Tables customers.
Select single * from customers where id = 1.
If sy-subrc = 0.
customers-name = ‘John’.
update customers.
Endif. Update customers
set name = ‘John’
where id = 1.
Update Statement
Data wa like customers.
wa-id = ‘1’.
wa-name = ‘Test No 1’.
wa-city = ‘Bangkok’.
update customers from wa.
If sy-subrc <> 0.
write: / ‘Data not found’.
Endif.
Modify Statement
Tables customers.
customers-id = ‘1’.
customers-name = ‘Test No 1’.
Modify customers.
Deleting Database Table Entries
Tables customers.
customers-id = ‘1’.
Delete customers.

Delete customers From Table delcustomers.

Delete From customers Where city = ‘Bangkok’.


Exercise
Tables Relationship for User Master
USR02-BNAME USR02-TRDAT ADCP-TEL_NUMBER Tables Relationship

USR02

BNAME
USR21
PERSNUMBER
ADDRNUMBER

ADCP
Exercise : User Master

usr02-
usr02- trdat
bname adcp-
tel_numbe
r

ใช้ Internal Table


ABAP Chapter 4
 Event-driven Programming
 Selection Screen
Event-driven Programming
Application Driven Programming
REPORT ztest.
DATA: today TYPE D.
today = ‘19991231’.
today = today + 1.
WRITE: / today.
Event-Driven Programming

Data tmp type i.


Start-of-Selection.
Write: / ‘This is ’.
Write: / ‘Basic List’.
At line-selection.
Write: / ‘This is ’.
Write: ‘Detail List’.
Events
 START-OF-SELECTION.
 END-OF-SELECTION.
 TOP-OF-PAGE.
 TOP-OF-PAGE DURING LINE-SELECTION.
 END-OF-PAGE.
 AT LINE-SELECTION.
 AT USER-COMMAND.
 INITIALIZATION.
 AT SELECTION-SCREEN.
AT LINE-SELECTION Event
(Drill-down Report)
AT LINE-SELECTION
Start-of-selection.
Write : ‘Basic List’.
At Line-selection.
Write : ‘Detail List’.
Double
Click

Basic list
Navigating Between Lists

Exit Detail list 20

ABAP Editor

Detail list 2

Cancel
Detail list 1

Basic list Back


Detail List and SY-LSIND
Detail list 2
Start-of-selection. SY-LSIND = 2

write: ‘Basic List’.


AT Line-selection.
CASE sy-lsind. Detail list 1
WHEN 1. SY-LSIND = 1

write: ‘Detail List #1’.


WHEN 2.
write: ‘Detail List #2’.
ENDCASE. Basic list
At Line Selection
Tables customers.
Start-of-Selection.
Select * from customers.
write : / customers-name .
Endselect.
At line-selection.
Write: ‘You Choose :’ , customers-name.
At Line Selection(Hide Statement)
Tables customers. List Buffer
Start-of-Selection. John
Select * from customers. Peter
David
write : / customers-name.
Hide customers-name.
Endselect.
HIDE area of list level 1
At line-selection.
line Field name Value
Write: ‘You Choose :’ , 1 customers-name John
2 customers-name Peter
customers-name. 3 customers-name David
Hide Area in List
Application Server Dialog WP Local Memory
Memory Space
TaskHandler
Customers Structure

3 | David | ....
ABAP Processor

List buffer
DYNPRO Processor Basic List
John
Peter HIDE area of list level 1
line Field name Value
David
DB Interface 1
2
customers-name
customers-name
John
Peter
Result Set Memory 3 customers-name David

Database Server
Database
At Line Selection(Hide Statement)
Basic List Detail List

John You choose : Peter


Peter 5
David
At Line-selection
1
SY-LILLI = 2
4
HIDE area of list level 1 Customers Structure
2
line Field name Value
3 | Peter | ....
1 customers-name John
2 customers-name Peter 3
3 customers-name David
At Line Selection(Hide Statement)
Tables customers. List Buffer
Start-of-Selection. 00000001 John
00000002 Peter
Select * from customers. 00000003 David
write : / customers-id,customers-name.
Hide: customers-id,customers-name.
Endselect. HIDE area of list level 1
At line-selection. line Field name Value
1 customers-id 00000001
1 customers-name John
Write: ‘You Choose :’ , customers-id,
2 customers-id 00000002
customers-name. 2 customers-name Peter

At Line Selection(Hide Statement)
Basic List Detail List
You choose : 00000002 Peter
00000001 John
00000002 Peter 5
00000003 David

At Line-selection
1
SY-LILLI = 2
4
HIDE area of list level 1 Customers Structure
2
line Field name Value 2 | Peter | ....
… … …
2
2
customers-id
customers-name
00000002
Peter
3
3 customers-id 00000003

At Line Selection
Tables: spfli,sflight. Basic List (SPFLI)

Start-of-selection.
Select * from spfli.
write : / spfli-carrid, spfli-connid, spfli-cityto.
Hide : spfli-carrid, spfli-connid.
Endselect.
At Line-selection.
select * from sflight where carrid = spfli-carrid Detail List (SFLIGHT)

and connid = spfli-connid.


write: / spfli-carrid, spfli-connid,sflight-fldate.
endselect.
Exercise
Basic List

Detail List
zcustomers-id

zcustomers

zcustomers-name
zsales-cust_id
zsales-qty
zsales-prod_id

zsales
Hide Statement (Report Heading)
List Buffer
Tables customers.
Customers Name
Top-of-page. -----------------------------
write: / ‘Customers Name’. John
Peter
uline. David
Start-of-Selection.
Select * from customers.
write : / customers-name.
Hide customers-name.
HIDE area of list level 1
Endselect.
At line-selection. line Field name Value
3 customers-name John
Write: ‘You Choose :’ , customers-name. 4 customers-name Peter
5 customers-name David
At Line Selection(Hide Statement)
Basic List Detail List
Customers Name
-----------------------------
You choose : Peter
John 5
Peter
David
At Line-selection
1
SY-LILLI = 4
4
HIDE area of list level 1 Customers Structure
2
line Field name Value
3 | Peter | ....
3 customers-name John
4 customers-name Peter 3
5 customers-name David
Invalid Line Selection

TOP-OF-PAGE.

Hide: spfli-carrid, spfli-connid.

Endselect.
Clear: spfli-carrid,spfli-connid.
At Line-selection.
Select * From sflight
Where carrid = spfli-carrid and
connid = spfli-connid.
Write: / spfli-carrid, spfli-connid ,sflight-fldate.
Endselect.
Clear: spfli-carrid,spfli-connid.
Page Heading
Start-of-selection.
Write: ‘Basic List’.
At Line-selection.
Write: ‘Detail List’.
Top-of-page.
Write: ‘Header-Basic List’.
Top-of-page During Line-selection.
Write: ‘Header-Detail List’.
Detail List Page Heading
...
top-of-page during line-selection.
case sy-lsind.
when 1.
write: / ‘Detail List Header #1’.
when 2.
write: / ‘Detail List Header #2’.
endcase.
.....
.....
...
Column Selection
data: fieldname(30).
...
start-of-selection.
select * from spfli.
write: / spfli-carrid,15 spfli-connid, 25 spfli-cityto.
hide: spfli-carrid,spfli-connid.
endselect.
at line-selection.
case sy-lsind.
when 1.
get cursor field fieldname.
case fieldname.
when 'SPFLI-CARRID'.
select single * from scarr where carrid = spfli-carrid.
if sy-subrc = 0.
write: / spfli-carrid,scarr-carrname.
endif.
when 'SPFLI-CONNID'.
select * from sflight where carrid = spfli-carrid and
connid = spfli-connid.
...
Column Selection : Value
...
data: fieldname(30),fieldvalue(30).
...
start-of-selection.
select * from spfli.
write: / spfli-carrid,15 spfli-connid, 25 spfli-cityto.
hide: spfli-carrid,spfli-connid.
endselect.
at line-selection.
case sy-lsind.
when 1.
get cursor field fieldname value fieldvalue.
case fieldname.
when 'SPFLI-CARRID'.
select single * from scarr where carrid = spfli-carrid.
if sy-subrc = 0.
write: / spfli-carrid,scarr-carrname.
endif.
when 'SPFLI-CONNID'.
...
Creating List in Modal Dialog Box

...
at line-selection.
window starting at 10 10
ending at 65 20.
select * from sflight
where carrid = spfli-carrid and
connid = spfli-connid.
write: / sflight-carrid,sflight-connid,sflight-fldate.
endselect.
...
Exercise
Basic List
zsales
zsales-qty
zsales-cust_id zsales-prod_id
zsales-sale_id

zproducts
Detail List zsalereps

zproducts-on_hand
zproducts-p_id
zsalereps-sale_id zsalereps-name
Drill-Down 2 Levels Example

Detail list level 2 (ZPRODUCTS)

Basic list (ZCUSTOMERS) 2


1

Detail list level 1 (ZSALES)


Program Example
START-OF-SELECTION.
SELECT * FROM zcustomers.
WRITE: / zcustomers-id COLOR 4 HOTSPOT, 15 zcustomers-name.
HIDE: zcustomers-id,zcustomers-name.
ENDSELECT.
CLEAR zcustomers-id. Hide Level 1
AT LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
GET CURSOR FIELD fieldname.
IF fieldname = 'ZCUSTOMERS-ID'.
SELECT * FROM zsales WHERE cust_id = zcustomers-id.
IF sy-dbcnt = 1.
WRITE: / zcustomers-id,15 zcustomers-name,30 zsales-prod_id HOTSPOT, 45 zsales-qty.
Drill Down Level 1 HIDE: zsales-prod_id.
ELSE.
WRITE: /30 zsales-prod_id HOTSPOT, 45 zsales-qty.
HIDE: zsales-prod_id.
ENDIF. Hide Level 2
ENDSELECT.
CLEAR: zcustomers-id,zsales-prod_id.
ENDIF.
WHEN 2.
GET CURSOR FIELD fieldname.
IF fieldname = 'ZSALES-PROD_ID'.
SELECT SINGLE * FROM zproducts WHERE p_id = zsales-prod_id.
Drill Down Level 2 IF sy-subrc = 0.
WRITE: / zproducts-p_id,15 zproducts-prod_name,38 zproducts-on_hand.
ENDIF.
CLEAR zsales-prod_id.
ENDIF.
ENDCASE.
Basic List

Exercise
SCARR

Drill-down Level 1
SPFLI

Drill-down Level 2
SFLIGHT

Drill-down Level 3
SBOOK
GUI Interface (User Interface)
GUI Interface
SET PF-STATUS …. => GUI Status
SET TITLEBAR …. => GUI Title
AT USER-COMMAND Event

SET PF-STATUS ‘TEST’.


...
AT USER-COMMAND.
CASE sy-ucomm.
WHEN ‘CODE1’.
.
WHEN ‘CODE2’.
.
ENDCASE.
Standard Toolbar : System Function
 System function do not trigger event AT USER-COMMAND
 %EX = Exit
 %PC = Save to file
 %SC = Find
 %SC+ = Find next
 %ST = Save in report tree
 BACK = Back
 RW = Cancel
 PRI = Print
 P- = Scroll to previous page
 P-- = Scroll to first page
 P+ = Scroll to next page
 P++ = Scroll to last page
Alternative with AT USER-COMMAND
REPORT ZRSDEM002.
.
START-OF-SELECTION
SET PF-STATUS ‘BASE’.
.
.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN ‘CARR’.
SET PF_STATUS SPACE. “Set to standard GUI interface
.
WHEN ‘FLIG’.
SET PF-STATUS ‘FLIG’.
WRITE …
.
.
GUI Status Excluding Function Code
REPORT ztest.
...
SET PF-STATUS ‘0100’.
...
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN ‘LIST’.
SET PF-STATUS ‘0100’ excluding ‘LIST’.
.
WHEN ‘DISP’.
SET PF-STATUS ‘0100’ excluding ‘DISP’.
WRITE …
. ....
GUI Status Excluding Function Code

REPORT ztest.
DATA exctab(10) occurs 0 with header line.
....
START-OF-SELECTION.
SET PF-STATUS ‘0100’.
...
exctab = ‘LIST’. APPEND exctab.
exctab = ‘TEST’. APPEND exctab.
...
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN ‘LIST’.
SET PF-STATUS ‘0100’ excluding exctab.
GUI TITLE
...
SET TITLEBAR ‘0100’.
ABAP Practice
Selection Screen
Selection Screen
 PARAMETERS Statement
 SELECT-OPTIONS Statement
parameters
Parameters
PARAMETERS: tmp1(10) TYPE C,
tmp2(10) TYPE C lower case,
tmp3 LIKE sy-datum default sy-datum,
tmp4 TYPE D default ‘19991231’,
tmp5 TYPE i,
tmp6(5) TYPE N.
Parameters Example
Tables customers.
Parameters pid like customers-id.
START-OF-SELECTION.
select single * from customers where id = pid.
if sy-subrc = 0.
write: / customers-name.
else.
write: / ‘No data found’.
endif.
Selection-Text
 By default , the System displays the name of the selection as text on
the Selection Screen
 You Should use the Text element/Selection texts function to store a
text line for each Selection Criterion.
Check box

Parameters tmp as checkbox default ‘X’.


Radio Button
Parameters: test1 Radiobutton group grp1,
test2 Radiobutton group grp1.
Required field with Parameters

Parameters tmp like sy-datum obligatory.


ABAP Exercise
select-options
Complex Selection (Select-options)
Tables spfli.
Select-options carrid for spfli-carrid.
START-OF-SELECTION.
Select * From spfli
Where carrid in carrid.
.
..
Endselect.
Select-Options
“ต้ องการให้ แสดงข้ อมูล customers ของลูกค้ าทีม่ ีชื่อ(คอลัมน์ name) ขึ้น
ต้ นด้ วยตัว ‘M’ และลูกค้ าทีช่ ่ือ ‘Smith’ และลูกค้ าทีช่ ่ืออยู่ระหว่ าง ‘A’ กับ
‘John’ โดยใช้ คำสั่ง SELECT”
Select * from customers
where (name like ‘M%’) or
(name = ‘Smith’) or
(name between ‘A’ and ‘John’).
Select-Options

Tables customers.
Select-options sname for customers-name.
START-OF-SELECTION.
Select *
from customers
Where name in sname.
Internal Structure of Select-options

sname
Sign Option Low High
Internal Structure of Select-options
Field Value .

Sign I = Include
E = Exclude
Option BT = Between
CP = Contains Pattern
EQ = Equal
GT = Greater Than
LT = Less Than
GE = Grater Than or Equal
LE = Less Than or Equal
NE = Not Equal
Internal Structure of Select-options

sname
Sign Option Low High

I CP M*
I EQ Smith
I BT A John
SELECT-OPTIONS
sname
Sign Option Low High Select * from customers
Transform
where (name like ‘M%’) or
I CP M* (name = ‘Smith’) or
I EQ Smith (name between ‘A’ and ‘John’).
I BT A John

Select * from customers


where name in
sname.
INITIALIZATION Event
Tables Customers.
Select-options sname for customers-name.
Initialization.
sname-sign = ‘I’.
sname-option = ‘EQ’.
sname-low = ‘Smith’.
append sname.
Start-of-Selection.
Select * from customers
Where name in sname.
Select-options Options
Select-options sname for customers-name obligatory.
Select-options sname for customers-name no-extension.

Select-options sname for customers-name no intervals.


Designing Selection Screen

Selection-screen begin of block test with frame Title text-001.


.
Selection-screen uline.
Selection-screen skip 3.
Selection-screen comment 3(10) text-001.
Parameters month(2) type n.
.
Selection-screen end of block test.
Designing Selection Screen

selection-screen begin of line.


selection-screen comment 1(7) text-001.
selection-screen position 9.
parameters month(2) type n.
selection-screen comment 16(6) text-002.
parameters year(4) type n.
selection-screen end of line.
Designing Selection Screen
Selection-screen begin of block name1 with frame title text-001.
Selection-screen begin of line.
Parameters test1 radiobutton group test default ‘X’.
Selection-screen comment 4(10) text-002.
Selection-screen position 35.
Parameters tcheck as checkbox.
Selection-screen comment 37(15) text-003.
Selection-screen end of line.
Selection-screen begin of line.
Parameters test2 radiobutton group test.
Selection-screen comment 4(10) text-004.
Selection-screen end of line.
Selection-screen end of block name1.
ABAP Exercise
Checking User Input
Tables customers.
Data pcode_len type i.
Parameters pcode like customers-postcode.
At selection-screen.
pcode_len = strlen( pcode ).
if pcode_len <> 5.
message e000(38) with ‘Please enter postcode 5 characters’.
endif.
Start-of-Selection.
select * from customers where postcode = pcode.

ABAP Exercise
ABAP Program Processing Steps
TABLES sflight.
PARAMETERS nextday LIKE sy-datum.
INITIALIZATION.
nextday = sy-datum + 1.
AT SELECTION-SCREEN.
IF nextday < sy-datum.
MESSAGE e000(38) WITH ‘Please enter date >= today’.
ENDIF.
START-OF-SELECTION.
SELECT * FROM sflight WHERE ... fldate = nextday…

ABAP Practice
ABAP Chapter 5
 Modularization
 Catch Statement
Modularization
Modularization
 Internal Subroutine Call
 External Subroutine Call
 Function Module
Subroutine
START-OF-SELECTION.
Perfrom routine1.
Perform routine2.
Perform routine2.
Form routine1.
select * from customers into table tab.
Endform.
Form routine2.
loop at tab.
write: / tab-id,tab-name.
endloop.
Endform.

Modularization
 Avoid redundancy
 Make your program easy to read & improve their
structure
 Re-use Program components
Calling and Defining Subroutines
REPORT ztest.
* Global Data
TABLES customers.
DATA tmp type i.
* Subroutine Calls
PERFORM routine1.
PERFORM routine2.
* Subroutine
FORM routine1.
DATA tmp1 type p. “Local data
write tmp.
ENDFORM.
FORM routine2.
DATA tmp2(10). “Local data
…..
ENDFORM.
Call by Value

a1

Copy

f1

Memory Space(Subroutine)
Call by Value
Data: a1,a2.
a1 = ‘A’.
a2 = ‘A’.
PERFORM routine1 USING a1 a2.
.…...
FORM routine1 USING VALUE(f1) VALUE(f2).
f1 = ‘X’.
f2 = ‘X’.
ENDFORM.
Call by Reference

a3

Address Passing

f3

Memory Space(Subroutine)
Call by Reference

Data: a3.
a3 = ‘A’.
PERFORM routine2 USING a3.
.…...
FORM routine2 USING f3.
f3 = ‘X’.
ENDFORM.
Call by Value and Result

a4
Copy Copy

f4

Memory Space(Subroutine)
Call by Value and Result

Data: a4,a5.
a4 = ‘A’.
a5 = ‘A’.
PERFORM routine3 USING a4 a5.
.…...
FORM routine3 CHANGING VALUE(f4) f5. “f5 : call by reference
f4 = ‘X’.
f5 = ‘X’.
ENDFORM.
Passing Structure as Parameters

TABLES sflight.
SELECT * FROM sflight.
PERFORM subproc USING sflight.
ENDSELECT.
FORM subproc USING rec LIKE sflight.
WRITE: / rec-carrid.
ENDFORM.
Passing Internal Table as Parameters

DATA: tab LIKE sflight OCCURS 0 WITH HEADER LINE.



PERFORM sub TABLES tab.
Passing Internal Table as Parameters

FORM sub TABLES tab1 STRUCTURE tab.


LOOP AT tab1.
WRITE: / tab1-carrid.
ENDLOOP.
ENDFORM.
External Subroutines

REPORT RSAAA10F.
TABLES: sflight.
…..
PERFORM cal(RSAAA10B).

REPORT RSAAA10B.
TABLES sflight.
…..
FORM cal.
…..
ENDFORM.
EXIT Statement
DATA tmp TYPE I.
tmp = 4.
PERFORM a.
WRITE tmp.

FORM a.
EXIT.
tmp = 99.
ENDFORM.
STOP Statement
DATA tmp TYPE I.
START-OF-SELECTION.
tmp = 4.
PERFORM a.
WRITE tmp.
END-OF-SELECTION.
tmp = 0.
write tmp.
FORM a.
STOP. “go to END-OF-SELECTION
tmp = 99.
ENDFORM.
Function Module
Function Module
 Function Group
 Function Library

- Admin
- Import/Export Parameter
- Source Code
- Main Program
- Documentation
Function Group
 When you create a function module, you must assign it to
function group
 The function group is the main program in which a function
module is embedded
 The function group is a program type F,and not executable
 The entire function group is loaded in a program the first
time that you call a function module that belongs to it
Function Group
 is a container for function modules
 When a function module is called,the entire function group
is loaded into the session of the program
 Function group is used to define global data for function
modules
 A DATA statement in the global memory of a function group
is shared by all the function modules that belong to that
function group
Function Group : SE37
Function Group : SE80
Function Module
 is a code that can be called from any ABAP
program,therefore making it a globally accessible object
 ABAP program pass data to function module from import
parameters or internal tables
 Function module receives data from a program,process the
information in its own code, and then sends back
information in the export parameters or internal tables
Function Module : SE37
Function Module
Function Module : Source Code

FUNCTION Z_FMTEST.
result = number1 ** number2.
ENDFUNCTION.
Program Example I
REPORT ztest.
PARAMETERS: no1 TYPE I,
no2 TYPE I.
DATA result TYPE I.
START-OF-SELECTION.
CALL FUNCTION ‘Z_FMTEST’
EXPORTING
number1 = no1
number2 = no2
IMPORTING
result = result.
write: / result.
Exercise : Function Module
ABAP Program

Function
Module

?
EXCEPTIONS
Function Module

Function Z_CAL01.
if number1 > 9 and number2 > 9.
raise invalidnumber.
else.
result = number1 ** number2.
endif.
ENDFUNCTION.
Example II : Exceptions
REPORT ztest.
PARAMETERS: no1 TYPE I,
no2 TYPE I.
DATA result TYPE I.

START-OF-SELECTION.
CALL FUNCTION ‘Z_CAL01’
EXPORTING
number1 = no1
number2 = no2
IMPORTING
result = result
EXCEPTIONS
invalidnumber = 1.
IF sy-subrc <> 0.
write: / ‘Please enter number < 10’.
ELSE.
write: / result.
ENDIF.
Exercise : Exceptions
ABAP Program

Function
Module

?
EXCEPTIONS VS AT SELECTION-SCREEN

REPORT ztest.
FUNCTION Z_CAL01.
Parameters: no1 type i,
if number1 > 9 and number2 > 9.
no2 type i.
raise invalidnumber.
At selection-screen
else.
result = number1 ** number2.
VS if no1 > 9 and no2 > 9.
message e000(38) with ‘Please enter no < 10’.
endif.
endif.
ENDFUNCTION.
START-OF-SELECTION.
CALL FUNCTION ‘Z_CAL01’.
…..
Optional
Function Module

ABAP Program
Structure in Function Module
Example : Structure
Example : Structure
Internal Table in Function Module
Example : Internal Table
Example : Internal Table
Function Group
Function Module : Z_FMTEST

Function Group : ZGRP00


Function Module : Z_CAL01
Function Group
Function Module in Function Group
Exercise
 Display current month name using function module
Catch Statement
CATCH Statement

•Syntax
Catch system-exceptions <error type> = <n>.
<ABAP statement – generate runtime error> .
Endcatch.
if sy-subrc = <n>.
...
endif.
CATCH Error Type

•Error class
•Catch system-exceptions conversion_errors = 1.
•Single error
•Catch system-exceptions convt_no_number = 1.
•All catchable runtime error
•Catch system-exceptions others = 1.
CATCH Statement

Report ztest.
Data num type I.
Catch system-exceptions conversion_errors = 1.”others
Move ‘abc’ to num. “runtime error: convt_no_number
Endcatch.
If sy-subrc = 1.
Write: / ‘Assign wrong data type to variable: num’.
Endif.
CATCH Statement

Report ztest.
Data num type I.
Catch system-exceptions others = 1.
Move ‘abc’ to num.
Endcatch.
If sy-subrc = 1.
Write: / ‘Assign wrong data type to variable: num’.
Endif.
CATCH Statement

Report ztest.
PARAMETERS: NUM1 TYPE I,
NUM2 TYPE I.
DATA RESULT TYPE I.

START-OF-SELECTION.
CATCH SYSTEM-EXCEPTIONS COMPUTE_INT_ZERODIVIDE = 1.
RESULT = NUM1 / NUM2.
ENDCATCH.
IF SY-SUBRC = 1.
WRITE: /'Divide by zero'.
ELSE.
WRITE: / RESULT.
ENDIF.
CATCH Statement

Report ztest.
PARAMETERS: NUM1 TYPE I,
NUM2 TYPE I.
DATA RESULT TYPE I.

START-OF-SELECTION.
CATCH SYSTEM-EXCEPTIONS OTHERS = 1.
RESULT = NUM1 / NUM2.
ENDCATCH.
IF SY-SUBRC = 1.
WRITE: /'Divide by zero'.
ELSE.
WRITE: / RESULT.
ENDIF.
CATCH in Function Module
Function Z_CAL. Function Z_CAL.
if number1 > 9 and number2 > 9. CATCH SYSTEM-EXCEPTIONS OTHERS = 1.
raise invalidnumber. RESULT = NUMBER1 ** NUMBER2.
ENDCATCH.
else.
IF SY-SUBRC = 1.
result = number1 ** number2. RAISE invalidnumber.
endif. ENDIF.
ENDFUNCTION. ENDFUNCTION.
ABAP Practice
ABAP Chapter 6
 Message
 Debugging

 File Transfer

 Type Group
Message in ABAP
User Messages
 If user has entered inconsistent values,you output a dialog message
with MESSAGE statement
 Dialog messages are stored in table T100 (Transaction : SE91)
report ztest.
….
AT SELECTION-SCREEN.

message e000(38) with ‘----’ ‘---’ ‘---’ ‘---’.

Message Type

Syntax
Message [ A<nnn> ](message class) with <field1> <field2> …

E, W, I, S
Messages Type - A(Abend)
Message A000(38)...

Program Start

Selection
Screen

A Message Exit
Messages Type - E(Error)
Message E000(38) ...

Program Start

Selection
New input
Screen
Require

E Message
Messages Type - W(Warning)
Message W000(38)...

Program Start

Selection New input


Screen
possible

W Message

Enter
List
Messages Type - I(Information)
Message I000(38)...

Program Start

Selection
Screen

I Message

Enter
List
Messages Type - S(Success)
Message S000(38)...

Program Start

Selection
Screen

List
(Next Screen)
Dynamic Message

Report ztest1.
Parameters today like sy-datum.
At selection-screen.
if today <> sy-datum.
message e000(38) with ‘Please enter today :’ sy-datum.
endif.
Start-of-selection.
Write: / ‘Today is :’, today.
Debugging
Debugging Mode
Debugging Mode : Internal Table
Debugging Mode : Internal Table
Debugging Mode : Watchpoint
Watchpoint : SAP ECC 6.0
How to Set Debugging Mode
 If you want to test transaction,enter /h in the command
field,press ENTER and execute the transaction
 Set breakpoints in the program
Utilities->Breakpoints->Set
 Uses BREAK-POINT statement
ABAP Practice
File Transfer
File Transfer (Application Server)

 There are 3 steps for file transfer


 Open File

 Read/Write File

 Close File
File Transfer

* Prepare Internal Table


Data all_customers like customers occurs 0 with header line.
Data msg_txt(50).
Parameters filename(128) default ‘customersdata.txt’ lower case.
Start-of-selection.
Select * from customers into table all_customers.
File Transfer

* Opening a file
Open dataset filename for output in text mode
encoding default message msg_txt.
If sy-subrc <> 0.
Write: ‘File cannot be opened .Reason :’,msg_txt.
else.
File Transfer

* Transferring data to a file


Loop at all_customers.
Transfer all_customers to filename.
Endloop.
* Closing a file
Close dataset filename.
Endif.
Transaction : AL11
File Transfer (Appending Data)

* Opening a file
Open dataset filename for appending in text mode
encoding default message msg_txt.
If sy-subrc <> 0.
Write: ‘File cannot be opened .Reason :’,msg_txt.
else.
...
Reading Data from OS File
* Reading data from a file
Parameters filename(128) default ‘customersdata.txt’ lower case.
Data msg_txt(50).
Data all_customers like customers occurs 0 with header line.
Start-of-selection.
Open dataset filename for input in text mode
encoding default message msg_txt.
If sy-subrc <> 0.
Write: ‘File cannot be opened .Reason :’,msg_txt.
else.
Reading Data from OS File
Do.
Read dataset filename into all_customers.
if sy-subrc <> 0.
Exit.
endif.
Append all_customers.
Enddo.
Close dataset filename.
Endif.
Deleting OS File

Parameters filename(128) default ‘customersdata.txt’ lower case.


START-OF-SELECTION.
Delete dataset filename.
If sy-subrc = 0.
write: / ‘Delete OK’.
Endif.
Working with File on Presentation Server
Download Data to PC
* Download data from PC
parameters filename like rlgrap-filename
default ‘c:\customers.txt’.
Data all_customers like customers occurs 0
with header line.
START-OF-SELECTION.
Select * from customers into table all_customres.
Download Data to PC
CALL FUNCTION ‘DOWNLOAD’
Exporting
filename = filename
Tables
data_tab = all_customers
Exceptions
file_open_error = 1

others = 5.
Download Data to PC
Case sy-subrc.
When 1.
Write: ‘Error when file opened’.
When 2.
Write: ‘Error during data transfer’.

When 0.
Write: / ‘Data Download Finish’.
Endcase.
Upload Data from PC

* Upload data to PC
parameters filename like rlgrap-filename
default ‘c:\customers.txt’.
Data all_customers like customers occurs 0 with header line.
START-OF-SELECTION.
Upload Data from PC
CALL FUNCTION ‘UPLOAD’
Exporting
filename = filename
Tables
data_tab = all_customers
Exceptions
file_open_error = 1

others = 5.
Upload Data from PC
Case sy-subrc.
When 1.
Write: ‘Error when file opened’.
When 2.
Write: ‘Error during data transfer’.

When 0.
Insert customers from table all_customers.

Endcase.
Upload/Download Data in Background

Call function ‘WS_DOWNLOAD’


Exporting
filename = filename
...
and
Call function ‘WS_UPLOAD’
Exporting
filename = filename
...
Type Group : SE11
Type Group
ABAP Program
Exercise IV
Exercise III : User Master

usr02-trdat

usr02-bname

adcp-tel_number
Exercise IV : Drill-Down Report

You might also like