How-to: Assign Lot No. from Number Series during Production Output posting

Suggest a new LotNumber from associated "Lot No.s" number series for output item. 

Description

See Production Consumption & Output

When an output item is setup for production output lot numbers there will generally be two ways to have the lot number assigned during posting:

  • Print labels for the production output item including new lot numbers pulled from the Number Series. Scan these labels during Production Output on the mobile device to populate the Lot Number step.  Such "lot labels" is currently not included in standard Mobile WMS and may need to be a new customizaton as well.
  • Suggest Lot Numbers from a number series as defaultvalue for the Lot Number step during Production Output on the mobile device. No label including the lot number is applied to the output items.

An example of the latter approach is below.


Note: Currently no event is available in Mobile WMS to edit standard Mobile WMS production output steps.  A not-so-pretty workaround in the example is reusing an event intended for creating new steps. New evenrts to update standard production output steps will be included in an upcoming version of Mobile WMS.


Example

Using OnGetRegistrationConfigurationOnProdOutput_OnAddStepsToProductionOutputQuantity


    // [Example]  Assign LotNumber from Number Series on production output posting
    // Workaround: Currently no event is available to edit standard Mobile WMS production output steps -> reusing an event intended for creating new steps
    [EventSubscriber(ObjectType::CodeunitCodeunit::"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")
    var
        Item: Record Item;
        ItemTrackingCode: Record "Item Tracking Code";
        NoSeries: Codeunit "MOB No. Series"; // Replace this with "No. Series" if BC24+ or "NoSeriesManagement" if BC23-
        NextLotNumber: Code[50];
    begin
        if not Item.Get(_LookupResponse.Get_ItemNumber()) then
            exit;


        if (Item."Item Tracking Code" = '') or (Item."Lot Nos." = ''then
            exit;

        if not ItemTrackingCode.Get(Item."Item Tracking Code"then
            exit;

        if not ItemTrackingCode."Lot Manuf. Outbound Tracking" then
            exit;

        NextLotNumber := NoSeries.GetNextNo(Item."Lot Nos.", WorkDate(), true);

        // Since this is really an event to add new steps for another step, save that step before switching to the one we want to update
        _Steps.Save();

        _Steps.SetRange(name, 'LotNumber');
        _Steps.FindFirst();
        _Steps.SetMustCallCreateNext(false);
        _Steps.Set_defaultValue(NextLotNumber)// Assign from number series here
        _Steps.Save();
        _Steps.SetRange(name);
    end;