Friday, November 23, 2007

sap abap conversion Program For Printing Prime Number

*&---------------------------------------------------------------------*
*& Report ZPRIME *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT zprime .
DATA : t_no TYPE i,
res TYPE p,
pr_no TYPE p,
tag TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS : pr_num TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
pr_no = 1.
WHILE pr_no LE pr_num.
t_no = 2.
tag = 0.
WHILE t_no < pr_no.
res = pr_no MOD t_no.
IF res = 0.
WRITE : / pr_no.
WRITE : 'is not PRIME Number ' COLOR 3 INTENSIFIED OFF.
tag = 1.
EXIT.
ENDIF.
t_no = t_no + 1.
ENDWHILE.
IF tag = 0.
WRITE : / pr_no.
WRITE : 'is PRIME Number ' COLOR 6 INTENSIFIED OFF.
ENDIF.
pr_no = pr_no + 1.
ENDWHILE.

No comments:

Blog Archive