Search
Search

# Number range mapping to alphanumeric numbers.

Gurus,

I want some help in writing some logic in ABAP. I have a scenario when a the numbers that are coming via interface are greater then 99. In that case, I have to map according to following scenario:

Ex: If its 100, it should be converted to A1 and so on..

A0-A1--

A9-AA--

AZ (100 - 135)

B0-B1--

B9-BA--

BZ (136 - 171)

-

-

Z0-Z1--

Z9-ZA--

ZZ

Thanks.

Regards,

Rajesh.

##### Naimesh Patelreplied

Try something like this:

```PARAMETERS: p_num TYPE i.

DATA: l_type_36(36) TYPE c.

CONCATENATE '0123456789' sy-abcde INTO l_type_36.

DATA: l_temp_num TYPE i,
l_mod_36 TYPE i,
l_div_36 TYPE i,
l_co    TYPE char10,
l_code TYPE char2.
IF p_num > 99.
l_temp_num = p_num - 99.
l_mod_36 = l_temp_num MOD 36.
l_div_36 = l_temp_num DIV 36.

l_code+1(1) = l_type_36+l_mod_36(1).
l_code+0(1) = sy-abcde+l_div_36(1).
ELSE.
l_co = p_num.
CONDENSE l_co.
l_code = l_co.
ENDIF.

WRITE: 'Number', p_num.
WRITE: / 'Code   ', l_code.
```

Test results:

```Number        135
Code    AZ
```

Regards,

Naimesh Patel

0 View this answer in context
View more on this topic or