‎2007 Feb 22 4:28 AM
Is there a key word or function module in ABAP which rotates a character or a string data. For example if the data is 'SAP', I should get it as 'PAS'.
Regards,
Aravind
‎2007 Feb 22 4:40 AM
See this code samepl
DATA: string11(15) type c.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = 'TEST PROGRAM'
lang = 'E'
IMPORTING
RSTRING = string11
* EXCEPTIONS
* TOO_SMALL = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ string11.DATA: ALPHABET(10) VALUE 'ABCDEFGHIJ',
THREE(3) VALUE 'DEF',
FOUR(4) VALUE 'DEF '.
SHIFT ALPHABET UP TO FOUR.
SY-SUBRC is now set to 4, and the field ALPHABET remains unchanged.
SHIFT ALPHABET UP TO THREE CIRCULAR.
SY-SUBRC is now set to 0 and ALPHABET has the contents 'DEFGHIJABC'.
DATA: ALPHA1(11) TYPE C VALUE 'ABCDEFGHIJ',
ALPHA2 TYPE STRING.
ALPHA2 = ALPHA1.
SHIFT ALPHA1 CIRCULAR.
SHIFT ALPHA2 CIRCULAR.
<b>
ALPHA1 now has the contents 'BCDEFGHIJ A' and ALPHA2 the contents 'BCDEFGHIJA'.</b>
Message was edited by:
Judith Jessie Selvi
‎2007 Feb 22 4:31 AM
data : str(3) type c value 'PAS',
str1(3) type c,
len type i,
pos type i,
len1 type i.
len = strlen( str ).
len1 = len.
len = len - 1.
do len1 times.
str1pos(1) = strlen(1).
pos = pos + 1.
len = len - 1.
enddo.
write : / str1.
regards
shiba dutta
Message was edited by:
SHIBA DUTTA
‎2007 Feb 22 4:31 AM
Use function module STRING_REVERSE
or u can use.
data : c(5) value 'ABCDE'.
data : l type i,i type i value -1.
data : str(5) .
l = strlen( c ).
do l times.
i = i + 1.
l = l - 1.
STR+i(1) = C+l(1).
enddo.
write STR.
‎2007 Feb 22 4:32 AM
HI,
USe:
<b>SHIFT C CIRCULAR.</b>
Shifts C cyclically, that is, the character that is pushed out
is reinserted at the other end of the string. You can use this
addition with both the RIGHT and LEFT additions.
DATA: ALPHA1(11) TYPE C VALUE 'ABCDEFGHIJ',
ALPHA2 TYPE STRING.
ALPHA2 = ALPHA1.
SHIFT ALPHA1 CIRCULAR.
SHIFT ALPHA2 CIRCULAR.
ALPHA1 now has the contents 'BCDEFGHIJ A' and ALPHA2 the
contents 'BCDEFGHIJA'.
Hope this helps.
Reward if helpful.
Regards,.
Sipra
‎2007 Feb 22 4:32 AM
Hi,
Use this FM STRING_REVERSE
pass the value to string
Regards
Shiva
‎2007 Feb 22 4:40 AM
See this code samepl
DATA: string11(15) type c.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = 'TEST PROGRAM'
lang = 'E'
IMPORTING
RSTRING = string11
* EXCEPTIONS
* TOO_SMALL = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ string11.DATA: ALPHABET(10) VALUE 'ABCDEFGHIJ',
THREE(3) VALUE 'DEF',
FOUR(4) VALUE 'DEF '.
SHIFT ALPHABET UP TO FOUR.
SY-SUBRC is now set to 4, and the field ALPHABET remains unchanged.
SHIFT ALPHABET UP TO THREE CIRCULAR.
SY-SUBRC is now set to 0 and ALPHABET has the contents 'DEFGHIJABC'.
DATA: ALPHA1(11) TYPE C VALUE 'ABCDEFGHIJ',
ALPHA2 TYPE STRING.
ALPHA2 = ALPHA1.
SHIFT ALPHA1 CIRCULAR.
SHIFT ALPHA2 CIRCULAR.
<b>
ALPHA1 now has the contents 'BCDEFGHIJ A' and ALPHA2 the contents 'BCDEFGHIJA'.</b>
Message was edited by:
Judith Jessie Selvi