How to configure auto shipping in picking process with base document Inventory Transfer Request

  • Updated

This note describes how to create a hookflow script in order to create the Inventory Transfer document automatically after picking the picklist of an Inventory Transfer Request.


Since there is not Shipping Type on the Inventory Transfer Request document the automatic ‘shipping’ function cannot be started by a configuration.

What we can do is to add an extra logic to AfterPickListPackedHookScript  where we can overwrite the AutomaticShipping parameter to true at the end of the Picking. We can use a VIEW in which we are going to select Picklist if the base document was Inventory Transfer Request.

This solution is available from WMS version 2022.09.06

1. Creating SQL VIEW as an input for the script

First, create an SQL view that contains all source data:

MSSQL

CREATE VIEW [dbo].[PMX_AUTO_DELIVER_PICKLISTS_WHSE_TRNSF] (
      "PickListDocEntry",  "InventoryTransferDocentry" ) AS
SELECT
       PMX_PLHE."DocEntry" AS "PickListDocEntry",
       OWTQ."DocEntry" AS "InventoryTransferDocentry"
FROM "PMX_PLHE"
INNER JOIN "PMX_PLLI" ON PMX_PLHE."DocEntry" = PMX_PLLI."DocEntry"
INNER JOIN "PMX_PLPL" ON PMX_PLLI."BaseEntry" = PMX_PLPL."DocEntry"
AND PMX_PLLI."BaseLine" = PMX_PLPL."LineNum"
INNER JOIN "WTQ1" ON PMX_PLPL."BaseEntry" = WTQ1."DocEntry"
AND PMX_PLPL."BaseLine" = WTQ1."LineNum"
AND PMX_PLPL."BaseType" = WTQ1."ObjType"
INNER JOIN "OWTQ" ON WTQ1."DocEntry" = OWTQ."DocEntry"
WHERE PMX_PLHE."DocStatus" = 'O'
GROUP BY PMX_PLHE."DocEntry",
       OWTQ."DocEntry"
GO

HANA

CREATE VIEW "WMS_PERFORMANCE"."PMX_AUTO_DELIVER_PICKLISTS_WHSE_TRNSF" ( "PickListDocEntry","InventoryTransferDocentry" ) AS 
SELECT
"PMX_PLHE"."DocEntry" AS "PickListDocEntry",
"OWTQ"."DocEntry" AS "InventoryTransferDocentry"
FROM "PMX_PLHE"
INNER JOIN "PMX_PLLI" ON "PMX_PLHE"."DocEntry" = "PMX_PLLI"."DocEntry"
INNER JOIN "PMX_PLPL" ON "PMX_PLLI"."BaseEntry" = "PMX_PLPL"."DocEntry"
AND "PMX_PLLI"."BaseLine" = "PMX_PLPL"."LineNum"
INNER JOIN "WTQ1" ON "PMX_PLPL"."BaseEntry" = "WTQ1"."DocEntry"
AND "PMX_PLPL"."BaseLine" = "WTQ1"."LineNum"
AND "PMX_PLPL"."BaseType" = "WTQ1"."ObjType"
INNER JOIN "OWTQ" ON "WTQ1"."DocEntry" = "OWTQ"."DocEntry"
WHERE "PMX_PLHE"."DocStatus" = 'O'
GROUP BY "PMX_PLHE"."DocEntry",
"OWTQ"."DocEntry"
WITH READ ONLY

 

2. Changing the Workflow script

Next, open the script of AfterPickListPackedHookScript from Organizational Structure > Company object > Workflows tab, and replace the content of the script by the script below. The Mobile Client application must be restarted.

using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Reflection;
using System.Text;

using Produmex.Foundation;
using Produmex.Foundation.Data.Sbo.BusinessObjects.Definitions.Tables;
using Produmex.Foundation.Data.Sbo.DataObjects;
using Produmex.Foundation.Data.Sbo.Utilities;
using Produmex.Foundation.Data.SqlClient;
using Produmex.Foundation.Diagnostics;
using Produmex.Foundation.Messages;
using Produmex.Foundation.SlimScreen;
using Produmex.Foundation.SlimScreen.Interfaces;
using Produmex.Foundation.SlimScreen.Interfaces.Definitions.KnownDataSets;
using Produmex.Foundation.Workflows;
using Produmex.Foundation.Workflows.Parameters;
using Produmex.Foundation.Wwf;
using Produmex.Foundation.Wwf.Sbo;
using Produmex.Foundation.Wwf.Sbo.LocalServices;
using Produmex.Sbo.Logex.Data;
using Produmex.Sbo.Logex.Data.BusinessObjects;
using Produmex.Sbo.Logex.Data.BusinessObjects.Definitions.Tables;
using Produmex.Sbo.Logex.Data.DataObjects;
using System.Collections.ObjectModel;
using Produmex.Sbo.Logex.Data.Providers;
using Produmex.Foundation.Data.Sbo;
using Produmex.Foundation.Data.DbClient;
using Produmex.Foundation.SlimScreen;
using Produmex.Foundation.Collections;

namespace WorkflowScript_AfterPickListPackedHookScript
{
   /// <summary>
   /// This is a hook script, meant to be customized on a "per project" basis
   /// </summary>
   public class WorkflowScript_AfterPickListPackedHookScript : WorkflowInstanceScriptBase
   {
       private static readonly ILog s_log = LogProvider.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);

      // Input parameters * do not change *
       public ReadOnlyBinder<CultureInfo> DefaultCultureInfo;
       public ReadOnlyBinder<PmxOseCompany> PmxOseCompany;
       public ReadOnlyBinder<int> PickListDocEntry;
       public ReadWriteBinder<bool> DoAutomaticShipping;

        // Output parameters * do not change *
       public ReadWriteBinder<PmxDictionary<string, object>> DeliveryData;

        // Sub-flows
       // <none>
       /// <summary>
       /// Initializes a new instance of the <see cref="WorkflowScript_AfterPickListPackedHookScript"/> class.
       /// </summary>
       /// <param name="parent">The parent.</param>
       /// <param name="factory">The factory.</param>

        public WorkflowScript_AfterPickListPackedHookScript( WorkflowInstanceBase parent, WorkflowInstanceFactory factory )
           : base(parent, factory)
       {
       }

      #region WorkflowInstanceScriptBase Members
       protected override void Execute()
       {
           // Parameters in scope
           //Session session = GetScopeParameter("Session") as Session;
           //ISboProviderService sboProviderService = GetScopeParameter("<WwfService>ISboService") as ISboProviderService;
           Session session = GetScopeParameter("Session") as Session;
           ISboProviderService sboProviderService = GetScopeParameter("<WwfService>ISboService") as ISboProviderService;
           string initialErrorKey = null;
           string query = null;
           DataSet dsPicklist = null;
           Message msg = null;
           query = BuildQuery.GetAutomaticShipping(PickListDocEntry);
           dsPicklist = sboProviderService.RunView(false, null, null, query);
                             if (this.GetNumberOfRows(dsPicklist) > 0)
           {
               DoAutomaticShipping.Set(true);
               initialErrorKey = null;
           }
       }
       #endregion

      #region HELPERS
       /// <summary>
       /// Gets the number of rows.
       /// </summary>
       /// <param name="ds">The ds.</param>
       /// <returns></returns>
       private int GetNumberOfRows(DataSet ds)
       {
           if (ds != null && ds.Tables.Count > 0)
           {
               return ds.Tables[0].Rows.Count;
           }
           return 0;
                             }
       #endregion

       #region QUERY
       /// <summary>
       /// Static class grouping our native queries
       /// </summary>
       private class BuildQuery
       {
           //TBA Added           
           public static string GetAutomaticShipping(int PickListDocEntry)
           {
               return string.Format(@"SELECT DISTINCT PickListDocEntry FROM PMX_AUTO_DELIVER_PICKLISTS_WHSE_TRNSF WHERE (PickListDocEntry = {0}) ", PickListDocEntry.ToString());
/*
HANA VERSION
return "SELECT * FROM PMX_AUTO_DELIVER_PICKLISTS_WHSE_TRNSF WHERE \"PickListDocEntry\" =" + PickListDocEntry;
*/
           }
       }
       #endregion
   }
}

 

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.