How to get latest sales order no

teckpohteckpoh Member Posts: 271
Dear experts,

Am creating sales invoice automatically by using code. In order to create the new sales order by using code i need get and assign the latest sales order no before insert the data to sales header. Anybody know what's the code for it? Thanks in adv.

Comments

  • jannestigjannestig Member Posts: 1,000
    Look at the no series code unit 396 and table 308 309

    For sales orders it is table 36 Sales header with the code


    CASE "Document Type" OF
    "Document Type"::Quote,"Document Type"::Order:
    BEGIN
    NoSeriesMgt.SetDefaultSeries("Posting No. Series",SalesSetup."Posted Invoice Nos.");
    NoSeriesMgt.SetDefaultSeries("Shipping No. Series",SalesSetup."Posted Shipment Nos.");
    IF "Document Type" = "Document Type"::Order THEN BEGIN
    NoSeriesMgt.SetDefaultSeries("Prepayment No. Series",SalesSetup."Posted Prepmt. Inv. Nos.");
    NoSeriesMgt.SetDefaultSeries("Prepmt. Cr. Memo No. Series",SalesSetup."Posted Prepmt. Cr. Memo Nos.");
    END;
    END;
Sign In or Register to comment.