*URGENT* how to increment Code type variable

leon1983
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 !
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 !
0
Comments
-
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=19147leon1983 wrote:Or maybe convert a Code type to integer and then vice versa?
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.0 -
You can use the INCSTR function.0
-
ivo.sabioncello wrote:You can use the INCSTR function.0
-
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 lot0 -
ok now it's clear..Next time add what you are trying to do first thing!
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
http://dynamicsuser.net/forums/thread/67711.aspx0 -
I will start from the beginning
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 advance0 -
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=187480 -
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 increment0 -
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.0 -
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 :-k0 -
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)?0 -
Why are you trying to code for the number series, just use the standard functions?
The wheel has already been invented!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 linesAnalyst 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.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions