AL icon indicating copy to clipboard operation
AL copied to clipboard

[Event Request] Codeunit 99000792 Create Prod. Order from Sale, CreateProdOrder

Open sirhc101 opened this issue 8 years ago • 0 comments

Please add the following events to codeunit object 99000792 Create Prod. Order from Sale function CreateProdOrder(). This would be very useful to hook into production order creation from sales, e.g for add additional information which are important for prod.-order line creation.

There should be an OnBefore[...] and OnAfter[...] Publisher and a useful signature would be SalesLine : Record "Sales Line", ProdOrder : Record "Production Order".

CreateProdOrder(SalesLine : Record "Sales Line";ProdOrderStatus : 'Simulated,Planned,Firm Planned,Released,Finished';OrderType : 'ItemOrder,ProjectOrder')
ProdOrder.INIT;
ProdOrder.Status := ProdOrderStatus;
ProdOrder."No." := '';
ProdOrder.INSERT(TRUE);

[...]

  ProdOrder.VALIDATE("Source No.",SalesLine."No.");
  ProdOrder.VALIDATE(Description,SalesLine.Description);
  SalesLine.CALCFIELDS("Reserved Qty. (Base)");
  ProdOrder.Quantity := SalesLine."Outstanding Qty. (Base)" - SalesLine."Reserved Qty. (Base)";
END;
ProdOrder.MODIFY;

// ---New Code Begin---
OnBeforeCreateProdOrderLines(ProdOrder, SalesLine);
// ---New Code End---

ProdOrder.SETRANGE("No.",ProdOrder."No.");
CreateProdOrderLines.SetSalesLine(SalesLine);
CreateProdOrderLines.Copy(ProdOrder,1,SalesLine."Variant Code",TRUE);

IF ProdOrder."Source Type" = ProdOrder."Source Type"::Item THEN BEGIN
  ProdOrderLine.SETRANGE(Status,ProdOrder.Status);

[...]

END;
IF ProdOrder.Status = ProdOrder.Status::Released THEN
  ProdOrderStatusMgt.FlushProdOrder(ProdOrder,ProdOrder.Status,WORKDATE);

// ---New Code Begin---
OnAfterCreateProdOrderLines(ProdOrder, SalesLine);
// ---New Code End---

LOCAL [IntegrationEvent] OnBeforeCreateProdOrderLines(VAR ProdOrder : Record "Production Order";VAR SalesLine : Record "Sales Line")

LOCAL [IntegrationEvent] OnAfterCreateProdOrderLines(VAR ProdOrder : Record "Production Order";VAR SalesLine : Record "Sales Line")

Thank you.

sirhc101 avatar Jun 06 '18 11:06 sirhc101