microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
783 stars 620 forks source link

Event Request Report 790 "Calculate Inventory" like "OnAfterSetLineNo" #27044

Closed lbe-lw closed 2 months ago

lbe-lw commented 2 months ago

Describe the request

We need to manipulate the "NextLineNo" in "calculate inventory" report, because we reached the max integer value of the field "Line No." in Item Journal Line as we have too many inventorylines. It would also be possible to add the NextLineNo Variable to the existing event "OnInsertItemJnlLineOnAfterCalcShouldInsertItemJnlLine":

image

Right now we solved this problem as follows, which is obviously not ideal:

[EventSubscriber(ObjectType::Report, Report::"Calculate Inventory", OnInsertItemJnlLineOnBeforeValidateItemNo, '', false, false)]
?? ?? local procedure OnInsertItemJnlLineOnBeforeValidateItemNo_R790(var ItemJournalLine: Record "Item Journal Line")
?? ?? var
?? ?? ?? ?? ItemJournalLineCurr: Record "Item Journal Line";
?? ?? begin
?? ?? ?? ?? if ItemJournalLine."Line No." = -1147473000 then
?? ?? ?? ?? ?? ?? if ItemJournalLineCurr.Get(ItemJournalLine."Journal Template Name", ItemJournalLine."Journal Batch Name", -1147483000) then
?? ?? ?? ?? ?? ?? ?? ?? ItemJournalLineCurr.Delete();

?? ?? ?? ?? if ItemJournalLine."Line No." < 0 then
?? ?? ?? ?? ?? ?? ItemJournalLine."Line No." := ItemJournalLine."Line No." * -1;
?? ?? end;

?? ?? [EventSubscriber(ObjectType::Report, Report::"Calculate Inventory", OnBeforeFunctionInsertItemJnlLine, '', false, false)]
?? ?? local procedure OnBeforeFunctionInsertItemJnlLine_R790(ItemNo: Code[20]; VariantCode2: Code[10]; DimEntryNo2: Integer; BinCode2: Code[20]; Quantity2: Decimal; PhysInvQuantity: Decimal; var ItemJournalLine: Record "Item Journal Line"; var IsHandled: Boolean; Location: Record Location)
?? ?? var
?? ?? ?? ?? ItemJournalLineCurr: Record "Item Journal Line";
?? ?? ?? ?? ItemJournalLineCurr2: Record "Item Journal Line";
?? ?? begin
?? ?? ?? ?? ItemJournalLineCurr2.Reset();
?? ?? ?? ?? ItemJournalLineCurr2.SetRange("Journal Template Name", ItemJournalLine."Journal Template Name");
?? ?? ?? ?? ItemJournalLineCurr2.SetRange("Journal Batch Name", ItemJournalLine."Journal Batch Name");
?? ?? ?? ?? if ItemJournalLineCurr2.IsEmpty() then begin
?? ?? ?? ?? ?? ?? ItemJournalLineCurr.Init();
?? ?? ?? ?? ?? ?? ItemJournalLineCurr."Journal Template Name" := ItemJournalLine."Journal Template Name";
?? ?? ?? ?? ?? ?? ItemJournalLineCurr."Journal Batch Name" := ItemJournalLine."Journal Batch Name";
?? ?? ?? ?? ?? ?? //Start with ca. half max value of Integer because of step 4 in SA690 codeunit 80160 "LW Process SuP Message"
?? ?? ?? ?? ?? ?? ItemJournalLineCurr."Line No." := -1147483000;
?? ?? ?? ?? ?? ?? ItemJournalLineCurr.Insert();
?? ?? ?? ?? end;
?? ?? end;

Another solution would be to set the "Line No." as BigInt.

Kind regards, Leon Becker Technical Lead ERP Lampenwelt GmbH

Leon Becker Tech Lead Lampenwelt

Additional context

pleas see above. Internal work item: AB#544572

JesperSchulz commented 2 months ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 23210.