10-17-2007 8:16 AM
Hi,
i need a very fast conversion from
0 => A
1 => B
2=> C
.
.
.
25=> Z
It can be done via a case statement, but this is rather slow. Performance analysis shows that this is the third time consuming process. So i need a rather fast conversion routine.
A hash table is faster, but still it takes a long time. From other programming languages i know the function ORD which gives back the ascii value of the character. Subtracting 64 will give the wanted vonversion routine, but i cant find a function similar to ORD. Any other ideas to do the conversion?
10-17-2007 8:47 AM
Hi Rainer,
the offset solution will be fastest:
lv_letter = sy-abcde+lv_number(1).
will give exactly what you want: character field lv_letter stortes the letter for integer value lv_number for values 0..25 as in your example.
Regards,
Clemens
P.S.: If there is anything faster than this, I'd eat my shoes
Message was edited by:
Clemens Li
10-17-2007 8:25 AM
hi,
try this
a = 'ABCD..XYZ'.
DO 26 times.
l_index = sy-index - 1.
wa-var = a+l_index(1).
Append wa to itab.
clear wa.
ENDDO.
Regards,
Atish
10-17-2007 8:27 AM
first populate an internal table with values from a to z. and den use following logic:
PARAMETERS:zchar type c.
data:BEGIN OF it OCCURS 0,
zch(1) TYPE c,
end of it.
data zint type i.
it-zch = 'A'.
APPEND it.
it-zch = 'B'.
APPEND it.
it-zch = 'C'.
APPEND it.
it-zch = 'D'.
APPEND it.
it-zch = 'E'.
APPEND it.
READ TABLE it with key zch = zchar.
zint = sy-tabix - 1.
WRITE / zint.
plz reward points if dis helps
10-17-2007 8:47 AM
Hi Rainer,
the offset solution will be fastest:
lv_letter = sy-abcde+lv_number(1).
will give exactly what you want: character field lv_letter stortes the letter for integer value lv_number for values 0..25 as in your example.
Regards,
Clemens
P.S.: If there is anything faster than this, I'd eat my shoes
Message was edited by:
Clemens Li