Do you Know ?

Factorial Program in SAP ABAP.

9 out of 10 programmers kick start they career with writing simple logical programs like
Factorial, it holds logical flow that is why experts recommend kicking start with these types of programs to understand language better.

Let us begin creating Factorial Program in SAP ABAP.

Step 1: Go to SE38 and Create an Executable Program.


Click on Create button.

Step 2 :

Maintain

Type : Executable
Status : Test Program

Click  Save !

Step 3:

Maintain Following Code:
=============================================================

REPORT  ZFACTORIAL.

PARAMETER FACT TYPE I.

DATA RESULT TYPE I.

RESULT = 1.

WHILE FACT > 0.
RESULT = RESULT * FACT.
FACT = FACT - 1.
ENDWHILE.

WRITE:/ RESULT.

 ================================================================================

Ctrl + F2 – To Check Syntax errors.
Ctrl + F3 – To Activate.


Step 5 :

Press F8 to Execute!

Input - 5.
Expected value: 120

Again Press F8 to Execute.