Number Series Generation

vipinkuruvillavipinkuruvilla Member Posts: 143
Hai,

Can anyone tell me how I can generate number sereies ? I like to get some codes for the same. I have already added the necessary fields in the Sales & Recievables Setup screen and table . Only my code is not working. I dont have any document type as it is there in Sales Header. So Iam a bit confused.

Any help would be appreciated.......

Comments

  • krzychub83krzychub83 Member Posts: 120
    I am not sure if I get You well. You want to have an serial code, which will auto increment (like sales invoice No. does)?

    "Labour Contract Series No." is a code of 10, with Table Relation property set to "No. Series".Code
    ...
    IF PayrollAndHumanResSetup.FIND('-') THEN
    BEGIN
      PayrollAndHumanResSetup.TESTFIELD("Labour Contract Series No.");
      employeeContract."No." :=NoSeriesManagement.GetNextNo(PayrollAndHumanResSetup."Labour Contract Series No.", WORKDATE, TRUE);
    END
    ELSE
      ERROR(text001);
    ...
    
    NoSeriesManagement is an CU of the same name.
    NoSeriesManagement.GetNextNo(
    Your Series Code,
    Date (this date is going to be saved as the date of last assigned No.),
    dose it have to save the number as used (IF No then this number is still able to be taken.) );

    I hope it will help You.
  • JedrzejTJedrzejT Member Posts: 267
    Try to copy/use code from Customer table for example. There is One field in Primary key.

    OnInsert:
    IF "No." = '' THEN BEGIN
      SalesSetup.GET;
      SalesSetup.TESTFIELD("Customer Nos.");
      NoSeriesMgt.InitSeries(SalesSetup."Customer Nos.",xRec."No. Series",0D,"No.","No. Series");
    END;
    
    OnValidate-No.
    IF "No." <> xRec."No." THEN BEGIN
      SalesSetup.GET;
      NoSeriesMgt.TestManual(SalesSetup."Customer Nos.");
      "No. Series" := '';
    END;
    
    You must just change "customer Nos." on your New Nos.
    
    
  • vipinkuruvillavipinkuruvilla Member Posts: 143
    JedrzejT wrote:
    Try to copy/use code from Customer table for example. There is One field in Primary key.

    OnInsert:
    IF "No." = '' THEN BEGIN
      SalesSetup.GET;
      SalesSetup.TESTFIELD("Customer Nos.");
      NoSeriesMgt.InitSeries(SalesSetup."Customer Nos.",xRec."No. Series",0D,"No.","No. Series");
    END;
    
    OnValidate-No.
    IF "No." <> xRec."No." THEN BEGIN
      SalesSetup.GET;
      NoSeriesMgt.TestManual(SalesSetup."Customer Nos.");
      "No. Series" := '';
    END;
    
    You must just change "customer Nos." on your New Nos.
    
    

    From where i will get this "No.Series" ?? Do I have to add another field in my table with a lookup to the sales & Recievables setup? Please do advice.....
  • JedrzejTJedrzejT Member Posts: 267
    You must have field

    1.
    "No. Series" Code 10 with tablerelation to table "No. series" in Your table which have to be numbered.
    2.
    "New Table Nos." code 10 with tablerelation to table "No. series" in setup table.

    Use "new table Nos." instead "customer Nos.". That's all if you have table with one field primary key.
  • vipinkuruvillavipinkuruvilla Member Posts: 143
    JedrzejT wrote:
    You must have field

    1.
    "No. Series" Code 10 with tablerelation to table "No. series" in Your table which have to be numbered.
    2.
    "New Table Nos." code 10 with tablerelation to table "No. series" in setup table.

    Use "new table Nos." instead "customer Nos.". That's all if you have table with one field primary key.

    I have implemented everything as per the instructions . The number is getting incremented but it is not getting displayed in the field. Do u know wht is the issue?? Do I have to write any code in AssistEdit().
  • JedrzejTJedrzejT Member Posts: 267
    You can write some code in assist edit for choosing diffrent Nos. but this is not the reason you don't see number in field.
    You know the number is incremented but You dont see it? :-k
    You look at value of "No." field?
    Do you write code in table? or in form?
    I can help You if You Paste Your code and what is the primary key of your table.
  • vipinkuruvillavipinkuruvilla Member Posts: 143
    JedrzejT wrote:
    You can write some code in assist edit for choosing diffrent Nos. but this is not the reason you don't see number in field.
    You know the number is incremented but You dont see it? :-k
    You look at value of "No." field?
    Do you write code in table? or in form?
    I can help You if You Paste Your code and what is the primary key of your table.

    My Primary Key is No I have written my code in table. My code looks like below :

    OnInsert() :

    IF No = '' THEN BEGIN
    SalesSetup.GET;
    SalesSetup.TESTFIELD(TomNo);
    NoSeriesMgt.InitSeries(SalesSetup.TomNo,xRec."No.Series",0D,No,"No.Series");
    END;

    No - OnValidate() :

    IF No <> xRec.No THEN BEGIN
    TomSetup.GET;
    NoSeriesMgt.TestManual(TomSetup.TomNo);
    END;

    This is what I have written. "No.Series" have implemented as per your instructions. Iam not sure what I have to write it in AssistEdit(). TomNo is the name I have given in the Sales & Recievables Setup.

    AssistEdit():

    WITH RecHeader DO BEGIN
    COPY(Rec);
    SalesSetup.GET;

    IF NoSeriesMgt.SelectSeries(SalesSetup.TomNo,OldRecHeader.No,No) THEN BEGIN
    NoSeriesMgt.SetSeries(No);
    END;

    In the above code RecHeader is the record variable of my table where the number series should be implemented. To be frank OldRecHeader I just duplicated the same after going through sales Header number series code. Iam not sure about this.

    Also I have written the following code in my Header form :

    No - OnAssitEdit() :

    IF AssistEdit(xRec) THEN
    CurrForm.UPDATE;

    Hope you can rectify my mistakes. Thanks in advance......
    END;
  • JedrzejTJedrzejT Member Posts: 267
    Code with assist should be like:
    AssistEdit(OldRecHeader : Record YourTable) : Boolean
    WITH RecHeader DO BEGIN 
      COPY(Rec); 
      SalesSetup.GET
      IF NoSeriesMgt.SelectSeries(SalesSetup.TomNo,OldRecHeader.No,No)    
        THEN BEGIN 
        NoSeriesMgt.SetSeries(No);  
        Rec := Cust; 
        EXIT(TRUE);
      END;
    END;
    
    No - OnValidate() : 
    
    IF No <> xRec.No THEN BEGIN  
      TomSetup.GET; 
      NoSeriesMgt.TestManual(TomSetup.TomNo); 
      "No. Series" := '';
    END;
    

    Code in insert and validate is good. Should work.
  • vipinkuruvillavipinkuruvilla Member Posts: 143
    JedrzejT wrote:
    Code with assist should be like:
    AssistEdit(OldRecHeader : Record YourTable) : Boolean
    WITH RecHeader DO BEGIN 
      COPY(Rec); 
      SalesSetup.GET
      IF NoSeriesMgt.SelectSeries(SalesSetup.TomNo,OldRecHeader.No,No)    
        THEN BEGIN 
        NoSeriesMgt.SetSeries(No);  
        Rec := Cust; 
        EXIT(TRUE);
      END;
    END;
    
    No - OnValidate() : 
    
    IF No <> xRec.No THEN BEGIN  
      TomSetup.GET; 
      NoSeriesMgt.TestManual(TomSetup.TomNo); 
      "No. Series" := '';
    END;
    

    Code in insert and validate is good. Should work.

    Thanx a lot dude. Its working fine. Thanx again for your valuable time.
  • xina_manxina_man Member Posts: 116
    s
  • xina_manxina_man Member Posts: 116
    xina_man wrote:
    s

    Sorry about the previous post... posted it by mistake.
Sign In or Register to comment.