Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

alphanumeric serial number increment

Former Member
0 Likes
3,071

Hi All,

Can anyone help me to increment an alphanumeric sequence.

For eq: 12B345A, should become 12B345B,12B345C...,12B345Z after Z it should take the second last character and inceremnt it, say 12B346A,12B346B,12B346C.........

Please let me know whether we can use some Function Modules for this operation or can anyone please help me with a pseudocode for the same.

Thanks in Advance,

Rijish

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
1,890

ARe positions 3 and 7 always the alpha characters, and the rest are always numeric?

Regards,

Rich Heilman

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
1,891

ARe positions 3 and 7 always the alpha characters, and the rest are always numeric?

Regards,

Rich Heilman

Read only

0 Likes
1,890

Thanks Rich! (For ur quick reply).

Not necessary .The alphabets can be at any position.The sequence is less or equal to 18 !

Read only

0 Likes
1,890

Try this Code:

data: v_str(7) type c,
      v_hx(1) type x,
      v_len type i,
      v_off type i.

field-symbols <fs>.

v_str = '12B345Z'.
write:/ 'Initial:', v_str.
v_len = strlen( v_str ).

v_off = v_len - 1.

do v_len times.

  if v_str+v_off(1) between 'A' and 'Z'.
    if v_str+v_off(1) lt 'Z'.
      assign v_str+v_off(1) to <fs> casting type x.
      add 1 to <fs>.
      exit.
    else.
      v_str+v_off(1) = 'A'.
    endif.
  elseif v_str+v_off(1) between '0' and '9'.
    if v_str+v_off(1) lt '9'.
      v_str+v_off(1) = v_str+v_off(1) + 1.
      exit.
    else.
      v_str+v_off(1) = '0'.
    endif.
  endif.
  v_off = v_off - 1.
enddo.

write:/ 'Final:', v_str.

Regards

Sridhar

Read only

0 Likes
1,890

Hi Sridhar,

Thanks for the code, itz working perfect.....

Once again thanks for your help...

regards

rijish

Read only

0 Likes
1,890

Its case sensitive?

Read only

Former Member
0 Likes
1,890

Hi,

use below pseudo code logic

lv_data = strlen( string ).

lv_data1 = sy-abcde.

case string+0(lv_data)

when 'A'.

string+0(lv_data) = 'B'.

.....

when 'Z'.

lv_data = lv_data - 1.

string0(lv_data)= string0(lv_data) + 1.

endcase.

Regards

Amole

Read only

Former Member
0 Likes
1,890

Rijish

What should happen when it reaches ...

12B346Z....

12B349Z...should the next be 12B350A or 12B34AA ?

Also in the case 12B999Z it should be followed by 12C000A or something else ???

Message was edited by: Anurag Bankley