CurrForm.SETSELECTIONFILTER(lv_SalesHeader); IF lv_SalesHeader.FINDSET THEN BEGIN REPEAT /// Controleren of transport order reeds bestaat: lv_PurchHeader.RESET; lv_PurchHeader.SETRANGE(lv_PurchHeader."Linked Sales Order",lv_SalesHeader."No."); IF lv_PurchHeader.FINDFIRST THEN BEGIN MESSAGE(Text002,lv_PurchHeader."No.",lv_SalesHeader."No."); EXIT; END; lv_SalesHeader.TESTFIELD("Shipping Agent Code"); lv_ShippingAgent.GET("Shipping Agent Code"); lv_PurchHeader.INIT; lv_PurchHeader.VALIDATE("Document Type","Document Type"::Order); lv_PurchHeader.VALIDATE("No.",''); lv_PurchHeader.INSERT(TRUE); lv_PurchHeader.VALIDATE("Buy-from Vendor No.",lv_ShippingAgent."Vendor No."); lv_PurchHeader.VALIDATE("Transport Order",TRUE); lv_PurchHeader."Linked Sales Order" := lv_SalesHeader."No."; lv_PurchHeader.MODIFY(TRUE); COMMIT; lv_PurchLine.INIT; lv_PurchLine.VALIDATE("Document Type","Document Type"::Order); lv_PurchLine.VALIDATE("Document No.",lv_PurchHeader."No."); lv_PurchLine.VALIDATE("Line No.",10000); lv_PurchLine.INSERT(TRUE); lv_PurchLine.VALIDATE(Type,lv_PurchLine.Type::"Charge (Item)"); lv_PurchLine.VALIDATE("No.",'TRANSPORT'); lv_PurchLine.Quantity := 1; lv_PurchLine.MODIFY(TRUE); COMMIT; lv_SalesHeader."Linked Transport Order" := lv_PurchHeader."No."; lv_SalesHeader.MODIFY; // FORM.RUNMODAL(50,lv_PurchHeader); UNTIL lv_SalesHeader.NEXT = 0; END;
Answers
RIS Plus, LLC
insead of
use
So, the default No Series will be used, and this is what you want ;-)
Your mistake is, that you not use the "init" function and, that you validate the "No.".
To understand it, read the code in No. - OnValidate and in OnInsert of table 38
Regards