local procedure "Code"(var ReqLine: Record "Requisition Line")
var
ReqLine2: Record "Requisition Line";
ReqLine3: Record "Requisition Line";
NewReqWkshName: Boolean;
IsHandled: Boolean;
begin
OnBeforeCode(ReqLine, PlanningResiliency, SuppressCommit, PrintPurchOrders);
InitShipReceiveDetails();
Clear(PurchOrderHeader);
ReqLine.SetRange("Worksheet Template Name", ReqLine."Worksheet Template Name");
ReqLine.SetRange("Journal Batch Name", ReqLine."Journal Batch Name");
if not PlanningResiliency then
ReqLine.LockTable();
if ReqLine."Planning Line Origin" <> ReqLine."Planning Line Origin"::"Order Planning" then
GetReqTemplate(ReqLine, ReqTemplate);
if ReqTemplate.Recurring then begin
ReqLine.SetRange("Order Date", 0D, EndOrderDate);
ReqLine.SetFilter("Expiration Date", '%1 | %2..', 0D, WorkDate());
end;
if not ReqLine.Find('=><') then begin
ReqLine."Line No." := 0;
if not SuppressCommit then
Commit();
exit;
end;
OnCodeOnBeforeInitProgressWindow(ReqTemplate, HideProgressWindow);
if not HideProgressWindow then
InitProgressWindow();
if not HideProgressWindow then
Window.Update(1, ReqLine."Journal Batch Name");
// Check lines
CheckRequisitionLines(ReqLine);
// Create lines
LineCount := 0;
OrderCounter := 0;
OrderLineCounter := 0;
Clear(PurchOrderHeader);
//-------------------------------------------------------------------OnCodeOnBeforeSetPurchOrderHeader:BEGIN
IsHandled := false;
OnCodeOnBeforeSetPurchOrderHeader(Rec, IsHandled)
if not IsHandled then
//-------------------------------------------------------------------OnCodeOnBeforeSetPurchOrderHeader:END
SetPurchOrderHeader();
SetReqLineSortingKey(ReqLine);
ProcessReqLineActions(ReqLine);
IsHandled := false;
OnCodeOnBeforeFinalizeOrderHeader(PurchOrderHeader, ReqLine, IsHandled);
if not IsHandled then
if PurchOrderHeader."Buy-from Vendor No." <> '' then
FinalizeOrderHeader(PurchOrderHeader, ReqLine);
CheckRunPrintPurchOrders();
if PrevChangedDocOrderNo <> '' then
PrintChangedDocument(PrevChangedDocOrderType, PrevChangedDocOrderNo);
// Copy number of created orders and current journal batch name to requisition worksheet
ReqLine.Init();
ReqLine."Line No." := OrderCounter;
if OrderCounter <> 0 then
if not ReqTemplate.Recurring then begin
// Not a recurring journal
ReqLine2.Copy(ReqLine);
ReqLine2.SetFilter("Vendor No.", '<>%1', '');
if ReqLine2.FindFirst() then;
// Remember the last line
IsHandled := false;
OnBeforeDeleteReqLines(ReqLine, TempFailedReqLine, IsHandled, ReqLine2);
if not IsHandled then
if ReqLine.Find('-') then
repeat
TempFailedReqLine := ReqLine;
if not TempFailedReqLine.Find() then
ReqLine.Delete(true);
until ReqLine.Next() = 0;
ReqLine3.SetRange("Worksheet Template Name", ReqLine."Worksheet Template Name");
ReqLine3.SetRange("Journal Batch Name", ReqLine."Journal Batch Name");
OnCodeOnAfterReqLine3SetFilters(ReqLine, ReqLine3);
if ReqTemplate."Increment Batch Name" then
if not ReqLine3.FindLast() then
if IncStr(ReqLine."Journal Batch Name") <> '' then begin
ReqWkshName.Get(ReqLine."Worksheet Template Name", ReqLine."Journal Batch Name");
NewReqWkshName := true;
OnCheckNewNameNeccessary(ReqWkshName, NewReqWkshName);
if NewReqWkshName then begin
ReqWkshName.Delete();
ReqWkshName.Name := IncStr(ReqLine."Journal Batch Name");
if ReqWkshName.Insert() then;
ReqLine."Journal Batch Name" := ReqWkshName.Name;
end;
end;
end;
OnAfterCode(ReqLine, OrderLineCounter, OrderCounter, PrintPurchOrders, SuppressCommit, PurchOrderHeader);
end;
//-------------------------------------------------------------------OnCodeOnBeforeSetPurchOrderHeader:BEGIN
[IntegrationEvent(true, false)]
local procedure OnCodeOnBeforeSetPurchOrderHeader(var ReqLine: Record "Requisition Line", var IsHandled: Boolean)
begin
end;
//-------------------------------------------------------------------OnCodeOnBeforeSetPurchOrderHeader:END
Additional context
We have to set different PurchaseOrderHeader
Internal work item: AB#558153
Describe the request
Please add new event
Additional context
We have to set different PurchaseOrderHeader Internal work item: AB#558153