2006 Mar 28 10:30 AM
I have a requirement...where if the string contains 'A'.
I have to get the next letter..that is 'B....
How to do this
2006 Mar 28 10:37 AM
PARAMETERS char TYPE c DEFAULT 'A'.
DATA cnt TYPE i.
SEARCH sy-abcde FOR char IN CHARACTER MODE.
cnt = sy-fdpos + 1.
IF cnt GE 26.
cnt = 0.
ENDIF.
WRITE sy-abcde+cnt(1).
2006 Mar 28 10:34 AM
Cook your own logic:
using case statement
case character.
when 'A'.
Next_alphabet = 'B'.
when 'B'.
Next_alphabet = 'C'.
.
.
..
.
.....
.
when 'Z'.
Next_alphabet = 'A'.
endcase.
2006 Mar 28 10:45 AM
data: abcd type sy-abcde.
data: source_string(1) .
data: moff type i ,
mlen type i ,
next_alpha(1) .
move: sy-abcde to abcd .
source_string = 'G' .
find source_string in abcd MATCH OFFSET moff MATCH LENGTH mlen.
if sy-subrc eq 0.
moff = moff + 1 .
next_alpha = abcd+moff(1) .
endif .
Regards
Raja
2006 Mar 28 10:35 AM
Hi vinotha,
you can use sy-ABCDE.
it contains all the alphabets in series..
just check the input and give the next one from it..
regards
satesh
2006 Mar 28 10:37 AM
PARAMETERS char TYPE c DEFAULT 'A'.
DATA cnt TYPE i.
SEARCH sy-abcde FOR char IN CHARACTER MODE.
cnt = sy-fdpos + 1.
IF cnt GE 26.
cnt = 0.
ENDIF.
WRITE sy-abcde+cnt(1).
2006 Mar 28 10:43 AM
Hi vinotha,
1. simple.
(we have to make use of the field
sy-abcde
sy-fdpos
)
2. just copy paste in new program
it will give A----
>B
B----
>C
.
.
.
Z----
> A
3.
REPORT abc.
PARAMETERS: : a(1) TYPE c DEFAULT 'A'.
DATA : b(1) TYPE c.
PERFORM getnext USING a b.
*----
WRITE 😕 b.
*----
INDEPENDENT FORM
*----
FORM getnext USING oldval newval.
DATA : chr TYPE c.
DATA : pos TYPE i.
chr = oldval.
IF sy-abcde CS chr.
sy-fdpos = sy-fdpos + 1.
<b> IF sy-fdpos > 25.
sy-fdpos = 0.
ENDIF.</b>
newval = sy-abcde+sy-fdpos(1).
ENDIF.
ENDFORM. "
regards,
amit m.
2006 Mar 28 10:50 AM
U can use the following code.. it goes in cyclic way if u don't need this u can comment that part.
data: nxt(1).
parameter chr(1).
search sy-abcde for chr.
if sy-subrc = 0.
if sy-fdpos <> 25.
sy-fdpos = sy-fdpos + 1.
else.
sy-fdpos = 0.
endif.
nxt = sy-abcde+sy-fdpos(1).
write : nxt.
else.
write : 'Last Char'.
endif.