Example programs for basic operations in SAP.
Example-1:
Report 01
DATA: a TYPE i,
b TYPE i,
c TYPE i,
d TYPE i.
a = 10.
b = a.
MOVE 20 TO c.
MOVE c TO d.
WRITE:/ a, b, c, d.
Output:
Example-1:
Assigning values to ABAP variables
DATA: a TYPE i,
b TYPE i,
c TYPE i,
d TYPE i.
a = 10.
b = a.
MOVE 20 TO c.
MOVE c TO d.
WRITE:/ a, b, c, d.
Output:
Example-2:
Basic Arithmetic Operations
Report 02
DATA: a TYPE i,
b TYPE i,
c TYPE i,
d TYPE i.
*Using Mathematical Expressions
a = 10 + 20.
b = 20 - 10.
c = 10 * 2.
d = 100 / 2.
WRITE:/ 'Using Expressions'.
WRITE:/ a, b, c, d.
*Using Keywords
add 10 to a.
subtract 5 from b.
multiply c by 2.
divide d by 2.
WRITE:/ 'Using Keywords'.
WRITE:/ a, b, c, d.
Output:
Eample-3:
Clear ABAP variables
keyword CLEAR is used to set the variables to default values.
Report 03
DATA: a TYPE i,
b TYPE i.
a = 10 + 20.
b = 20 - 10.
WRITE:/ 'Before Clear'.
WRITE:/ a, b.
clear: a, b.
WRITE:/ 'After Clear'.
WRITE:/ a, b.
Output:
No comments:
Post a Comment