How to add parallelism to Shipments creation in Acumatica

Hello everybody,

Today I want to leave short note on new feature of Acumatica: ParallelProcessingOptions. Main purpose of that class is adding paralelism to processing screens. Take a look on it's declaration:

public abstract class PXProcessingBase<Table> : PXSelectBase<Table>, IPXProcessing, IPXProcessingWithCustomDelegate where Table : class, IBqlTable, new()
 {
   .
.
  .
   public System.Action<PXParallelProcessingOptions> ParallelProcessingOptions;
   .
.

}

As you can see, ParallelProcessingOptions is a member of PXProcessingBase, while PXProcessingBase is a parent for PXProcessing. For Acumatica developers it means that starting from 2018 R2 you can easily turn on parallel processing 

but only for processing screens. You'll not be able to turn it on for Data entry screens. Also you can turn it on for base Acumatica graph. For example to turn it on for creation of shipments, you can use following code:

public class SOCreateShipmentExt : PXGraphExtension<SOCreateShipment>
{
    public override void Initialize()
    {
        base.Initialize();
 
        Base.Orders.ParallelProcessingOptions =
            settings =>
            {
                string action = null;
                if (Base.Filter.Current != null)
                {
                    action = Base.Filter.Current.Action;
                }
 
                settings.IsEnabled = !string.IsNullOrEmpty(action) && action.StartsWith("PrepareInvoice"StringComparison.OrdinalIgnoreCase);
                settings.BatchSize = 10;
            };
    }
}

Similar behavior you can get for Invoicing of shipments:

public class SOInvoiceShipmentExt : PXGraphExtension<SOInvoiceShipment>
   {
       public override void Initialize()
       {
           base.Initialize();
 
           Base.Orders.ParallelProcessingOptions =
               settings =>
               {
                   string actionID = null;
                   if (Base.Filter.Current != null)
                   {
                       actionID = (string)Base.Orders.GetTargetFill(nullnullnull, Base.Filter.Current.Action, "@actionID");
                   }
                   settings.IsEnabled = (actionID == "2");
                   settings.BatchSize = 10;
               };
       }
   }

and for releasing of invoices:

public class SOReleaseInvoiceExt : PXGraphExtension<SOReleaseInvoice>
{
    public override void Initialize()
    {
        base.Initialize();
 
        Base.SOInvoiceList.ParallelProcessingOptions =
            settings =>
            {
                string actionID = null;
                if (Base.Filter.Current != null)
                {
                    actionID = (string)Base.SOInvoiceList.GetTargetFill(nullnullnull, Base.Filter.Current.Action, "@ActionName");
                }
                settings.IsEnabled = (actionID == "Release");
                settings.BatchSize = 10;
            };
    }
}

As you can see, pattern of usage is pretty straightforward: 

  1. Initialize
  2. Set ParallelProcessingOptions depending of action or automation steps.

In my tests, pefrormance improvement was up to 40 times faster. 

No Comments

Add a Comment