09-19-2007 1:38 PM
Hi,
Can any one tell me the logic to print stars like this,
*
* *
* * * *
* *
*
using abap code?
Note: no. of maximum stars will be entered by user.
Regards,
Martina
09-19-2007 1:45 PM
Hi Matrina,
Check this code.
PARAMETERS: P_STAR TYPE I.
DATA V_COUNT TYPE I.
DATA V_FLAG.
START-OF-SELECTION.
V_COUNT = P_STAR MOD 2.
IF V_COUNT = 0.
V_COUNT = 2.
ELSE.
V_COUNT = 1.
ENDIF.
DO P_STAR TIMES.
DO V_COUNT TIMES.
WRITE: '*'.
ENDDO.
SKIP.
IF V_COUNT = P_STAR.
V_FLAG = 'X'.
ENDIF.
IF V_FLAG IS INITIAL.
V_COUNT = V_COUNT + 2.
ENDIF.
IF V_FLAG IS NOT INITIAL.
V_COUNT = V_COUNT - 2.
ENDIF.
ENDDO.
<b>Note:</b> Dont post duplicate threads. Plz close the other duplicate threads by solved problem.
Thanks,
Vinay
09-19-2007 1:45 PM
Hi Matrina,
Check this code.
PARAMETERS: P_STAR TYPE I.
DATA V_COUNT TYPE I.
DATA V_FLAG.
START-OF-SELECTION.
V_COUNT = P_STAR MOD 2.
IF V_COUNT = 0.
V_COUNT = 2.
ELSE.
V_COUNT = 1.
ENDIF.
DO P_STAR TIMES.
DO V_COUNT TIMES.
WRITE: '*'.
ENDDO.
SKIP.
IF V_COUNT = P_STAR.
V_FLAG = 'X'.
ENDIF.
IF V_FLAG IS INITIAL.
V_COUNT = V_COUNT + 2.
ENDIF.
IF V_FLAG IS NOT INITIAL.
V_COUNT = V_COUNT - 2.
ENDIF.
ENDDO.
<b>Note:</b> Dont post duplicate threads. Plz close the other duplicate threads by solved problem.
Thanks,
Vinay
09-19-2007 1:59 PM
Dear Vinaykumar,
First of all thanx for reply...ur code is not up to the mark its printing only the half of the part.
I posted duplicate threads for the convinience of people who work on separate modules.....Otherwise i wouldn't have got the reply.
Regards,
Martina.
09-19-2007 2:06 PM
Hi Martina,
ABAP Development is the forum category which will have subcategories like data dictionary, form printing, abap objects etc. Please put your question in the write subcategory rather putting the same question in more than one subcategories to get the answers. People who will watch the ABAP Development category as a whole can see your questions as duplicates in sub categories.
I am able to get the output correctly. Will you check once with my code again??
It will work for both even and odd numbers too.
Thanks,
Vinay
Message was edited by:
Vinaykumar G
09-19-2007 2:08 PM
Hi,
From ur code wot i m getting is,
*
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * * only
i want the same at the lower part...
anyways thanx i got the code.
martina