Why do you need this change?
Hi,
i ask to remove the ItemApplicationEntry.SetBaseLoadFields(); in the procedure "UnApplyDropShipment" (added in BC 28) in the codeunit 5815 "Undo Sales Shipment Line", because it causes a JIT error.
`
local procedure UnApplyDropShipment(ItemLedgerEntry: Record "Item Ledger Entry"; NewSalesShptLine: Record "Sales Shipment Line"; SalesShptLine: Record "Sales Shipment Line")
var
ItemApplicationEntry: Record "Item Application Entry";
RelevantUndoShipmentLedgerEntryNo: Integer;
begin
RelevantUndoShipmentLedgerEntryNo := FindRelevantNewSalesShptLedgerEntryNo(SalesShptLine, NewSalesShptLine, ItemLedgerEntry);
ItemApplicationEntry.SetBaseLoadFields(); <---------- Remove
ItemApplicationEntry.SetRange("Item Ledger Entry No.", ItemLedgerEntry."Entry No.");
ItemApplicationEntry.SetRange("Cost Application", true);
ItemApplicationEntry.SetRange("Inbound Item Entry No.", ItemLedgerEntry."Applies-to Entry");
ItemApplicationEntry.SetRange("Outbound Item Entry No.", ItemLedgerEntry."Entry No.");
ItemApplicationEntry.FindFirst();
ItemJnlPostLine.UnApplyDropShipment(ItemApplicationEntry, RelevantUndoShipmentLedgerEntryNo);
end;
`
The stack of the error is
"Item Jnl.-Post Line"(CodeUnit 22).UnApplyDropShipment line 60 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).UnApplyDropShipment line 14 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).RemoveDropShipmentApplicationWithPurchase line 19 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).InsertNewShipmentLine line 20 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).Code line 55 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).OnRun(Trigger) line 17 - Base Application by Microsoft version 28.0.46665.48549
"Posted Sales Shpt. Subform"(Page 131).UndoShipmentPosting line 9 - Base Application by Microsoft version 28.0.46665.48549
"Posted Sales Shpt. Subform"(Page 131)."UndoShipment - OnAction"(Trigger) line 2 - Base Application by Microsoft version 28.0.46665.48549
The JIT error is raised because in our app we use the event OnInsertApplEntryOnBeforeModify, raised in the procedure "InsertApplEntry" in the codeunit 22 "Item Jnl.-Post Line", to modify a custom field on the record ItemApplnEntry passed by var.
The Record ItemApplnEntry of the event is the same record "ItemApplicationEntry" found in the procedure UnApplyDropShipment and this causes the JIT error when the standard later calls Delete() of the record.
`
procedure InsertApplEntry(ItemLedgEntryNo: Integer; InboundItemEntry: Integer; OutboundItemEntry: Integer; TransferedFromEntryNo: Integer; PostingDate: Date; Quantity: Decimal; CostToApply: Boolean)
var
ApplItemLedgEntry: Record "Item Ledger Entry";
OldItemApplnEntry: Record "Item Application Entry";
ItemApplHistoryEntry: Record "Item Application Entry History";
ItemApplnEntryExists: Boolean;
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeInsertApplEntry(
ItemLedgEntryNo, InboundItemEntry, OutboundItemEntry, TransferedFromEntryNo, PostingDate, Quantity, CostToApply, IsHandled);
if IsHandled then
exit;
if Item.IsNonInventoriableType() then
exit;
if (ItemApplnEntryNo = 0) and InvtSetup.UseLegacyPosting() then begin
ItemApplnEntry.Reset();
ItemApplnEntry.LockTable();
ItemApplnEntryNo := ItemApplnEntry.GetLastEntryNo();
if ItemApplnEntryNo > 0 then begin
ItemApplHistoryEntry.Reset();
ItemApplHistoryEntry.LockTable();
ItemApplHistoryEntry.SetCurrentKey("Entry No.");
if ItemApplHistoryEntry.FindLast() then
if ItemApplHistoryEntry."Entry No." > ItemApplnEntryNo then
ItemApplnEntryNo := ItemApplHistoryEntry."Entry No.";
end else
ItemApplnEntryNo := 0;
end;
if Quantity < 0 then begin
OldItemApplnEntry.SetCurrentKey("Inbound Item Entry No.", "Item Ledger Entry No.", "Outbound Item Entry No.");
OldItemApplnEntry.SetRange("Inbound Item Entry No.", InboundItemEntry);
OldItemApplnEntry.SetRange("Item Ledger Entry No.", ItemLedgEntryNo);
OldItemApplnEntry.SetRange("Outbound Item Entry No.", OutboundItemEntry);
if OldItemApplnEntry.FindFirst() then begin
ItemApplnEntry := OldItemApplnEntry;
ItemApplnEntry.Quantity := ItemApplnEntry.Quantity + Quantity;
ItemApplnEntry."Last Modified Date" := CurrentDateTime;
ItemApplnEntry."Last Modified By User" := UserId;
OnInsertApplEntryOnBeforeModify(ItemApplnEntry);
ItemApplnEntry.Modify();
ItemApplnEntryExists := true;
end;
end;
...........
end;
`
`
[IntegrationEvent(false, false)]
local procedure OnInsertApplEntryOnBeforeModify(var ItemApplicationEntry: Record "Item Application Entry")
begin
end;
`
Describe the request
Remove the ItemApplicationEntry.SetBaseLoadFields(); in the procedure "UnApplyDropShipment" in the codeunit 5815 "Undo Sales Shipment Line".
`
local procedure UnApplyDropShipment(ItemLedgerEntry: Record "Item Ledger Entry"; NewSalesShptLine: Record "Sales Shipment Line"; SalesShptLine: Record "Sales Shipment Line")
var
ItemApplicationEntry: Record "Item Application Entry";
RelevantUndoShipmentLedgerEntryNo: Integer;
begin
RelevantUndoShipmentLedgerEntryNo := FindRelevantNewSalesShptLedgerEntryNo(SalesShptLine, NewSalesShptLine, ItemLedgerEntry);
ItemApplicationEntry.SetBaseLoadFields(); <---------- Remove
ItemApplicationEntry.SetRange("Item Ledger Entry No.", ItemLedgerEntry."Entry No.");
ItemApplicationEntry.SetRange("Cost Application", true);
ItemApplicationEntry.SetRange("Inbound Item Entry No.", ItemLedgerEntry."Applies-to Entry");
ItemApplicationEntry.SetRange("Outbound Item Entry No.", ItemLedgerEntry."Entry No.");
ItemApplicationEntry.FindFirst();
ItemJnlPostLine.UnApplyDropShipment(ItemApplicationEntry, RelevantUndoShipmentLedgerEntryNo);
end;
`
Internal work item: AB#630549
Why do you need this change?
Hi,
i ask to remove the ItemApplicationEntry.SetBaseLoadFields(); in the procedure "UnApplyDropShipment" (added in BC 28) in the codeunit 5815 "Undo Sales Shipment Line", because it causes a JIT error.
`
`
The stack of the error is
"Item Jnl.-Post Line"(CodeUnit 22).UnApplyDropShipment line 60 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).UnApplyDropShipment line 14 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).RemoveDropShipmentApplicationWithPurchase line 19 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).InsertNewShipmentLine line 20 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).Code line 55 - Base Application by Microsoft version 28.0.46665.48549
"Undo Sales Shipment Line"(CodeUnit 5815).OnRun(Trigger) line 17 - Base Application by Microsoft version 28.0.46665.48549
"Posted Sales Shpt. Subform"(Page 131).UndoShipmentPosting line 9 - Base Application by Microsoft version 28.0.46665.48549
"Posted Sales Shpt. Subform"(Page 131)."UndoShipment - OnAction"(Trigger) line 2 - Base Application by Microsoft version 28.0.46665.48549
The JIT error is raised because in our app we use the event OnInsertApplEntryOnBeforeModify, raised in the procedure "InsertApplEntry" in the codeunit 22 "Item Jnl.-Post Line", to modify a custom field on the record ItemApplnEntry passed by var.
The Record ItemApplnEntry of the event is the same record "ItemApplicationEntry" found in the procedure UnApplyDropShipment and this causes the JIT error when the standard later calls Delete() of the record.
`
`
`
`
Describe the request
Remove the ItemApplicationEntry.SetBaseLoadFields(); in the procedure "UnApplyDropShipment" in the codeunit 5815 "Undo Sales Shipment Line".
`
`
Internal work item: AB#630549