Increment Code variable-Error

nazunazu Member Posts: 70
Hi Experts,

Please help me with following situation

I have a code variable sat cd:='A001'.I want to increment it till 'A0015'.

How do increment?I used the strlen(cd)+1.but when the output reaches till A0010 it displayes some vague cahracters.Please help

Comments

  • kapamaroukapamarou Member Posts: 1,152
    If you think about it, this is how number series work. So look at codeunit NoSeriesManagement and you'll find an answer there.
  • nazunazu Member Posts: 70
    Thanks for the answer.I trued using that .I used the function getnextno.Bt it is not working
  • kapamaroukapamarou Member Posts: 1,152
    nazu wrote:
    Bt it is not working

    Then there is something wrong...
    Can you show us what you've written?
  • BeliasBelias Member Posts: 2,998
    this can't work...if you start with A001 the serie will go from A001 to A010 and then all the way through A999...you can't add one more character...
    if you want A0015, you have to start your number serie from A0001, not from A001...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • nazunazu Member Posts: 70
    How about A015? :(

    Say example there is a field called ext.ref no

    "Ext. Reference No."[STRLEN("Ext. Reference No.")]:=
    "Ext. Reference No."[STRLEN("Ext. Reference No.")] + 1;
    and based on certain parameter it ahs to be incremented.Say i give the ext as 'A001' and i give the other paramenter as 4.so it should generate from A001 to A016.The numbers are getting generated bt from A010 it is showing as A0&8(some symbol afte A).
  • BeliasBelias Member Posts: 2,998
    :shock:
    this code comes directly from the hell...you have to learn the basic principles of NAV before writing code...i can't correct your code because it's completely wrong: square brackets...you have to study the manuals, ask a senior developer, see what standard code does, see online help...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kapamaroukapamarou Member Posts: 1,152
    nazu wrote:
    "Ext. Reference No."[STRLEN("Ext. Reference No.")]:=
    "Ext. Reference No."[STRLEN("Ext. Reference No.")] + 1;

    This is translated (probably) to:

    From "Ext. Reference No." take character at position x and turn it to the character represented by x + 1 in the current set.

    kapamarou wrote:
    look at codeunit NoSeriesManagement and you'll find an answer there.

    Did you follow that advice? There is a call to INCSTR in that codeunit.
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • nazunazu Member Posts: 70
    I m nt getting it.i cant use directly incstr & getnextno throws an error
  • kinekine Member Posts: 12,562
    throws an error

    Which one?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nazunazu Member Posts: 70
    cd:='A0001';
    cduno.GetNextNo(cd,today,true);
    It says A001 doesnt exist :(
  • kinekine Member Posts: 12,562
    Yes, of course, the parameter is Number Series code, not number to increment... ;-) if you want to increment the string, use INCSTR function.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nazunazu Member Posts: 70
    I am not able to increment the code value.The code value is given manually say A0001.How do i increment.

    Any more reply
  • kapamaroukapamarou Member Posts: 1,152
    Have you read any of the documentation? Is there anyone experienced in your company to help you? :-k
  • kinekine Member Posts: 12,562
    nazu wrote:
    I am not able to increment the code value.The code value is given manually say A0001.How do i increment.

    Any more reply
    Have you even read my reply?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • SogSog Member Posts: 1,023
    nazu wrote:
    I am not able to increment the code value.The code value is given manually say A0001.How do i increment.

    Any more reply
    kine wrote:
    If you want to increment the string, use INCSTR function.

    A0002 := incstr(a00001);
    A0010 := incstr(a00009);
    and so on and so forth.
    The answer has been given, but please tell me you are working on this for training and not for a customer.
    (how to find incstr, in the code page, press F5, you can see 3 columns, in the first, search for SYSTEM, in the second, search for String, and you'll find all your (handy) string functions in the 3th column, a question about any variable in these columns, stand on it and press F1! :))
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • BeliasBelias Member Posts: 2,998
    Sog wrote:
    ........(how to find incstr, in the code page, press F5, you can see 3 columns, in the first, search for SYSTEM, in the second, search for String, and you'll find all your (handy) string functions in the 3th column, a question about any variable in these columns, stand on it and press F1! :))
    you could have simply said: "read my signature!" (pressing F1 is so much faster...) :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.