Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 28 Next »

Deprecated

This article was written for legacy versions of Mobile WMS (MOB.11 - MOB5.13).

New events was introduced in MOB5.14 and this article was updated accordingly, see Case: Add Line Steps for Warehouse Receipts

Case

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.

Save collected NetWeight/GrossWeight values to new fields at Warehouse Receipt Lines. Then, move the values to Item Card during standard BC posting to ensure changes to Item Card is written within correct scope (same COMMIT as Warehouse Receipt Line posting).

Standard CRONUS Location 'WHITE' can be used for testing the customization.


Example

tableextension 50200 "DEMO Warehouse Receipt Line" extends "Warehouse Receipt Line"
{
    fields
    {
        field(50200; "DEMO Captured NetWeight"; Decimal)
        {
            Description = 'Mobile WMS DEMO';
            Caption = 'Captured NetWeight';
            DataClassification = CustomerContent;
        }


        field(50201; "DEMO Captured GrossWeight"; Decimal)
        {
            Description = 'Mobile WMS DEMO';
            Caption = 'Captured GrossWeight';
            DataClassification = CustomerContent;
        }
    }

}

tableextension 50201 "DEMO Posted Whse. Receipt Line" extends "Posted Whse. Receipt Line"
{
    fields
    {
        field(50200; "DEMO Captured NetWeight"; Decimal)
        {
            Description = 'Mobile WMS DEMO';
            Caption = 'Captured NetWeight';
            DataClassification = CustomerContent;
        }


        field(50201; "DEMO Captured GrossWeight"; Decimal)
        {
            Description = 'Mobile WMS DEMO';
            Caption = 'Captured GrossWeight';
            DataClassification = CustomerContent;
        }
    }

}


codeunit 50201 "DEMO Receive Weight Ext v5.11"
{

    //
    // Create new RegistrationCollectorConfiguration-Key in reference data with two steps named: "CustomGrossWeightGrams" and "CustomNetWeightGrams"
    // 
    [EventSubscriber(ObjectType::CodeunitCodeunit::"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''CustomWReceiveSteps''', XmlKeyNode);
        MobXmlMgt.AddElement(XmlConfigurationNode, 'Value''''', XmlValueNode);

        // Add the CDATA section to the Value-Node
        XmlCDataSection := GetOrderLineExtraInfoCDataSection();
        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, XmlCDataSection, '');

        // Create the start tags of the configuration xml. These must be closed afterwards.
        MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '<registrationCollectorConfiguration>');
        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, 001000006, 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, 001000006, true);

        MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '</steps>');
        MobXMLMgt.NodeAppendCDataText(XmlCDataSection, '</registrationCollectorConfiguration>');

        exit(XmlCDataSection);
    end;

    //
    // Add steps referenced by new RegistrationCollectorConfiguration-Key to line steps collectors
    //
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyLine''', true, true)]
    procedure OnGetReceiveOrderLines_OnAddStepsToAnyLine(_RecRef: RecordRefvar _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_StepsByReferenceDataKey('CustomWReceiveSteps', true);
    end;

    //
    // Handle new step input values by WhseReceiptLine (move captured values to new fields at Whse. Receipt Line)
    //
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnPostReceiveOrder_OnHandleRegistrationForWarehouseReceiptLine''', true, true)]
    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 NetWeight" := MobWmsToolbox.Text2Int(_Registration.GetValue('CustomNetWeightGrams', true));
        _WhseReceiptLine."DEMO Captured GrossWeight" := MobWmsToolbox.Text2Int(_Registration.GetValue('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::CodeunitCodeunit::"Whse.-Post Receipt", 'OnBeforePostSourceDocument''', true, true)]
    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 NetWeight" <> 0) or (WhseRcptLine."DEMO Captured GrossWeight" <> 0))) then
            exit;

        UpdateItemWeights(Item, WhseRcptLine."DEMO Captured NetWeight", WhseRcptLine."DEMO 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

VersionChanges
MOB5.11Required events introduced
  • No labels