1 abap basics iii northern arizona university college of business
Post on 14-Dec-2015
227 Views
Preview:
TRANSCRIPT
2
Types
It is possible to define new data types.
These are known as user-defined types.
New types are defined using the Types statement.
4
Types
Types:
Bank_Acct(28) Type C.
Data:
Ckecking_Acct Type Bank_Acct.
Savings_Acct Type Bank_Acct.
5
Types
Types Begin of Demo_Type ,
D_ID Type I ,
D_Name(20) Type C ,
End of Demo_Type .
Data:
Old_Demo Type Demo_Type ,
New_Demo Type Demo_Type .
9
Arithmetic Operators
+ add- Subtract* multiply/ divide** exponentialDiv integer quotient of divisionMod integer remainder of division
11
Add Statement
Add 1 to Counter .or
Counter = Counter + 1 .
Add F1 then F2 until F9 giving Result .
12
Character Data – Offset & Length
Data:F1(6) Type C value ‘abcdef’ .F2(6) Type C value ‘ ‘ .
Move ‘x’ to F1+2 . “will space fillMove ‘x’ to F1+2(1) . “no space fillMove F1+0(3) to F2 .
13
Character Data – Shift
Data:F1(6) Type C value ‘abcdef’ .
Shift F1 . “shifts leftShift F1 circular .Shift F1 right .Shift F1 by 4 places .
14
Character Data – Replace
Data:
F1(7) Type C value ‘XXX-NAU’ .
Replace ‘XXX’ with ‘CBA’ into F1 .
The strings are case sensitive .
15
Character Data – Search
Data:
F1(7) Type C value ‘CBA-NAU’ .
Search F1 for‘CBA*’ .
Sy-subrc = 0 (match)
or 4 (no match).
17
Case Statement
Data Field1 Type I .Case Field1 .
When 1 .Write ‘The value is 1’ .
When 2 .Write ‘The value is 2’ .
When Others .Write ‘The value is greater than 2’ .
EndCase .
18
Case Statement
Data Field1(1) Type C .Case Field1 .
When ‘a’ .Write ‘The value is a’ .
When ‘b’ .Write ‘The value is b’ .
When Others .Write ‘The value is greater than b’ .
EndCase .
19
Case Statement
Case sy-subrc .
When 0 .
Write ‘The value is zero’ .
When Others .
Write ‘The value is not zero’ .
EndCase .
22
If Statement
If A < 50 .
Whatever = 0 .
ElseIf A = 50 .
Whatever = 1 .
Else .
Whatever = 2 .
EndIf .
24
Logical Operators
Is InitialBetween value1 And value 2 CO contains onlyCA contains anyCS contains stringCP contains pattern
25
If Statement
If W_Field is Initial .
If Not ( W_Field is Initial ) .
If W_Field is between 10 and 20 .
26
If Statement
Data W_Field(6)type C Value ‘abcdef’ .
If W_Field CO ‘abcdef’ . “only
If W_Field CA ‘a’ . “any
IFW_Field CS ‘bc’ . “string
IFW_Field CP ‘*b+d*’ “pattern
29
Do Loop
Data Cnt type I value 10 .
Do Cnt times.
Write: / ‘the loop count is: ‘, sy-index .
EndDo.
31
Do Loop - Exit
Data Cnt type I value 10 .
Do Cnt times.
Write: / ‘the loop count is: ‘, sy-index .
If sy-index = 5 .
Exit .
EndIf .
EndDo.
32
While Loop
Data: Cnt type I value 0 ,
Limit type I value 10 .
While Cnt < Limit .
Cnt = Cnt + 1 .
Write: / ‘the loop count is: ‘, Cnt .
EndWhile .
top related