Program To display the triangle using special character
(By Polu Sreedevi)
Developed the program to display the
triangle using any special characters like ‘!@#$%^&*’. Here in selection
screen I am passing any special character and number of times and doing
validations on special character and num of times.
Validation: It should allow only special
characters
Num of times: it should not exceed 10 times.
Go to Se38 and enter the program name and
select create.
Write the below logic in source code.
DATA:i TYPE n,
j TYPE n.
*Selection Screen
PARAMETERS:p_spec TYPE c,
p_cnt(2) TYPE n.
*Declare constants
CONSTANTS: c_spec TYPE char10 VALUE'!@#$%^&*()',
c_cnt TYPE char2 VALUE'10'.
*Validation
AT SELECTION-SCREEN .
*if it's not special character
then display error message as 'Enter valid input'.
IF p_spec NA c_spec.
MESSAGE text-001 TYPE 'E'.
ENDIF.
*If it's exceeds 10 then display
error message as 'Enter valid input'.
IF p_cnt GT c_cnt.
MESSAGE text-001 TYPE 'E'.
ENDIF.
START-OF-SELECTION .
*Logic
i = 1.
DO p_cnt TIMES.
IF i LE p_cnt.
j = 1.
DO i TIMES.
IF j LE i.
WRITE: p_spec.
j = j + 1.
ENDIF.
ENDDO.
WRITE /.
i = i + 1.
ENDIF.
ENDDO.
Selection Screen:
Enter Special Character and enter number in no
of times field.
Click on Execute .
Output of the program (Below screen):