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 CanRegisterMultipleUoMForProdOutput(_LookupResponse.Get_Location(), _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 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)]
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 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)]
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;
/// 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>
local procedure 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();
if not Location.Get(_LocationCode) then
Clear(Location);
if not Item.Get(_ItemNo) then
exit(false); // 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;
Version History
Version | Changes |
---|---|
MOB5.40 | Introduced |
MOB5.43 | Refactored example to use new CanRegisterMultipleUoMForProdOutput() based on Adhoc.CanRegisterMultipleUoM() |