Increment Number Series When Report Runs

erugalathaerugalatha Member Posts: 120
Hi,

I have a report which generates a file. In this file I need a unique file number identifier. I've decided to set up a No. Series for this file numbering but how do I get the new number from the No. Series into my file generated by the report? I do not know how to link report to no. series (maybe it does not work this way)

Thanks for your help.

Comments

  • krikikriki Member, Moderator Posts: 9,118
    Put this in the report to get a unique no.
    NoSeriesMgt.InitSeries(recSomeSetup."REPORTNOS",recSomeSetup."REPORTNOS",0D,codTheNumber,recSomeSetup."REPORTNOS");
    
    -recSomeSetup."REPORTNOS" should contain the no. series you want to use.
    -codTheNumber : this will contain the newly generated no. from the no. series.

    IMPORTANT: after calling this function, the table of the no. series will be blocked. So call this function as late as possible. After calling it, you should put a COMMIT to free the table again. But remember if after the COMMIT, there is some crash, the number will be used (or you have to put it back manually), even if your report hasn't finished yet.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    GetNextNo(TryNoSeriesCode,TrySeriesDate,TRUE);
    

    From the same codeunit is even shorter.
  • erugalathaerugalatha Member Posts: 120
    Great ... got that part working using Mark's way. Thank you.

    I've now run into another issue where the file is a daily file with a three digit file number (i.e. 001 to 999 files per day).

    Is there a way to reset the file numbering no. series on a daily basis?
    Or should I not use no. series at all e.g. create my own table and create a record for each days files?

    Thank you for your help.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You can remove the field Last No. Used from the No. Series Line [309] table. This resets the number series.

    Be carefull not to clear the wrong one.
  • krikikriki Member, Moderator Posts: 9,118
    You can also add 2 fields in some setup table (General Ledger Setup or other) : an integer for the counter and a date for the date when it was last updated.
    Then when you need a number you just check if the date in that table is today. If it isn't put the counter back to 0.
    Then add 1 to the counter, save the record. And you have a new number.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.