Program To display the triangle using special character
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.
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
characters
Num of times: it should not exceed 10 times.
Go to Se38 and enter the program name and
select create.
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.
of times field.
Click on Execute .
Output of the program (Below screen):
Now re-write it in object oriented ABAP.
Reminds me of my first exercises in Programming.. These are what we all do in C, C++, JAVA etc. to learn 🙂
I'm pretty sure that "+" is a special character. Still, I got an error.
Initial codes we learnt from C and C++ thanks for remembering it...
Hi Sreedevi,
Good Evening!
Nice blog for beginners! Thanks for sharing.
Regards,
Hari Suseelan
hi, is this possible for printing full diamond shape output using the above concept.?