Skip to content

[Request for External] report 5405 "Calc. Consumption" - protected variables, public procedure & use GuiAllowed #29123

@matthiasrabus

Description

@matthiasrabus

Why do you need this change?

We are converting one C/AL customer to the latest BC version. This customer has some changes to the standard report 5405 "Calc. Consumption" to allow it to run without UI and expose some functionality to other objects. To replicate the behavior, I would like to request the following changes

Describe the request

Please define these global variables as protected:
Item
ProdOrderLine
ItemJnlLine
NextConsumpJnlLineNo

    var
        LastItemJnlLine: Record "Item Journal Line";
        UOMMgt: Codeunit "Unit of Measure Management";
        Window: Dialog;
        PostingDate: Date;
        CalcBasedOn: Option "Actual Output","Expected Output";
        ToTemplateName: Code[10];
        ToBatchName: Code[10];

#pragma warning disable AA0074
        Text000: Label 'Calculating consumption...\\';
#pragma warning disable AA0470
        Text001: Label 'Prod. Order No.   #1##########\';
        Text002: Label 'Item No.          #2##########\';
        Text003: Label 'Quantity          #3##########';
#pragma warning restore AA0470
#pragma warning restore AA0074

    protected var
        LocationCode: Code[10];
        ReservedFromStock: Enum "Reservation From Stock";
        Item: Record Item;
        ProdOrderLine: Record "Prod. Order Line";
        ItemJnlLine: Record "Item Journal Line";
        NextConsumpJnlLineNo: Integer;

Please change the signature of the procedure CreateConsumpJnlLine to be public:

procedure CreateConsumpJnlLine(LocationCode: Code[10]; BinCode: Code[20]; OriginalQtyToPost: Decimal)

Please change the way how the dialog is shown, so that the report can be run without UI:

New global variable, plus setter and initialization:

var
    ShowDialog: Boolean; 

    procedure SetHideDialog(DoShowDialog: Boolean)
    begin
        ShowDialog := DoShowDialog;
    end;

    trigger OnInitReport()
    begin
        ShowDialog := true;
    end;

Change the following code segments:

Before:

    local procedure CreateConsumpJnlLine(LocationCode: Code[10]; BinCode: Code[20]; OriginalQtyToPost: Decimal)
    var
        Location: Record Location;
#if not CLEAN26
        ManufacturingSetup: Record Microsoft.Manufacturing.Setup."Manufacturing Setup";
#endif
        QtyToPost: Decimal;
        ShouldModifyItemJnlLine: Boolean;
        ShouldAdjustQty: Boolean;
    begin
        QtyToPost := OriginalQtyToPost;
        OnBeforeCreateConsumpJnlLine(LocationCode, BinCode, QtyToPost);

        Window.Update(3, QtyToPost);

#if not CLEAN26
.....

New:

    local procedure CreateConsumpJnlLine(LocationCode: Code[10]; BinCode: Code[20]; OriginalQtyToPost: Decimal)
    var
        Location: Record Location;
#if not CLEAN26
        ManufacturingSetup: Record Microsoft.Manufacturing.Setup."Manufacturing Setup";
#endif
        QtyToPost: Decimal;
        ShouldModifyItemJnlLine: Boolean;
        ShouldAdjustQty: Boolean;
    begin
        QtyToPost := OriginalQtyToPost;
        OnBeforeCreateConsumpJnlLine(LocationCode, BinCode, QtyToPost);

//CHANGED
     if  ShowDialog  then
        Window.Update(3, QtyToPost);
//CHANGED 

#if not CLEAN26
.....

Before:

            dataitem("Prod. Order Component"; "Prod. Order Component")
            {
                DataItemLink = Status = field(Status), "Prod. Order No." = field("No.");
                RequestFilterFields = "Item No.";

                trigger OnAfterGetRecord()
                var
                    NeededQty: Decimal;
                    IsHandled: Boolean;
                begin
                    Window.Update(2, "Item No.");

New:

            dataitem("Prod. Order Component"; "Prod. Order Component")
            {
                DataItemLink = Status = field(Status), "Prod. Order No." = field("No.");
                RequestFilterFields = "Item No.";

                trigger OnAfterGetRecord()
                var
                    NeededQty: Decimal;
                    IsHandled: Boolean;
                begin
                  //CHANGED
                 if  ShowDialog  then
                    Window.Update(2, "Item No.");
                  //CHANGED

Before:

            trigger OnAfterGetRecord()
            begin
                Window.Update(1, "No.");
            end;

            trigger OnPreDataItem()
            begin
                ItemJnlLine.SetRange("Journal Template Name", ToTemplateName);
                ItemJnlLine.SetRange("Journal Batch Name", ToBatchName);
                if ItemJnlLine.FindLast() then
                    NextConsumpJnlLineNo := ItemJnlLine."Line No." + 10000
                else
                    NextConsumpJnlLineNo := 10000;

                Window.Open(
                  Text000 +
                  Text001 +
                  Text002 +
                  Text003);
            end;

New:

            trigger OnAfterGetRecord()
            begin
               //CHANGED
               if  ShowDialog  then
               //CHANGED
                   Window.Update(1, "No.");
            end;

            trigger OnPreDataItem()
            begin
                ItemJnlLine.SetRange("Journal Template Name", ToTemplateName);
                ItemJnlLine.SetRange("Journal Batch Name", ToBatchName);
                if ItemJnlLine.FindLast() then
                    NextConsumpJnlLineNo := ItemJnlLine."Line No." + 10000
                else
                    NextConsumpJnlLineNo := 10000;
                    //CHANGED
                     if  ShowDialog  then
                    //CHANGED
                Window.Open(
                  Text000 +
                  Text001 +
                  Text002 +
                  Text003);
            end;

Internal work item: AB#599357

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM arearequest-for-externalRequest for exposing a function for extension developmentships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions