ABAP Basics II
Northern Arizona University College of Business
Printing
To print the program code, copy the code into
Notepad and then print.
To print the screens (data entry or output),
capture the screen (Alt/print screen) and paste into Word. Then print from word.
Defining variables Data Types
C
I P
Character
Integer Packed Decimal
Whatever
25 19.95
D
T
Date
Time
20030121
143000
Data Statement
Data D_num Type I value 1 .
Data D_num LIKE sy-subrc .
The data type is determined dynamically at runtime from the like field .
Records
Data Begin of Demo_Record,
D_ID Type I , D_Name(30) Type C , End of Demo_Record .
Constants
Constants:
C_Number Type I value 1 , C_Name(20) Type C value Joe .
Write statement
Write Whatever .
Write Whatever . Write: Whatever: , Whatever . Write 20 Whatever .
Goes to column (position) 20 .
Write statement
Write 20(6)Whatever .
Goes to position 20, and prints for a length of 6 . Advances to the next line .
Write / .
Text Elements
Three types of Text Elements
List Headings Selection Texts
Text Symbol
Text Elements
GoTo
Text Elements
List Headings Selection Texts Text Symbol
10
Text Symbols
Alternate method of defining character
variables.
Number, Text, Length
001 Hi There
10
Write Text-001 .
11
Selection Texts
Text identifiers for parameter fields
(replaces parameter name).
Must make the program ACTIVE
Select REPS for the program from the worklist, and click on the continue icon
12
Selection Texts
Must SAVE the program
13
System Date and Time
Data:
Today type D , Now type T .
Today = sy-datum .
Now
= sy-uzeit .
14
Formatting
Write Today mm/dd/yyyy .
Write Now Using Edit Mask __:__ .
15
Alignment
Write Field1 Left-Justified .
Write Field2 Centered . Write Field3 Right-Justified . Write: /20 Field1 . Write: / Field2 under Field1 .
16
No Gaps
Write: Field1 No-Gap, Field2 .
17
Horizontal Lines
Uline .
Uline /20 . Uline /20(10) .
Uline: /20(10) .
18
Line Spacing
Skip .
Skip 3 . Skip to line 20 .
19
Column Spacing
Position 20 .
20
Character Data - Case
Data: F1(6) F2(6)
type C value abcdef , type C value ABCDEF .
Translate F1 to Upper Case . Translate F2 to Lower Case .
21
Character Data - Split
Data: F1(7) F2(3) F3(3)
type C value cba,nau , type C , type C .
Split F1 at , into F2 F3 .
22
Character Data - Concatenate
Data: F1(7) F2(3) F3(3)
type C , type C type C
value cba , value nau .
Concatenate F2 - F3 into F1 .
23
Character Data - Condense
Data:
F1(7) type C value cba nau.
Condense F1 No-Gaps .
24
Date & Time Fields
Data:
Today Next_Week type D , type D .
Next_Week = Today + 7 . days
25
Time Fields
Data: Now Now_Plus1
type T , type T .
Now_Plus1 = Now + 3600 . seconds
26
If Statement
If
Else . Whatever = 1 . EndIf .
A=B.
Whatever = 0 .
27