Skip to content

[Event Request] codeunit 99000808 "PlanningRoutingManagement" OnBeforeCalcSequenceFromActual #29636

@dmonteagudo-pwd

Description

@dmonteagudo-pwd

Why do you need this change?

The CalcSequenceFromActual procedure is called from Table 99000830 "Planning Routing Line" fields 70 and 72 OnValidate triggers with an uninitialized ReqLine parameter. This causes:

  1. Incorrect routing type passed to sequencing functions (uses default Serial=0 instead of actual value)
  2. Wrong operation scheduling in parallel routing scenarios
  3. No workaround available - cannot override table triggers in extensions

This bug affects manufacturing planning for companies using routing operations and is related to issues #29512 and #29607 (same root cause).

Why Request an Event (not just wait for bug fix)?

  1. Faster resolution
  2. Low risk: Adding event is non-breaking, requires minimal testing
  3. Partner enablement: Allows immediate workaround via subscriber
  4. Future-proof: Event remains useful for customizations even after bug fix

Describe the request

Add one Integration Event in Codeunit 99000808 PlanningRoutingManagement:

Event Location

At the beginning of procedure CalcSequenceFromActual (before first use of ReqLine parameter):

Current code (line ~238):

procedure CalcSequenceFromActual(PlanningRtngLine: Record "Planning Routing Line"; Direction: Option Forward,Backward; ReqLine: Record "Requisition Line")
var
    PlanningRtngLine2: Record "Planning Routing Line";
    MaxSeq: Integer;
begin
    if NeedsCalculation(
         ReqLine."Worksheet Template Name",
         ReqLine."Journal Batch Name",
         ReqLine."Line No.")
    then
        Calculate(ReqLine);
    
    // ... rest of code uses ReqLine."Routing Type"
end;

Requested change:

procedure CalcSequenceFromActual(PlanningRtngLine: Record "Planning Routing Line"; Direction: Option Forward,Backward; ReqLine: Record "Requisition Line")
var
    PlanningRtngLine2: Record "Planning Routing Line";
    MaxSeq: Integer;
begin
    OnBeforeCalcSequenceFromActual(PlanningRtngLine, Direction, ReqLine);  // ← NEW EVENT
    
    if NeedsCalculation(
         ReqLine."Worksheet Template Name",
         ReqLine."Journal Batch Name",
         ReqLine."Line No.")
    then
        Calculate(ReqLine);
    
    // ... rest of code
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeCalcSequenceFromActual(PlanningRtngLine: Record "Planning Routing Line"; Direction: Option Forward,Backward; var ReqLine: Record "Requisition Line")
begin
end;

Critical Requirement

The ReqLine parameter MUST be var to allow subscribers to initialize it.


Workaround Code

With this event, the workaround is straightforward:

[EventSubscriber(ObjectType::Codeunit, Codeunit::PlanningRoutingManagement, 'OnBeforeCalcSequenceFromActual', '', false, false)]
local procedure FixUninitializedReqLine(PlanningRtngLine: Record "Planning Routing Line"; Direction: Option; var ReqLine: Record "Requisition Line")
begin
    if ReqLine."Line No." = 0 then  // Detect uninitialized
        ReqLine.Get(PlanningRtngLine."Worksheet Template Name", PlanningRtngLine."Worksheet Batch Name", PlanningRtngLine."Worksheet Line No.");
end;

This mirrors the initialization pattern already present in CalculateRoutingFromActual (same codeunit, line ~516).


Additional Context

Objects affected:

  • Codeunit 99000808 "PlanningRoutingManagement" (event location)
  • Table 99000830 "Planning Routing Line" (caller with bug)

Related issues:

User scenario:
Manufacturing companies using Planning Worksheets with routing operations, particularly when Routing Type = Parallel.

BC Version tested: 27.3.44313.44463

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions