Warning |
---|
This article was written for legacy versions of Mobile WMS extension (MOB.11 - MOB5.13). New events was introduced in MOB5.14 and this article was updated accordingly, see Case: Add Line Steps for to Warehouse Receipts |
Case
Excerpt |
---|
A customer wishes to start using Item NetWeight and -GrossWeight, but have currently no values registered at the Item Card. Create a temporary customization is to collect these weights when goods are received. |
The captured values must be written to the Item Card during posting.
Proposed solution
The customer is using Warehouse Receipts for inbound goods always. Two new Decimal collector steps must be added for the user to enter NetWeight and GrossWeight for the item.
The customization is to be used only for a limited time, and should be isolated / easy to remove later.
...
Standard CRONUS Location 'WHITE' can be used for testing the customization.
Example
tableextension 5020050665 "DEMO Warehouse Receipt LineMOBDEMO Warehouse Receipt Line" extends "Warehouse Receipt Line"
{
fields
{
field(50200; "DEMO Captured NetWeightMOBDEMO Captured NetWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured NetWeight';
DataClassification = CustomerContent;
}
field(50201; "DEMO Captured GrossWeightMOBDEMO Captured GrossWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured GrossWeight';
DataClassification = CustomerContent;
}
}
}
tableextension 5020150666 "DEMO Posted WhseMOBDEMO Posted Whse. Rcpt. Receipt Line Li" extends "Posted Whse. Receipt Line"
{
fields
{
field(50200; "DEMO Captured NetWeightMOBDEMO Captured NetWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured NetWeight';
DataClassification = CustomerContent;
}
field(50201; "DEMO Captured GrossWeightMOBDEMO Captured GrossWeight"; Decimal)
{
Description = 'Mobile WMS DEMO';
Caption = 'Captured GrossWeight';
DataClassification = CustomerContent;
}
}
}
codeunit 50201 "DEMO Receive Weight Ext v5.11"
{
//
// [Case] [Add Line Steps to Warehouse Receipts v5.11]
//
//
// A customer wishes to start using Item NetWeight and -GrossWeight, but have currently no values registered at the Item Card.
// A temporary customization is to be made to start filling in these values when goods are received.
// The captured values must be written to the Item Card during posting.
//
//
// Create new RegistrationCollectorConfiguration-Key in reference data with two steps named: "CustomGrossWeightGrams" and "CustomNetWeightGrams"
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAfterAddRegistrationCollectorConfigurationsAsXml', '', true, true)]
local procedure OnGetReferenceData_OnAfterAddRegistrationCollectorConfigurationsAsXml(var _XmlResponseData: XmlNode)
var
MobXmlMgt: Codeunit "MOB XML Management";
XmlConfigurationNode: XmlNode;
XmlKeyNode: XmlNode;
XmlValueNode: XmlNode;
XmlCDataSection: XmlCdata;
begin
// Add the mandatory nodes
MobXmlMgt.AddElement(_XmlResponseData, 'Configuration', '', '', XmlConfigurationNode);
MobXmlMgt.AddElement(XmlConfigurationNode, 'Key', 'CustomWReceiveStepsCustomReceiveSteps', '', XmlKeyNode);
MobXmlMgt.AddElement(XmlConfigurationNode, 'Value', '', '', XmlValueNode);
// Add the CDATA section to the Value-Node
XmlCDataSection := GetOrderLineExtraInfoCDataSection();
MobXMLMgt MobXmlMgt.NodeAppendCData(XmlValueNode, XmlCDataSection);
end;
local procedure GetOrderLineExtraInfoCDataSection() XmlCDataSection: XmlCdata
var
MobXmlMgt: Codeunit "MOB XML Management";
MobConfTools: Codeunit "MOB WMS Conf. Tools";
DummyXmlDocument: XmlDocument;
begin
// Create an empty CDATA section to add the registrationCollectorConfiguration XML to
MobXmlMgt.NodeCreateCData(DummyXmlDocument, XmlCDataSectionXmlCDataSection, '');
// Create the start tags of the configuration xml. These must be closed afterwards.
MobXMLMgt MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '<registrationCollectorConfiguration>');
MobXMLMgt MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '<steps>');
// Add the actual steps
MobConfTools.RC_Std_Parms(10000, 'CustomGrossWeightGrams', 'Gross Weight (Grams)', 'Gross Weight (Grams):', 'Gross Weight in Grams per Base Unit of Measure');
MobConfTools.RC_Decimal_CData(XmlCDataSection, 0, 0, 100000, 6, true);
MobConfTools.RC_Std_Parms(20000, 'CustomNetWeightGrams', 'Net Weight (Grams)', 'Net Weight (Grams):', 'Net Weight in Grams per Base Unit of Measure');
MobConfTools.RC_Decimal_CData(XmlCDataSection, 0, 0, 100000, 6, true);
MobXMLMgt
MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '</steps>');
MobXMLMgt MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '</registrationCollectorConfiguration>');
exit(XmlCDataSection);
end;
//
// Add steps referenced by new RegistrationCollectorConfiguration-Key to line steps collectors
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyLine', '', true, true)]
local procedure OnGetReceiveOrderLines_OnAddStepsToAnyLineOnAfterAddStepsOnAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
begin
with _BaseOrderLineElement do
// MOB5.11
// Currently the Android Mobile App supports only one "RegisterExtraInfo"-node (one extra RegistrationCollectorConfigurationKey).
// The last subscriber to OnGetReceiveOrderLines_OnAfterAddStepsByReferenceDataKey must set a <RegisterExtraInfo>-key that includes steps for all previous subscribers.
// This is only possible by knowing what other customizations is done and manually create a new RegistrationCollectorConfigurationKey that includes all steps.
//
// In this demo we expect to be only subscriber and throw an error if earlier subscribtions exists by including optional _ErrorIfAlreadyCreated parameter.
// We cannot test if later subcribers is overriding this value we set.
Create _BaseOrderLineElement.Create_StepsByReferenceDataKey('CustomWReceiveStepsCustomReceiveSteps', true);
end;
//
// Handle new step input values by WhseReceiptLine (move captured values to new fields at Whse. Receipt Line)
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnHandleRegistrationForWarehouseReceiptLine', '', true, true)]
local procedure OnPostReceiveOrder_OnHandleRegistrationForWarehouseReceiptLine(var _Registration: Record "MOB WMS Registration"; var _WhseReceiptLine: Record "Warehouse Receipt Line")
var
MobWmsToolbox: Codeunit "MOB WMS Toolbox";
RegistrationXmlText: Text;
begin
// Demo: Show content of the "Registration XML" blob -- not needed for the processing below (useful for debugging)
RegistrationXmlText := _Registration.GetRegistrationXmlAsText();
// Parse the xml WmsRegistration by name of the steps declared in GetOrderLineExtraInfoCDataSection() and save value to new fields at WhseReceiptLine
// Includes optional parameter _ErrorIfNotExists since we unconditially expect these two nodes to exist at all line registrations
_WhseReceiptLine."DEMO Captured NetWeightMOBDEMO Captured NetWeight" := MobWmsToolbox.Text2Int(_Registration.GetValueGetValueAsDecimal('CustomNetWeightGrams', true));
_WhseReceiptLine."DEMO Captured GrossWeightMOBDEMO Captured GrossWeight" := MobWmsToolbox.Text2Int(_Registration.GetValueGetValueAsDecimal('CustomGrossWeightGrams', true));
end;
//
// Push new fields at Warehouse Activity Line to Item card using standard posting event
// Using this standard event ensures data written to Item is within same commit at Whse Receipt Line posting
//
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Whse.-Post Receipt", 'OnBeforePostSourceDocument', '', true, true)]
local procedure OnWhsePostReceiptOnBeforePostSourceDocument(var WhseRcptLine: Record "Warehouse Receipt Line"; PurchaseHeader: Record "Purchase Header"; SalesHeader: Record "Sales Header"; TransferHeader: Record "Transfer Header")
var
Item: Record Item;
begin
if not (Item.Get(WhseRcptLine."Item No.") and ((WhseRcptLine."DEMO Captured NetWeightMOBDEMO Captured NetWeight" <> 0) or (WhseRcptLine."DEMO Captured GrossWeightMOBDEMO Captured GrossWeight" <> 0))) then
exit;
UpdateItemWeights(Item, WhseRcptLine."DEMO Captured NetWeightMOBDEMO Captured NetWeight", WhseRcptLine."DEMO Captured GrossWeightMOBDEMO Captured GrossWeight");
Item.Modify();
end;
local procedure UpdateItemWeights(var _Item: Record Item; _NetWeightGrams: Integer; _GrossWeightGrams: Integer)
var
ConversionFactor: Decimal;
begin
// Conversion factor between registrered unit (grams) and item card unit (kg) -- hardcoded for simplification
ConversionFactor := 1000;
// Update item card if new values was provided in the input steps
if _GrossWeightGrams > 0 then
_Item."Gross Weight" := _GrossWeightGrams / ConversionFactor;
if _NetWeightGrams > 0 then
_Item."Net Weight" := _NetWeightGrams / ConversionFactor;
end;
}
Testing your solution
- Register a Warehouse Receipt at a Mobile Device. Two new line steps for NetWeight and GrossWeight should appear. Add both Weights for an item and post the Receipt.
- Run table browser for Posted Whse. Receipt Line (table no. 7319). Your new values should be visible at latest posted receipt:
- Run table browser for Item (table no. 27). Your new values should be recorded at the Item you registered/posted:
Version History
Version | Changes |
---|---|
MOB5.11 | Required events introduced |