Options

Generating number

metinemremetinemre Member Posts: 10
edited 2011-09-14 in Dynamics AX
Hi All,

I have to create next number from a string like "A000001" -> "A000002"

I'm not talking about number sequence function. I just want to do that. Should I create or find an UDF for it or there is any ready built-in function in Axapta?

Comments

  • Options
    metinemremetinemre Member Posts: 10
    I couldn't found anything about it and wrote that code:

    Static str AutoNum(str Num)
    {
    int i;
    int bas;
    str b;
    ;
    for (i=StrLen(num);i>=1;i--)
    {
    b=SubStr(num,i,1);
    if (b<"0" || b>"9")
    {
    bas=i+1;
    Break;
    }
    if (i==1)
    bas=1;
    }
    num=StrReplace(SubStr(num,1,bas-1)+
    Num2Str(Str2Num( SubStr(num,bas,StrLen(num) - bas + 1) )+1,
    StrLen(num) - bas + 1,0,1,0)," ","0");
    Return num;
    }
Sign In or Register to comment.