Print The Characters in Reverse Order

How to print the characters  in Reverse Order?

This is the ABAP program logic you can used.

1. Get all the individual characters of your text into a string along with spaces.
2. Get the string length.
3. Starting from the nth character, keep extracting the character of the string and populate into another string (say result string), decrement the counter and continue, exit when there are no more characters left.
4. Write the result string.
 

With function STRING_REVERSE it will success fine, but you have to change the type if str. 

See below: 

data: str(20) type c value 'madhvi'. 

WRITE: / 'input ', str. 

new-line. 

CALL FUNCTION 'STRING_REVERSE' 
    EXPORTING 
        STRING = STR 
        LANG = SY-LANGU 
    IMPORTING 
        RSTRING = STR 
    EXCEPTIONS 
        TOO_SMALL = 01. 
WRITE: / 'output ', str. 
 

or
 

REPORT  ZPOLY.

data: mp type string value ' madhvi', int type i, col type i value 5, pos type i value 5.

int = strlen( mp ).
WRITE / int.
int = int - 1.

do int times.

  WRITE AT col(pos) mp+int(1).
   int = int - 1.
   pos = pos + 1.
   col = col + 1.

enddo. 
 

Reverse printing text in Smartforms

How to print some dynamic text in smartform with 270 degrees?

To print Dynamiv text in smartform with 270 degrees ,what you have to do is that you have to make a Window which is vertical which can hold exactly 1 character,. Now pass the Text , it will compeled to show it as vertical.

Let us suppose that the word is "HELLO" then you can only print:

H
E
L
L
O

Not like this :

O
L
L
E
H

ABAP

See Also:
Simple Abap Program Example

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.