Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

    // Hide default UoM from helpLabel at Quantity step (if needed)
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnGetRegistrationConfigurationOnProdOutput_OnAfterAddStepToProductionOutputQuantity', '', true, true)]
    localprocedure MyOnGetRegistrationConfigurationOnProdOutput_OnAfterAddStepToProductionOutputQuantity(_RegistrationType: Text; var _LookupResponse: Record"MOB NS WhseInquery Element"; var _Step: Record"MOB Steps Element")
    begin
        if _Step.Get_name() = 'Quantity'then
            if CanRegisterMultipleUoMForProdOutput(_LookupResponse.Get_Location(), _LookupResponse.Get_ItemNumber()) then
                _Step.Set_helpLabel('');    // Clear default UoM from helpLabel as it may be changed in new step created from OnGetRegistrationConfigurationOnProdOutput_OnAddStepsToProductionOutputQuantity event
    end;

    // Hide default UoM from helpLabel at ScrapQuantity step (if needed)
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnGetRegistrationConfigurationOnProdOutput_OnAfterAddStepToProductionOutputScrap', '', true, true)]
    localprocedure MyOnGetRegistrationConfigurationOnProdOutput_OnAfterAddStepToProductionOutputScrap(_RegistrationType: Text; var _LookupResponse: Record"MOB NS WhseInquery Element"; var _Step: Record"MOB Steps Element")
    begin
        if _Step.Get_name() = 'ScrapQuantity'then
            if CanRegisterMultipleUoMForProdOutput(_LookupResponse.Get_Location(), _LookupResponse.Get_ItemNumber()) then
                _Step.Set_helpLabel('');    // Clear default UoM from helpLabel as it may be changed in new step created from OnGetRegistrationConfigurationOnProdOutput_OnAddStepsToProductionOutputQuantity event
    end;

    // Update Unit of Measure Code in Production Output Journal if a custom UoM step was collected
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnProdOutput_OnAfterCreateProductionJnlLine', '', true, true)]
    localprocedure MyOnPostAdhocRegistrationOnProdOutput_OnAfterCreateProductionJnlLine(var _RequestValues: Record"MOB NS Request Element"; var _ProductionJnlLine: Record"Item Journal Line")
    var
        MyUnitOfMeasureCode: Code[10];
    begin
        MyUnitOfMeasureCode := _RequestValues.GetValue('UoM', false);
        if MyUnitOfMeasureCode <> ''then
            _ProductionJnlLine.Validate("Unit of Measure Code", MyUnitOfMeasureCode);
    end;

    /// <summary>
    /// Determine if UoM can meaningfully be registered for Production Output. Requires multiple UoM's to exist for an Item and a Location setup that can post in different UoMs.
    /// Based on MobWmsAdhocRegistr.CanRegisterMultipleUoM() but also factoring in "SN Manuf. Inbound Tracking"
    /// </summary>
    localprocedure CanRegisterMultipleUoMForProdOutput(_LocationCode: Code[10]; _ItemNo: Code[20]): Boolean
    var
        MobSetup: Record"MOB Setup";
        Location: Record Location;
        ItemTrackingCode: Record"Item Tracking Code";
        Item: Record Item;
        MobWmsToolbox: Codeunit"MOB WMS Toolbox";
    begin
        MobSetup.Get();
        ifnot Location.Get(_LocationCode) then
            Clear(Location);
        ifnot Item.Get(_ItemNo) then
            Clearexit(Itemfalse);    // Can never register multiple UoM when Item do not exist

        if ItemTrackingCode.Get(Item."Item Tracking Code") and ItemTrackingCode."SN Manuf. Inbound Tracking"then
            exit(false);    // We collect only a single Serial No. from Mobile Device and cannot handle UoM other than base

        if MobWmsToolbox.GetItemHasMultipleUoM(_ItemNo) then
            if Location."Directed Put-away and Pick"then
                exit(true)
            else
                exit(not MobSetup."Use Base Unit of Measure");

        exit(false); // Only one UoM was setup at Item
    end;

...