abap programming overview
DESCRIPTION
TRANSCRIPT
![Page 1: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/1.jpg)
ABAP ProgrammingABAP Programming OverviewOverview
![Page 2: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/2.jpg)
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
![Page 3: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/3.jpg)
ABAP Chapter 1 Introduction to SAP Architecture ABAP Overview Data Object in ABAP
![Page 4: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/4.jpg)
SAP System : 3 Tier Client/ServerSAP System : 3 Tier Client/Server
DB Server
SAP Application Server
SAP GUI Presentation
Server
SAP GUISAP GUI
![Page 5: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/5.jpg)
SAP SYSTEM (3 Tier Architecture)SAP SYSTEM (3 Tier Architecture)
Presentation Layer
(Windows based)
Application Layer
(Windows Server/UNIX)
Database Server
Database Layer
(Windows Server/UNIX)
M
SAP Instance
Oracle
Informix
DB2
MS SQL Server
MaxDB
G
Dispatcher
RequestQueue
D D B V S E
SAP Buffer(Shared Mem)
SAP GUI SAP GUI
![Page 6: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/6.jpg)
Dialog Processing
![Page 7: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/7.jpg)
Database Server
Application Server
Dispatcher
RequestQueue
D D D D…
SAP Buffer
Program
Table
…
1
3
45
68
9
10
Report zpsm1.
Tables customers.
Select single * from
customers where id = 1.
Write: / customers-name.
Execute ABAP statement
Check Program in Program Buffer
7
Load&Gen Program
SQL Request
Send List
Generate Screen(List)Send Request
Request List
2 Search for free WP
Store request to queue
Send request to WP
SAP GUI
SAP System : Dialog Processing
![Page 8: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/8.jpg)
TaskHandler
DYNPRO Processor
ABAP Processor
Local Memory
Memory Space
DB Interface
List buffer
Database Server
Dialog Work Process
Dialog Work Process Architecture
Result Set Memory
![Page 9: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/9.jpg)
ABAP Programming Overview
![Page 10: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/10.jpg)
ABAP Overview
DATA ...DATA ...
WRITE ..WRITE ....
IF ...IF ...MOVE …MOVE …
WHILE...WHILE...
*Comment..*Comment....
SEARCH ...SEARCH ...
SELECT ...SELECT ...
LOOP AT ...LOOP AT ...DO ...DO ...
![Page 11: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/11.jpg)
ABAPABAP
AAdvanced
BBusiness
AApplication
PProgramming
![Page 12: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/12.jpg)
ABAP FeatureABAP 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
![Page 13: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/13.jpg)
ABAP ABAP
Operating/Database system-independent programming
ABAP contains a subset of SQL called Open Open SQLSQL for comfortable database access for various databasevarious database
![Page 14: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/14.jpg)
ABAP Programming ABAP Programming
ABAP Report Dialog Programming(Transaction)
![Page 15: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/15.jpg)
ABAP Program : ReportABAP Program : Report
Data
Report Program
: attribute type 1 (executable) Reading
Database
Reading dataReading data
![Page 16: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/16.jpg)
Types of ABAP Report
1. Report Listing
2. Drill-down Report
3. Control-break Report
4. ALV Report
1
3
4
![Page 17: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/17.jpg)
ABAP Program : Dialog ProgramABAP Program : Dialog Program
Data
Dialog Program
: attribute type M (Module Pool) Reading
Database
Reading and changing dataReading and changing data
Writing
![Page 18: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/18.jpg)
Dialog Program : Transaction
![Page 19: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/19.jpg)
ABAP Programming
![Page 20: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/20.jpg)
How to create ABAP program
Transaction Code : SE38
![Page 21: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/21.jpg)
Transaction : SE38
![Page 22: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/22.jpg)
Program Attribute
![Page 23: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/23.jpg)
ABAP Editor
![Page 24: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/24.jpg)
The Structure of the LanguageThe Structure of the Language
Each statement must end with a period
DATA tmp TYPE I.
WRITE ‘Hello World’. WRITE ‘OK’.
![Page 25: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/25.jpg)
LiteralLiteral
DATA tmp TYPE I.
WRITE ‘Hello World’.
WRITE ’10’.
MOVE 9 TO tmp.
Text Literal
Numeric Literal
Text Literal
![Page 26: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/26.jpg)
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
![Page 27: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/27.jpg)
Chained StatementsChained Statements
WRITE‘HelloWorld’. WRITE ‘OK’.
= WRITE: ‘Hello World’, ‘OK’.
DATAtmp1 TYPE I . tt tt ttt t t t2
= 1DATA: tmp TYPE I,
2tmp TYPE C.
![Page 28: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/28.jpg)
Chained StatementChained Statement
MOVE sy-subrc TO tmp1.MOVE sy-subrc TO tmp2.MOVE sy-subrc TO tmp3. =MOVE sy-subrc TO: tmp1, tmp2, tmp3.
![Page 29: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/29.jpg)
Chained StatementChained Statement
PERFORM cal_1 USING a1 a2.PERFORM cal_1 USING a3 a4. =PERFORM cal_1 USING: a1 a2, a3 a4.
![Page 30: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/30.jpg)
CommentsComments
* This is full line comment WRITE ‘Hello World’. “ Write data (partial line comment) WRITE ‘Test’.
![Page 31: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/31.jpg)
ABAP Command : Case SensitivityABAP Command : Case Sensitivity
WRITE ‘Hello World’. WriTe ‘Hello World’. wRiTE ‘Hello World’.
ABAP command is not case sensitive
![Page 32: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/32.jpg)
Data Objects in ABAP
![Page 33: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/33.jpg)
Data Objects in ABAPData Objects in ABAP
Memory Space
Structure
Table Structure Internal Table
Variable
Constants<Field-symbols>
![Page 34: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/34.jpg)
Variable
![Page 35: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/35.jpg)
VariableVariable
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’.
![Page 36: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/36.jpg)
Predefined ABAP Data TypesPredefined ABAP Data Types
Type Description Initial Value
C
D
F
I
N
P
T
X
String
xstring
Character
Date
Floating Point
Integer
Numeric Text
Packed Decimal
Time
Hexadecimal
Variable-length
Variable-length Hexadecimal
Space
‘00000000’
00. 0‘0
0‘000000’
’00’
Space
Blank string
Length1 – 65535
8 characters
8 bytes
4 bytes
1 – 65535
1 – 16 bytes
6 characters
1 – 65535
Variable
Variable
![Page 37: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/37.jpg)
Defining Variable with DATA StatementDefining Variable with DATA Statement
* SyntaxDATA var[(length)] [Type type] [Decimals number].
DATA var LIKE Table-Field [VALUE initial value].
![Page 38: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/38.jpg)
Defining Variable with DATA StatementDefining Variable with DATA Statement
* Data Declaration 10DATA: tmp( ) TYPE C,
1tmp TYPE I, 2 8 2 1 50tmp ( ) TYPE P DECIMALS VALUE ‘ . ’.
3 5DATA: tmp ( ) TYPE N, 4tmp .
![Page 39: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/39.jpg)
Defining Variable with DATA StatementDefining Variable with DATA Statement
* Data Declaration -DATA customerno LIKE customers id.
DATA matnr tttt mara-matnr.
DATA customerno TYPE customers-id.DATA matnr TYPE mara-matnr.
![Page 40: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/40.jpg)
ABAP Predefined Data Types
ABAP Predefined Data Types
Complete Types(I,F,D,T,STRING and XSTRING)
Incomplete Types(C,N,P and X)
![Page 41: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/41.jpg)
Variable
Data Type C,N and X length between 1 – 65535 (Default 1)
Data Type P length between 1 – 16 (Default 8) and decimals length between 0 – 31
Data Type I value between – 231 to 231 – 1 or –2,147,483,648 to 2,147,483,647
DATA tmp(10) TYPE C.
DATA tmp(5) TYPE P DECIMALS 2.
DATA tmp TYPE I.tmp = 1000000.
![Page 42: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/42.jpg)
Data type N
data tmp(5) type N.tmp = ‘Xca9yy23K6’.
![Page 43: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/43.jpg)
ABAP Error
ABAP Error
Syntax Error
Runtime Error
System RuntimeError
User RuntimeError
Time Exceed(10 Minutes)
Cannot AllocateSpace
![Page 44: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/44.jpg)
User Runtime Error
DATA result TYPE i.result = 10 / 0.
![Page 45: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/45.jpg)
System Runtime Error : Space Allocation
![Page 46: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/46.jpg)
System Runtime Error : Time Exceed
![Page 47: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/47.jpg)
Non-elementary TypeNon-elementary Type
* Data DeclarationTYPES tname(30) TYPE c.DATA: customer_name TYPE tname, firstname TYPE tname.
![Page 48: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/48.jpg)
Value AssignmentValue Assignment
* Value assignment 1 30DATA: name ( ),
ttt t _ I , next_num TYPE I.
MOVE ‘XXXX’ TO name1. 5MOVE TO first_num.
5COMPUTE next_num = first_num + . 1name = ‘SAP’.
1ADD TO next_num.
![Page 49: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/49.jpg)
Value AssignmentValue Assignment
* Value assignment DATA: tmp1 TYPE t,
tmp2 TYPE t.tmp1 = tmp2 = 10.
![Page 50: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/50.jpg)
ABAP Practice
ต้�องการให้�สร�างต้�วแปรชื่��อ firstname และ lastname โดยให้�ค่�าชื่��อของค่�ณก�บต้�วแปร firstname และนามสก�ลของค่�ณให้�ก�บต้�วแปร lastname พร�อมทั้�$งแสดงค่�าข�อม%ล firstname ก�บ lastname ออกมาทั้&�ห้น�าจอ
![Page 51: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/51.jpg)
Structure
![Page 52: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/52.jpg)
StructureStructure
* SyntaxDATA BEGIN OF <structure name>.DATA field1. DATA field2.
……
DATA END OF <structure name>.
![Page 53: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/53.jpg)
StructureStructure
* SyntaxDATA 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.
id city
wa
0000000
0
name
![Page 54: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/54.jpg)
Defining Structure (Include Structure)Defining Structure (Include Structure)
* Include StructureDATA BEGIN OF wa. INCLUDE STRUCTURE customers.DATA tel(7).DATA END OF wa.
![Page 55: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/55.jpg)
Defining StructureDefining Structure
* LIKE optionDATA wa LIKE customers.wa-id = 1.wa-name = ‘John’.WRITE: wa-id, wa-name.
![Page 56: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/56.jpg)
ABAP Practice
ต้�องการให้�สร�าง Structure ชื่��อ myname โดยม&ฟิ)ลด* firstname และ lastname โดยให้�ค่�าชื่��อของค่�ณก�บฟิ)ลด* firstname และนามสก�ลของค่�ณให้�ก�บฟิ)ลด* lastname พร�อมทั้�$งแสดงค่�าข�อม%ลของ Structure ทั้&�ชื่��อ myname ทั้�$งฟิ)ลด* firstname และ lastname ออกมาทั้&�ห้น�าจอ
![Page 57: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/57.jpg)
Constants
![Page 58: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/58.jpg)
ConstantsConstants
* Constant variableCONSTANTS max_no TYPE I VALUE 999. DATA counter TYPE I VALUE max_no.WRITE: max_no, counter.
![Page 59: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/59.jpg)
Constants Using ExampleConstants Using Example
* Constant variableCONSTANTS ctext(11) TYPE C VALUE ‘Hello World’. WRITE ctext.WRITE ctext.WRITE ctext.WRITE ctext.WRITE ctext.
![Page 60: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/60.jpg)
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 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
syst-datum
![Page 61: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/61.jpg)
ABAP System Fields : Structure SYST (SE11)
![Page 62: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/62.jpg)
DATEDATE
* 8Fixed Length * Include Representation ‘tttttttt’
DATA today TYPE D. -today = sy datum.
WRITE today. 19991231today = ‘ ’. WRITE today.
![Page 63: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/63.jpg)
TIMETIME
* Fixed Length 6* Format ‘HHMMSS’DATA times TYPE T.times = sy-uzeit.WRITE times.
HHMMSS
![Page 64: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/64.jpg)
MOVE StatementMOVE Statement
DATA wa LIKE customers. DATA vender LIKE customers.
wa- id = ‘1234’.wa- #1name = ‘Test ’.tttt wa TO vender.
WRITE: wa- -id, vender name.
“vender = wa.
![Page 65: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/65.jpg)
MOVE-CORRESPONDING StatementMOVE-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 .
![Page 66: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/66.jpg)
Field-symbols
![Page 67: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/67.jpg)
Field-symbolsField-symbols
ttttt name (4) Value ‘Test’, 10num Type I Value , 19980429today Type D Value ‘ ’.
- Field symbols <temp>. Assign name To <temp>. Write <temp>.
Assign num To <temp>. Write <temp>.
Assign today To <temp>. Write <temp>.
![Page 68: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/68.jpg)
Field-symbols : UNASSIGNField-symbols : UNASSIGN
ttttt name (4) Value ‘Test’,f - ield symbols <temp>.tttttt name To <temp>.w rite <temp>.una ssign <temp>.
![Page 69: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/69.jpg)
CLEAR StatementCLEAR Statement
Example:
DATA tmp type i value 9.tmp = 10.CLEAR tmp.
“ Clear statement sets a field to an initial value appropriate for its type” CLEAR <data object>.
![Page 70: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/70.jpg)
CLEAR StructureCLEAR Structure
DATA wa like customers.…CLEAR wa.
![Page 71: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/71.jpg)
ABAP Report : Program Structure
Report ztest.*Data objects declarationdata ...data begin of ...*Program Logic(Data objects
processing)…write ….
![Page 72: Abap programming overview](https://reader033.vdocument.in/reader033/viewer/2022051311/54532013af7959904c8b961e/html5/thumbnails/72.jpg)
ABAP Practice