Application Development and Automation 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: 
Read only

ABAP program

Former Member
0 Likes
837

hi,

i want to write the program to print the pattern

12345

5432

234

43

3

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
611

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
Read only

Former Member
0 Likes
612

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.

Read only

Former Member
0 Likes
611

Hi

Use the Loops like DO..ENDDO.

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

Regards

Anji

Read only

former_member195698
Active Contributor
0 Likes
611

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