Options

How can I view a No. Series on Report 206?

demi222demi222 Member Posts: 131
I have added a new section to Report 206, Sales Invoice Header,Header.

In this header I added a text box... I want to be able to view the
"No. Series Line"."Last No. Used" + 1.

so what I have done:

Global Variables:
NoSeriesLine of type record to the No. Series Line table
NewString of type Code

In the Sales Invoice Header, Header OnPreSection I have written:
NoSeriesLine.GET("Sales Invoice Header"."No. Series");

In the Sales Invoice Header, OnAfterGetRecord I have written:
NewString := INCSTR(NoSeriesLine."Last No. Used");

I added a text box with sourceExpr of NewString.

I get a message:
The No. Series Line does not exist
Identification fields + values:
Series Code := 'S-INV+'
Line No. = '0'

what am I missing?

Comments

  • Options
    Dean_AxonDean_Axon Member Posts: 193
    Hi Demi,

    your GET statement is incorrect.

    the primary key for the "no. Series Line" table is
    Series Code,Line No.
    

    In this table you can setup multiple No.s for the same "No. Series" so you have to identify which one you wish to use.

    As This is not held on the "Sales Header" so you will have to make some kind of rule to specify which you require.
    i.e. ALWAYS use the last no. series line in which case you could then use
    FIND('+');
    :D:D
    Remember: Keep it simple
  • Options
    demi222demi222 Member Posts: 131
    ok, I'm a little confused.

    I go to Sales and receivables...Invoices and click on the Posting No. Series. The Last No. Used is the one I want +1.

    If I do:
    IF NoSeriesLine.FIND('+') THEN
    NewString := INCSTR(NoSeriesLine."Last No. Used");
    the same message comes up.

    I don't know where to even find where Line No. is...

    any suggestions?
  • Options
    ArhontisArhontis Member Posts: 667
    You get the error cause you have a get and a find function working together...

    As "Dean Axon" mentrioned, if you look into the No. Series Line table, the key is "Series Code,Line No." so you either SETRANGE to one of them and perform a find to get ther coresponding records, or you perform a GET with all the key fields provided to the function. Meaning:
    NoSeriesLine.SETRANGE("Series Code","Sales Invoice Header"."No. Series"); 
    NoSeriesLine.FIND('+');
    NewString := INCSTR(NoSeriesLine."Last No. Used"); 
    
    -or-
    NoSeriesLine.GET("Sales Invoice Header"."No. Series",10000); 
    NewString := INCSTR(NoSeriesLine."Last No. Used"); 
    
    :whistle:
  • Options
    demi222demi222 Member Posts: 131
    ok, an error doesn't show now...

    However, it doesn't show the last no used... in fact, nothing shows up.

    thanks for trying
  • Options
    ArhontisArhontis Member Posts: 667
    Sourceexpr in your textbox?

    Why do you enable the debugger and place a break point to your code and see where it goes, or do a:
      MESSAGE(NoSeriesLine."Last No. Used"); 
      MESSAGE(NewString);
    
    after your code to see the calculated values.
    :roll:
  • Options
    demi222demi222 Member Posts: 131
    I tried both codes..

    the first one:

    NoSeriesLine.SETRANGE("Series Code","Sales Header"."No. Series");
    NoSeriesLine.FIND('+');
    NewString := INCSTR(NoSeriesLine."Last No. Used");

    This takes the last record from the No. Series Line table and adds 1 to it. However, it is not choosing the correct record. It needs to match with the Posting No. Series chosen.

    The second one:
    NoSeriesLine.GET("Sales Invoice Header"."No. Series",10000);
    NewString := INCSTR(NoSeriesLine."Last No. Used");

    Nothing shows up here.

    I will try the messages that you told me.

    I appreciate all your help... I have spent all day trying to do this... and It won't get done.. :(
  • Options
    ArhontisArhontis Member Posts: 667
    Use the Posting No. Series field of "Sales Header":

    NoSeriesLine.SETRANGE("Series Code","Sales Header"."Posting No. Series");
    NoSeriesLine.FIND('+');
    NewString := INCSTR(NoSeriesLine."Last No. Used");
  • Options
    demi222demi222 Member Posts: 131
    I tried it and it didn't work, it still takes the very last record from the
    No. Series Line table... still not the correct record.

    Any other suggestions?
  • Options
    Dean_AxonDean_Axon Member Posts: 193
    Hi Demi,
    the code that Arhontis gave you should work fine :?:

    I tested this :
    NoSeriesLine.Setrange("Series Code","Sales Invoice Header"."No. Series");
    Message(Format(NoSeriesLine.Count));//Just for checking purposes
    Message("Sales Invoice Header"."No. Series");
    NoSeriesLine.Find('+');
    NewString:=IncStr(NoSeriesLine."Last No. Used");
    Message(NewString);
    

    I suppose the next question is "What trigger are you placing this code in ?"

    Regards,

    Dean
    Remember: Keep it simple
  • Options
    ArhontisArhontis Member Posts: 667
    Exact code if I may say, "Dean Axon", but in demi222's case the report is looking at the sales header and all he wants is to get the propable next number that the sales document will get (Posting No. Series) IF it will be posted. Its a wrong approach if you ask me, since there is uncertainty of the produced INCSTR number, but since the customer wants it and the project manager says ok, somebody has to do it...

    Let me remind to demi that the numbers in No. Series Line table get increased by the "increment-by No." field that might be different from 1 in the INCSTR case. So he could do "increment-by No." times the INCSTR of the NewString to get a more proper number.

    So, the code sould look a bit more like:
    NoSeriesLine.Setrange("Series Code","Sales Header"."Posting No. Series"); 
    Message(Format(NoSeriesLine.Count));//Just for checking purposes 
    Message("Sales Header"."No. Series"); 
    NoSeriesLine.Find('+'); 
    NewString:=NoSeriesLine."Last No. Used";
    FOR i:=1 to NoSeriesLine."Increment-by No." Do
      NewString:=IncStr(NewString); 
    Message(NewString);
    

    First of all I would never predict a posting number on a pre-posted document, I guess everybody agrees to that, since there is not number reservations [-o< .

    BTW thanks for the assistance Dean.
  • Options
    demi222demi222 Member Posts: 131
    Thank you BOTH so much for your help!!
    It works just fine...
    :o
  • Options
    fbfb Member Posts: 246
    Or, you could do this, and avoid a number of other problems, including NoSeriesLines that haven't been used yet ("Last No. Used" is blank), choosing the correct NoSeriesLine based on date, etc, etc:
    NxtNumber := 
        NoSeriesMgt.TryGetNextNo("Sales Header"."Posting No. Series",0D);
    
Sign In or Register to comment.