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

Write a program to write your name in reverse order

Former Member
0 Likes
1,952

hi

This is ravinder

kindly help me with solution for the following

■ Design selection-screen that accepts a number and default to ‘5’

■ Write a program to write your name in reverse order

■ The writing should be restricted to only those many characters as number given in the selection screen

For example assume the user gives 5 in the selection screen. Then the output should be-

R

E

D

N

I

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,268

Hi

PARAMETERS: P_NUM      TYPE I DEFAULT 5,
            P_NAME(30) TYPE C.

DATA: V_LEN   TYPE I,
      V_TIMES TYPE I,
      V_POS   TYPE I.

START-OF-SELECTION.

  V_LEN = STRLEN( P_NAME ).

  IF V_LEN <= P_NUM.
    V_TIMES = V_LEN.
  ELSE.
    V_TIMES = P_NUM.
  ENDIF.

  V_POS = V_LEN - 1.

  DO V_TIMES TIMES.
    WRITE: / P_NAME+V_POS(1).
    V_POS = V_POS - 1.
  ENDDO.

Max

Edited by: max bianchi on Mar 19, 2008 2:39 PM

5 REPLIES 5
Read only

Former Member
0 Likes
1,268

e

Read only

Former Member
0 Likes
1,269

Hi

PARAMETERS: P_NUM      TYPE I DEFAULT 5,
            P_NAME(30) TYPE C.

DATA: V_LEN   TYPE I,
      V_TIMES TYPE I,
      V_POS   TYPE I.

START-OF-SELECTION.

  V_LEN = STRLEN( P_NAME ).

  IF V_LEN <= P_NUM.
    V_TIMES = V_LEN.
  ELSE.
    V_TIMES = P_NUM.
  ENDIF.

  V_POS = V_LEN - 1.

  DO V_TIMES TIMES.
    WRITE: / P_NAME+V_POS(1).
    V_POS = V_POS - 1.
  ENDDO.

Max

Edited by: max bianchi on Mar 19, 2008 2:39 PM

Read only

Former Member
0 Likes
1,268

Hi,

You can make use of FM STRING_REVERSE.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,268

hi use this,

data: test type string,

strlen type i,

i type i.

data: name(10) value 'reverse'.

i = strlen( name ).

do i times.

i = i - 1.

write:/ name+i(1).

if i le 6.

else.

exit.

endif.

enddo.

regards,

venkat.

Read only

Former Member
0 Likes
1,268

use ... STRING_REVERSE fm to achieve that ...


CALL FUNCTION 'STRING_REVERSE'
      EXPORTING
        string  = descr
        lang    = 'E'
      IMPORTING
        rstring = descr.