How-to: Change Registrations Before Posting
Description
Fix registrations received from the mobile device before processing themThe posting of a planned order (pick/receive/count etc.) goes through the following stages:
- Extract the order line registrations sent in by the mobile device and store them in the "MOB WMS Registration" table
- Loop through the registrations and update the related order lines
- Call the standard posting-codeunit
In some cases, we can implement customizations to the data collection process on the mobile device and still reuse the standard code that processes the registrations.
The trick is to modify registrations before the code that processes the registrations is executed.
This can be done in OnBefore-events like OnPostPickOrder_OnBeforePostWarehouseActivityOrder
Use case
In the picking scenario, the user typically scans both the Bin and Item barcodes. This is to validate that he is picking the right item from the right bin.
Scanning the bin also gives the user flexibility to pick from another bin if the item cannot be found in the expected bin.
In a scenario where the item to pick uses serial numbers, the bin code scan loses its value because the serial number can only be in one bin.
As long as the user scans the serial number we are 100% sure that the right item is picked. In this scenario, we can turn off bin validation to speed up the process.
So far so good. But what if the user scans a serial number that is in another bin than the expected bin?
Since the step to validate/change bin is removed, the order will fail in posting because the serial number is not available in the expected bin.
This problem can be solved by modifying the "From Bin" in the MOB WMS Registration -record.
The MOB WMS Registration tells which Serial Number is picked. This allows us to determine which bin it is in and update the "From Bin".
This way we can allow the user to just scan the serial numbers and handle the "From Bins" in the background.
Technical Background Details
Every time mobile sends a request to BC it is stored in the "Mobile Document Queue" and each request has a unique "Message ID".
The "Message ID" for a posting request is registered on the related document in the "MOB Posting MessageId" field.
The registrations in the MOB WMS Registration table are also "stamped" with this message id and this can be used to find all registrations related to a specific posting transaction.
If an order is partially posted multiple times, each posting will have a unique message id and the MOB WMS Registrations will reflect that.
How to enable it
To "fix" the raw registrations received from the mobile, you can subscribe to xxx_OnBeforePostYYY -events.
Example
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Pick", 'OnPostPickOrder_OnBeforePostWarehouseActivityOrder', '', true, true)]
procedure OnPostPickOrder_OnBeforePostWarehouseActivityOrder(var _OrderValues: Record "MOB Common Element"; var _WhseActivityHeader: Record "Warehouse Activity Header")
var
MobWmsRegistration: Record "MOB WMS Registration";
begin
// Find the registrations related to this posting operation
MobWmsRegistration.SetCurrentKey("Posting MessageId");
MobWmsRegistration.SetRange("Posting MessageId", _WhseActivityHeader."MOB Posting MessageId");
if MobWmsRegistration.FindSet(true) then
repeat
if MobWmsRegistration.SerialNumber <> '' then begin
// Determine the bin where this serial number is stored
// Update the "From Bin" if the bin is different than the actual bin
end;
until MobWmsRegistration.Next() = 0;
end;
This principle can be used to handle many scenarios,