Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Print stars.

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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