Little more than ABAP Programing .Knowing about the Arithmetical, Relational and Logical operations also about Conditional and Loop Statement with Program.
Arithmetical operations :
Addition : +
Division : /
Subtract : -
Multiply : *
Remainder : MOD
Relational operations :
Less than : < or LT
Greater than : > or GT
Less than equal : <= or LE
Greater than equal : >= or GE
Equal : = or EQ
Not Equal : <> or NE
Logical operations :
1> AND
2> OR
3> NOT
Working With Loop and Conditional Statement.
Loop Statements :
1) Do <n> times
End do.
2) While <condition>
end while.
Conditional Statement :
1) If <condition>
endif.
2) If <condition>
Else <condition>
endif.
3) If <condition>
Elseif <condition>
Elseif <condition>
Else <condition>
endif.
4) Case : <condition>
When <value>
When <value>
When <value>
Endcase.
Program Name : ZRV_condition_stats
Coding :
Parameters : p_num1 type I,
p_num2 type I.
if p_num1 > p_num2
write : /'p_num1 GT p_num2', p_num1,
elseif p_num2 > p_num1
write : /'p_num2 GT p_num1', p_num1,
else p_num2 = p_num1
Write : /'Equal',
Endif.
Program Name : ZRV_case_stats
Coding :
case : p_num type I.
When 1
Write : /'1', p_num,
When 2
Write : /'2', p_num,
When others
Write : /'others', p_num.
Endcase.
Program Name : ZRV_loop
Coding :
do 5 times
Write : / sy-index.
enddo.
P.S : sy-index is a sytem variable which will give the current loop pass no.
Program Name : ZRV_loop
Coding :
do 5 times
Write : / sy-index.
if sy-index =5
exit
endif.
enddo.
P.S : By using Exit keywords you can terminate the loop.
Program Name : ZRV_loop
Coding :
do 5 times
if sy-index = 3
continue
endif.
Write : / sy-index.
if sy-index =5
exit
endif.
enddo.
P.S : Continue is used to skip the loop pass.
Program Name : ZRV_loop
Coding :
do
check sy-index = 3
Write : / sy-index.
if sy-index =5
exit
endif.
enddo.
P.S : Check statement : terminates the current loop pass conditionally.
Program Name : Zrv_while_stats.
Coding :
parameters : p_num type i.
While p_num > 0
Write : / p_num.
p_num = p_num - 1 .
endwhile.
No comments:
Post a Comment