How to fill No. Series in Gen. Journal Line?

Heike_BennerscheidHeike_Bennerscheid Member Posts: 23
I hope somebody can help me here.

I have a report which sums some Invoices. When the report is done it calls a second report which fills the Gen. Journal Line Table. I created a No. Series which is filled in the Gen. Journal Line Table too. Here is the code:
PurchaseSetup.GET();
PurchaseSetup.TESTFIELD("Provisionsgutschrift-Nr.");
"Gen. Journal Line"."Document No." := NoSeriesMgt.GetNextNo(PurchaseSetup."Provisionsgutschrift-Nr.",0D,FALSE);

I used FALSE at the end of the function call because I had problems when I wanted to post the filled lines. But now I have the problem that when I have more than one line the No. Series isn't count further.

Line 1: Vendor 4711 No. Series GUTA00061
Line 2: Vendor 0815 No. Series GUTA00061

I hope you can understand what I mean and maybe can help me.

Answers

  • DaveTDaveT Member Posts: 1,039
    Hi Heike,

    I think your problem is not the document no. but the batch you are using. If you specify a no. series in the batch then the line much match the sequence and is difficult to maintain especially if user are manually using the batch. The best way is to allocate a batch for these posting and either leave the no. series blank or code it that manual user cannot enter into the batch.

    Hope this helps
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • byllebylle Member Posts: 47
    Hi Heike

    You don't get a new "Document No." because you have used FALSE. False means, that No. Series will not be update - and therefore Navision does not know that you already have used the specific number.

    You can solve this in several ways:

    1) Change FALSE to TRUE, as I can understand this is not really an option for you.

    2) Try using NoSeriesMgt.SaveNoSeries(); after each insert.
    SaveNoSeries simply does the same as the TRUE option, its modifies the NoSerieLines for you and thereby you should get a new number next time you call GetNextNo

    3) Control NoSeries by yourself. E.g. first time call GetNextNo, to get next number - afterwards increment the number through code, and then end by modifying the NoSeriesLines with the last used number.

    This way is not recommended, if you have several users using the same NoSeries - but if this is a NoSeries special created for your report, it is certainly an option - because you would also gain some performance. It cost time every time you have to modify the NoSeries table, which also can cost unnecessary locks for your users, depending on your commit rate.

    Before doing any of these steps, I would – if I was you, reconsider my code and check if it's really not possible to use the TRUE option. The TRUE option would be the best way ;-)

    Hopes this guides you in a direction, which can solve your problem.
  • Heike_BennerscheidHeike_Bennerscheid Member Posts: 23
    Thanks you two.

    The problem I have with the TRUE parameter is that when I want to post the Journal Lines I got an Error that he wants to have the next number.

    Line: Vendor 0815 No. Series GUTA00061

    Error: Document No. must be GUTA00062 in Gen. Journal Line Journal Template Name='TAP', Journal Batch Name='TAP', Line No.='1000'.

    I think when I use the other steps which you told me that the Error will come too. Because the post routine awaits the next number.
  • EugeneEugene Member Posts: 309
    try posting each document separately (that is each document no. should be posted before filling in journal lines with the next document no.)
    But the question really is why do you want to use new document no. for each journal line ?
  • DaveTDaveT Member Posts: 1,039
    Hi Heike,

    Have you tried a batch the the no. series blanked in the general journal batches line (i.e. drill up on the batch no.) ?
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • Heike_BennerscheidHeike_Bennerscheid Member Posts: 23
    Because it's like an invoice number. For each Vendor I need a new Document No.

    I can't post it before I fill the next line because the steps (fill the Journal and post it) are done from two diffent people.

    The first one fills the Journal with some lines (one line for each Vendor) and the second one post the lines after the first step is completly done.

    @DaveT

    Sorry but I don't understand what you mean :(
  • Heike_BennerscheidHeike_Bennerscheid Member Posts: 23
    The problem is solved. The Jounal Batch 'TAP' had the No. Series as the default Document No. That caused the error.
Sign In or Register to comment.