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 16 Next »

Use this event to

Handle business logic for the custom RegistrationType.

Values from Xml Post-Request is provided as input parameter tables and be accessed/iterated with no use of Xml.


Supersedes OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml


Template 01 - Subscribe only to mandatory parameters (excluded _DraftRegistration and _XmlRequestDoc)

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure My02OnPostAdhocRegistrationOnCustomRegistrationType(var _RequestElement: Record "MOB NS Request Element"; var _XmlResponseDoc: XmlDocument; _RegistrationType: Textvar _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
    begin
        if _RegistrationType = 'MyCustomRegistrationType' then begin      // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if _IsHandled then
                exit;


            // Handle _RequestElement and create _XmlResponseDoc here
            // ....

            _IsHandled := true;
        end;
    end;


Template 02 - Subscribe to all parameters

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure My01OnPostAdhocRegistrationOnCustomRegistrationType(var _RequestElement: Record "MOB NS Request Element"; var _DraftRegistration: Record "MOB WMS Registration"; var _XmlRequestDoc: XmlDocumentvar _XmlResponseDoc: XmlDocument; _RegistrationType: Textvar _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
    begin
        if _RegistrationType = 'MyCustomRegistrationType' then begin      // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if _IsHandled then
                exit;


            // Handle _RequestElement and create _XmlResponseDoc here
            // ....

            _IsHandled := true;
        end;
    end;

Example - Iteration of _RequestElement and _DraftRegistration

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure Ex01OnPostAdhocRegistrationOnCustomRegistrationType(var _RequestElement: Record "MOB NS Request Element"; var _DraftRegistration: Record "MOB WMS Registration"; var _XMLRequestDoc: XmlDocumentvar _XMLResponseDoc: XmlDocument; _RegistrationType: Textvar _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
    begin
        if _RegistrationType = 'MyCustomRegistrationType' then begin      // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if _IsHandled then
                exit;


            // Sample iteration of requestData (excluding <Order>-element)
            if _RequestElement.FindFirst() then
                repeat
                until _RequestElement.Next() 0;

            // Sample iteration of "draft" registrations from <Order>-element (snapshot of unposted Registrations as they look right now when an adhoc registration is triggered)
            // Draft registrations is included only if attribute sendRegistrationData="Order"|"OrderLine" was used from application.cfg
            if _DraftRegistration.FindFirst() then
                repeat
                until _DraftRegistration.Next() 0;

            _IsHandled := true;
        end;
    end;



Example - Read values from _RequestElement (and, subscribing only to mandatory parameters: excluded _DraftRegistration and _XmlRequestDoc)

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationType''', true, true)]
    local procedure Ex02OnPostAdhocRegistrationOnCustomRegistrationType(var _RequestElement: Record "MOB NS Request Element"; var _XMLResponseDoc: XmlDocument; _RegistrationType: Textvar _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
    var
        MOBToolbox: Codeunit "MOB Toolbox";
        Status: Text;
    begin
        if (_RegistrationType = 'MyCustomUnplannedProdConsumption') and (not _IsHandledthen begin
            Status := PostUnplannedProdConsumption(_RequestElement, _RegistrationType, _RegistrationTypeTracking);
            MOBToolbox.CreateSimpleResponse(_XMLResponseDoc, Status);
            _IsHandled := true;
        end;
    end;


    local procedure PostUnplannedProdConsumption(var _RequestElement: Record "MOB NS Request Element"; _RegistrationType: Textvar _ReturnRegistrationTypeTracking: Text[200])Text
    var
        MobWmsLanguage: Codeunit "MOB WMS Language";
        MobWmsToolbox: Codeunit "MOB WMS Toolbox";
        ProdOrderNo: Code[20];
        ProdOrderLineNo: Integer;
        ItemNo: Code[20];
        VariantCode: Code[20];
        UnitOfMeasureCode: Code[10];
        Qty: Decimal;
    begin
        // Populate information about this request/response to be displayed at the Mobile Document Queue
        _ReturnRegistrationTypeTracking := CopyStr(_RegistrationType, 1, MaxStrLen(_ReturnRegistrationTypeTracking));

        // Parse values from Request
        ProdOrderNo := _RequestElement.GetValue('ProdOrder').SubString(1, MaxStrLen(ProdOrderNo));
        ProdOrderLineNo := MobWmsToolbox.Text2Int(_RequestElement.GetValue('ProdOrderLineNo'));
        ItemNo := _RequestElement.GetValue('Item').Substring(1, MaxStrLen(ItemNo));
        VariantCode := _RequestElement.GetValue('Variant', false).Substring(1, MaxStrLen(VariantCode));    // GetValue(.., false) = no error if not exists
        UnitOfMeasureCode := _RequestElement.GetValue('UoM', false).Substring(1, MaxStrLen(UnitOfMeasureCode));
        Qty := MobWmsToolbox.Text2Int(_RequestElement.GetValue('Qty'));

        // 
        // Find the Prod. Order Line
        // 
        // ... not implemented in this example

        // 
        // Create Item Journal Line and post  
        //
        // ... not implemented in this example

        exit(MobWmsLanguage.GetMessage('REG_TRANS_SUCCESS'));
    end;



Version History

Version

Changes

MOB5.15Introduced
  • No labels