Skip to content

[Event Request] Codeunit 80 "Sales-Post" - Shipment and Order Numbers #29308

@krpr-navax

Description

@krpr-navax

Why do you need this change?

We would like to request new integration events in the Sales-Post codeunit, which checks for shipments and order numbers. As this check is executed for every line being posted, the overhead for bulk operations is incredibly high, even though the functionality is not in use by any of our customers. To improve performance during our bulk posting operations, the events will be subscribed using manual subscription to skip these costly executions for each line.

Describe the request

Object: codeunit 80 "Sales-Post"
Procedure: SetInvoiceOrderNo

Code:

#if NEWEVENTS
    [IntegrationEvent(false, false)]
    local procedure OnBeforeSetInvoiceOrderNo(SalesLine: Record "Sales Line"; var SalesInvLine: Record "Sales Invoice Line"; var IsHandled: Boolean)
    begin
    end;
#endif
    
    local procedure SetInvoiceOrderNo(SalesLine: Record "Sales Line"; var SalesInvLine: Record "Sales Invoice Line")
    var
        SalesShptLine: Record "Sales Shipment Line";
#if NEWEVENTS
        IsHandled: Boolean;
    begin
        OnBeforeSetInvoiceOrderNo(SalesLine, SalesInvLine, IsHandled);
        if IsHandled then
            exit;
#else
    begin
#endif

        if SalesLine."Document Type" = SalesLine."Document Type"::Order then begin
            SalesInvLine."Order No." := SalesLine."Document No.";
            SalesInvLine."Order Line No." := SalesLine."Line No.";
        end else
            if SalesShptLine.Get(SalesLine."Shipment No.", SalesLine."Shipment Line No.") then begin
                SalesInvLine."Order No." := SalesShptLine."Order No.";
                SalesInvLine."Order Line No." := SalesShptLine."Order Line No.";
            end;
    end;

Object: codeunit 80 "Sales-Post"
Procedure: PostUpdateOrderNo

Code:

#if NEWEVENTS
    [IntegrationEvent(false, false)]
    local procedure OnBeforePostUpdateOrderNo(var SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)
    begin
    end;
#endif

    local procedure PostUpdateOrderNo(var SalesInvoiceHeader: Record "Sales Invoice Header")
    var
        SalesInvoiceLine: Record "Sales Invoice Line";
#if NEWEVENTS
        IsHandled: Boolean;
    begin
        OnBeforePostUpdateOrderNo(SalesInvoiceHeader, IsHandled);
        if IsHandled then
            exit;
#endif
        if SalesInvoiceHeader."No." = '' then
            exit;
        
        ...
    end;

Internal work item: AB#610441

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an event

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions