Ex:
DATA : FACT TYPE I.
PARAMETERS : NUM TYPE I.
PERFORM FACTORIAL USING NUM CHANGING FACT.
WRITE : 'FACTORIAL OF ', NUM , '=', FACT.
*&---------------------------------------------------------------------*
*& Form FACTORIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NUM text
* <--P_FACT text
*----------------------------------------------------------------------*
form FACTORIAL using VALUE(p_num)
changing p_fact.
P_FACT = 1.
WHILE P_NUM >= 1..
p_fact = p_fact * P_NUM.
P_NUM = P_NUM - 1.
ENDWHILE.
endform. " FACTORIAL
Steps
- Go to transaction code SE38.
DATA : FACT TYPE I.
PARAMETERS : NUM TYPE I.
PERFORM FACTORIAL USING NUM CHANGING FACT.
WRITE : 'FACTORIAL OF ', NUM , '=', FACT.
*&---------------------------------------------------------------------*
*& Form FACTORIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NUM text
* <--P_FACT text
*----------------------------------------------------------------------*
form FACTORIAL using VALUE(p_num)
changing p_fact.
P_FACT = 1.
WHILE P_NUM >= 1..
p_fact = p_fact * P_NUM.
P_NUM = P_NUM - 1.
ENDWHILE.
endform. " FACTORIAL
----------------------------------------------------------
No comments:
Post a Comment