*URGENT* how to increment Code type variable

leon1983leon1983 Member Posts: 20
Hi

In my C/al code I have to increment the the 'last number used' field in the 'no. Series Line' table.

**************************************
I load the last number used in variable docno :
**************************************

docno:=NoSeries."Last No. Used"

*****************
the variables are:
*****************

docno =>code
NoSeries => record of subtype No. Series Line


**********************************************************
now I want to increment docno and then inject it in the table to update "Last number used" field.
**********************************************************
docno=docno+1 wont work since docno is of Code type and not integer.


Does anyone know how I can increment such a variable ? Or maybe convert a Code type to integer and then vice versa?


thank you !

Comments

  • SavatageSavatage Member Posts: 7,142
    edited 2007-07-03
    I'm not sure what you are trying to do but...

    Why not make docno type integer. do what you need to do

    DocNo := DocNo + 1;
    etc.

    and then use the format function when all is done to take your result and put it in a code field?
    http://www.mibuso.com/forum/viewtopic.php?t=19147
    leon1983 wrote:
    Or maybe convert a Code type to integer and then vice versa?
    code_variable := FORMAT(integer_variable);
    note: use the EVALUATE function to convert Code to Integer


    ***Why isn't your No. Series incrementing in the first place? Perhaps this is the question you should be asking? Like I said I'm not sure what you are trying to accomplish.
  • ivo.sabioncelloivo.sabioncello Member Posts: 7
    You can use the INCSTR function.
  • SavatageSavatage Member Posts: 7,142
    You can use the INCSTR function.
    NewString := INCSTR(String)
  • leon1983leon1983 Member Posts: 20
    thank you very much, I can now increment the code number. But it seems that I'm not incrementing the right variable.





    I want to change the number that is by default in the 'No.' field when I open the 'purchase invoice ' form.

    that number coresponds to 'P-INV' in the 'no. series line' table
    I thought that by changing 'Last No. Used' it would change the No that appears by default when I open the form, but it doesnt work : / .

    Does anyone know how to modify what apears by default in the 'No.' field when you open the 'purchase invoice ' form?


    thanks a lot
  • SavatageSavatage Member Posts: 7,142
    edited 2007-07-03
    ok now it's clear..Next time add what you are trying to do first thing! :mrgreen:

    Onopen form you want it to automatically have an order number so you can get right to putting an order in or whatever.

    Now this has been discussed a few times (i'll search for it later) but if you do this then everytime you open the form a new order will be created even if you just want to look at it again. Now this WILL create (eventually) a bunch of open, unsued orders sitting around.

    is F3-enter really to much to do?

    **edit
    Here's one
    http://www.mibuso.com/forum/viewtopic.php?t=5964

    maybe David can fix the MBSonline links for me [-o<

    I like this one too :lol:
    http://dynamicsuser.net/forums/thread/67711.aspx
  • leon1983leon1983 Member Posts: 20
    I will start from the beginning :p



    I have created an XML port to import XMLs containing info on invoices. The info gets dumped in the general journal line table.

    I use the code in the 'No.' field of the purchase invoice form to fill the field 'document no.' in the general journal for each record.

    So suppose the 'No'. on the purchase invoice form is set a 1001 by default when I open the purchase invoice form.
    If I import 10 XMLs, which create 10records in GJ line table. Those 10 records must have 'Document No.' 1001 1002 1003...1011.
    Then suppose after that I want to insert a purchase manually with the 'Purchase invoice form', I want to have it so that when I open the form I get 1012 set in the 'No.' field by default.


    I'm stuck on initializing that 'No.' field
    ](*,)

    thanks in advance :p
  • SavatageSavatage Member Posts: 7,142
    Ahh, i thought it was clear before but now it's better.

    I'm not and XML port expert but perhaps this can point you in the direction you need to go.
    http://www.mibuso.com/forum/viewtopic.php?t=18748
  • leon1983leon1983 Member Posts: 20
    hmm

    actually never mind the xml port part


    just wondering where you initialize the default "No." field in the purchase invoice form. ](*,)
    thats the thing I'm trying to increment
  • SavatageSavatage Member Posts: 7,142
    perhaps i'm reading this too fast -
    ok what i understand now is that you are using Numbers but the No. series is NOT increasing. when you import. so for each imported "thing" you want to increase the no series by that #.

    You would have to update the No. Series Line Table (309).
    find your series code P-INV (or whichever)
    change the Last # usedfield.

    then add a "No. Series Line".MODIFY; statement.

    I really think using # series management codeunit to enter the numbers while importing is the way to go.
  • leon1983leon1983 Member Posts: 20
    its what i did

    I coded the thing so that it increment the "last No. used' Field for P-INV in 'No Series line' table. But for some weird reason it doesn't change the default value in 'No." when you pop a Purchase invoice form although 'Last No used' has changed ](*,) ](*,) ](*,)

    It looks like the Purchase invoice form doesn't read in the No Series line table when it initializes #-o #-o #-o
    Where does it read that default value?

    :-k :-k :-k
  • SavatageSavatage Member Posts: 7,142
    1 last thing before i go on holiday \:D/
    so you see that the last no used HAS BEEN changed by your code in the no series line table (309)?
  • David_CoxDavid_Cox Member Posts: 509
    Why are you trying to code for the number series, just use the standard functions?

    The wheel has already been invented! :lol:
    If I import 10 XMLs, which create 10records in GJ line table. Those 10 records must have 'Document No.' 1001 1002 1003...1011.

    I coded the thing so that it increment the "last No. used' Field for P-INV in 'No Series line' table.

    On Pre Report or Data Item
    PurchSetup.GET;
    PurchSetup.TESTFIELD("Invoice Nos");

    In your code and the G/L Line you are making
    CLEAR(NoSeriesMgt);
    "Document No." := NoSeriesMgt.GetNextNo(PurchSetup."Invoice Nos",TODAY,TRUE);

    This will use the next number and update the number series, if I am reading your post correctly?

    David

    NOTE:
    //If you wanted to Insert Purchase Invoices in code
    PurchHeader.INIT;
    PurchHeader."Document Type" := PurchHeader."Document Type"::Invoice;
    //Clear the Number as Init leaves the old value
    PurchHeader."No." := '';
    PurchHeader.INSERT(TRUE);

    This will use the next number and update the "No Series"
    Add your Vendor etc and Modify, then create your lines
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.