02-02-2006 8:55 AM
hi
i want to generate batch number from '0000' to any value but the new value must be with in 4 cahracters.
Ex: 9999 its new value is '9999'
12345 its new value be 'XXXX'(4 characters)
here '12345' is more than 4 characters should be converted to 4 characters.
plse sujjest idea.
by aaryaa
02-02-2006 8:58 AM
I think you had earlier posted the similar question. This converts the number to alphanumeric codes with length 4.
PARAMETERS p_i TYPE i.
DATA d_i1 TYPE i.
DATA d_i2 TYPE i.
DATA d_i3 TYPE i.
DATA d_i4 TYPE i.
DATA code(4).
d_i4 = p_i MOD 26.
p_i = p_i DIV 26.
d_i3 = p_i MOD 26.
p_i = p_i DIV 26.
d_i2 = p_i MOD 26.
p_i = p_i DIV 26.
d_i1 = p_i MOD 26.
code+0(1) = sy-abcde+d_i1(1).
code+1(1) = sy-abcde+d_i2(1).
code+2(1) = sy-abcde+d_i3(1).
code+3(1) = sy-abcde+d_i4(1).
WRITE code.
This one would generate the sequence : 0000 - 9999 then AAAA - AAAZ ...
PARAMETERS p_i TYPE i.
DATA d_i1 TYPE i.
DATA d_i2 TYPE i.
DATA d_i3 TYPE i.
DATA d_i4 TYPE i.
DATA flag TYPE i.
DATA code(4).
flag = 0.
IF p_i GT 9999.
p_i = p_i - 10000.
flag = 1.
d_i4 = p_i MOD 26.
p_i = p_i DIV 26.
d_i3 = p_i MOD 26.
p_i = p_i DIV 26.
d_i2 = p_i MOD 26.
p_i = p_i DIV 26.
d_i1 = p_i MOD 26.
ELSE.
d_i4 = p_i MOD 10.
p_i = p_i DIV 10.
d_i3 = p_i MOD 10.
p_i = p_i DIV 10.
d_i2 = p_i MOD 10.
p_i = p_i DIV 10.
d_i1 = p_i MOD 10.
ENDIF.
IF flag = 1.
code+0(1) = sy-abcde+d_i1(1).
code+1(1) = sy-abcde+d_i2(1).
code+2(1) = sy-abcde+d_i3(1).
code+3(1) = sy-abcde+d_i4(1).
ELSE.
code+0(1) = d_i1.
code+1(1) = d_i2.
code+2(1) = d_i3.
code+3(1) = d_i4.
ENDIF.
WRITE code.
Message was edited by: Wenceslaus G
02-02-2006 9:01 AM
if it is a number more than 4 char see how many charecter its more and devide that number by 1 followed those many more zeroes
ex: if it is 12345 then devide by 10 and take only whole number
if it is 123456 then also devide by 100 and take whole number
If the number already exists then
number = number + 1 or
number = number - 1
02-02-2006 12:11 PM
Create a number range object and assign the range. In the program use the function module NUMBER_GET_NEXT to get the next number and check if the number range target is reached. If yes reset the number range.
Regards,
Ankur Bhandari
p.s
Kindly appropriate reward points by clicking the star on the left of reply,if the solution is helpful.