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: 

ABAP program

Former Member
0 Kudos
327

hi,

i want to write the program to print the pattern

12345

5432

234

43

3

1 ACCEPTED SOLUTION

Former Member
0 Kudos
101

Hi

try this code...

data: w_no type i value 1,

w_line type i value 5,

y type i.

do 5 times.

y = w_line mod 2.

if y eq 1.

do w_line times.

write w_no.

w_no = w_no + 1.

enddo.

write /.

w_line = w_line - 1.

w_no = w_no - 1.

endif.

if y eq 0.

do w_line times.

write w_no.

w_no = w_no - 1.

enddo.

write /.

w_line = w_line - 1.

w_no = w_no + 1.

endif.

enddo.

3 REPLIES 3

Former Member
0 Kudos
102

Hi

try this code...

data: w_no type i value 1,

w_line type i value 5,

y type i.

do 5 times.

y = w_line mod 2.

if y eq 1.

do w_line times.

write w_no.

w_no = w_no + 1.

enddo.

write /.

w_line = w_line - 1.

w_no = w_no - 1.

endif.

if y eq 0.

do w_line times.

write w_no.

w_no = w_no - 1.

enddo.

write /.

w_line = w_line - 1.

w_no = w_no + 1.

endif.

enddo.

Former Member
0 Kudos
101

Hi

Use the Loops like DO..ENDDO.

or WHILE..ENDWHILE.. and print the numbers with conditions

Regards

Anji

former_member195698
Active Contributor
0 Kudos
101

Its simple .. take your text in a character field.

data:wf_char(5) type c, "Text

wf_length type i. "Length

wf_char = '12345'.

wf_length = strlen(wf_char).

do.

if wf_length = 0.

exit.

endif.

write:/ wf_char(wf_length).

Call Function string_reverse.

wf_length = wf_length - 1.

wf_char = wf_char(wf_length).

enddo.

regards,

abhishek

Message was edited by:

Abhishek Jolly