This article requires Mobile WMS extension version MOB5.40 (or newer)

Description

For Items with multiple Unit of Measure codes


When posting from the WebClient, the user may change the Unit of Measure Code for output lines in Production Output Journal.

This is currently not supported out-of-the-box in Mobile WMS, as customers may or may not prefer to allow posting output in UoM's other than the default UoM.

Example

    // Create new UoM-step if needed
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnGetRegistrationConfigurationOnProdOutput_OnAddStepsToProductionOutputQuantity', '', true, true)]
    local procedure MyOnGetRegistrationConfigurationOnProdOutput_OnAddStepsToProductionOutputQuantity(var _LookupResponse: Record "MOB NS WhseInquery Element"; var _Steps: Record "MOB Steps Element")
    begin
        if CanSelectUoM(_LookupResponse.Get_ItemNumber()) then begin
            // create new step id 79 = prior to existing quantity step
            _Steps.Create_ListStep_UoM(79, _LookupResponse.Get_ItemNumber());
            _Steps.Set_defaultValue(_LookupResponse.Get_UoM());
            _Steps.Set_optional(false);
        end;
    end;

    // Hide default UoM from helpLabel at Quantity step (if needed)
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnGetRegistrationConfigurationOnProdOutput_OnAfterAddStepToProductionOutputQuantity', '', true, true)]
    local procedure 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 CanSelectUoM(_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)]
    local procedure 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 CanSelectUoM(_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)]
    local procedure 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;

    // Condition for when to create/handle a custom UoM step
    local procedure CanSelectUoM(_ItemNo: Code[20]): Boolean
    var
        MobSetup: Record "MOB Setup";
        ItemTrackingCode: Record "Item Tracking Code";
        Item: Record Item;
        MobWMSToolbox: Codeunit "MOB WMS Toolbox";
    begin
        MobSetup.Get();
        if MobSetup."Use Base Unit of Measure" then
            exit(false);

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

        exit(false);
    end;

Version History

VersionChanges
MOB5.40Introduced