ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 7312 "Create Pick".CreateTempLine

Open MiRo65 opened this issue 6 years ago • 5 comments

Could we please have an Event including eventhandler in Codeunit 7312 in function CreateTempLine?

Code example:

begin
    TotalQtyPickedBase := 0;
    GetLocation(LocationCode);
    // start kvspsa - Event Raiser
    SkipReservation := false;
    isHandled := false;
    **OnBeforeCreateTempLineCheckReservation(SourceType, SourceNo, SourceLineNo, QtyBaseMaxAvailToPick, SkipReservation, isHandled);**
    if not IsHandled or not SkipReservation then begin
        // stop kvspsa
        if Location."Directed Put-away and Pick" then
            QtyBaseMaxAvailToPick := // Total qty (excl. Receive bin content) that are not assigned to any activity/ order
              CalcTotalQtyOnBinType('', LocationCode, ItemNo, VariantCode) -
              CalcTotalQtyAssgndOnWhse(LocationCode, ItemNo, VariantCode) +
              CalcTotalQtyAssgndOnWhseAct(TempWhseActivLine."Activity Type"::"Put-away", LocationCode, ItemNo, VariantCode) -
              CalcTotalQtyOnBinType(GetBinTypeFilter(0), LocationCode, ItemNo, VariantCode) // Receive area
        else
            QtyBaseMaxAvailToPick :=
              CalcAvailableQty(ItemNo, VariantCode) -
              CalcPickQtyAssigned(LocationCode, ItemNo, VariantCode, UnitofMeasureCode, FromBinCode, TempWhseItemTrackingLine);

        CheckReservation(
          QtyBaseMaxAvailToPick, SourceType, SourceSubType, SourceNo, SourceLineNo, SourceSubLineNo, Location."Always Create Pick Line",
          QtyPerUnitofMeasure, TotalQtytoPick, TotalQtytoPickBase);
        // start kvspsa - Code Modification
    end;
    // stop kvspsa

Thank you

MiRo65 avatar Jan 09 '20 14:01 MiRo65

Why do you need parameter SkipReservation? Can we use IsHandled only?

AlexanderYakunin avatar Jan 28 '20 13:01 AlexanderYakunin

Yep. IsHandled should be enought if your implementation follows our example. The skipreservation was a leftover from our upgrade. sorry.

Fixed Code Example (Create Pick.Codeunit.al):

   procedure CreateTempLine(LocationCode: Code[10]; ItemNo: Code[20]; VariantCode: Code[10]; UnitofMeasureCode: Code[10]; FromBinCode: Code[20]; ToBinCode: Code[20]; QtyPerUnitofMeasure: Decimal; var TotalQtytoPick: Decimal; var TotalQtytoPickBase: Decimal)
   var
[...]
       // start kvspsa - Variables added
       isHandled: Boolean;
       // stop kvspsa
   begin
       TotalQtyPickedBase := 0;
       GetLocation(LocationCode);
       // start kvspsa - Event Raiser
       isHandled := false;
       OnBeforeCreateTempLineCheckReservation(SourceType, SourceNo, SourceLineNo, QtyBaseMaxAvailToPick, isHandled);
       if not IsHandled then begin
       // stop kvspsa
           if Location."Directed Put-away and Pick" then
               QtyBaseMaxAvailToPick := // Total qty (excl. Receive bin content) that are not assigned to any activity/ order
                 CalcTotalQtyOnBinType('', LocationCode, ItemNo, VariantCode) -
                 CalcTotalQtyAssgndOnWhse(LocationCode, ItemNo, VariantCode) +
                 CalcTotalQtyAssgndOnWhseAct(TempWhseActivLine."Activity Type"::"Put-away", LocationCode, ItemNo, VariantCode) -
                 CalcTotalQtyOnBinType(GetBinTypeFilter(0), LocationCode, ItemNo, VariantCode) // Receive area
           else
               QtyBaseMaxAvailToPick :=
                 CalcAvailableQty(ItemNo, VariantCode) -
                 CalcPickQtyAssigned(LocationCode, ItemNo, VariantCode, UnitofMeasureCode, FromBinCode, TempWhseItemTrackingLine);

           CheckReservation(
             QtyBaseMaxAvailToPick, SourceType, SourceSubType, SourceNo, SourceLineNo, SourceSubLineNo, Location."Always Create Pick Line",
             QtyPerUnitofMeasure, TotalQtytoPick, TotalQtytoPickBase);
       // start kvspsa - Code Modification
       end;
       // stop kvspsa

[...]

   // start kvspsa - Event Publisher
   [IntegrationEvent(false, false)]
   local procedure OnBeforeCreateTempLineCheckReservation(SourceType: Integer; SourceNo: Code[20]; SourceLineNo: Integer; var QtyBaseMaxAvailToPick: Decimal;  var isHandled: Boolean);
   begin
   end;
   // stop kvspsa

ChrisBlankDe avatar Jan 30 '20 13:01 ChrisBlankDe

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. We will update this issue with information about availability.

bc-ghost avatar Feb 04 '20 06:02 bc-ghost

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. We will update this issue with information about availability.

bc-ghost avatar Feb 19 '20 11:02 bc-ghost

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. We will update this issue with information about availability.

bc-ghost avatar Feb 19 '20 12:02 bc-ghost