This post is machine-translated. The original post in german language can be found here.

Add sales order line to existing load through code

In this post I would like to show how you can add all the lines of an sales order or even a selection of sales order lines by code to an existing load.

Selection of sales order lines

static void Job1(Args _args)
{
    WHSLoadPlanningWorkbenchServerForm loadPlanningWorkbenchServerForm = new WHSLoadPlanningWorkbenchServerForm();
    WHSInventTransSumDim whsInventTransSumDim;
    counter c = 0;
    WHSLoadTable whsLoadTable =
    whsLoadTable::find("USMF-000004");

    void addLine(InventTransId _inventTransId)
    {
        c++;

        select whsInventTransSumDim
        where whsInventTransSumDim.InventTransId == _inventTransId;

        loadPlanningWorkbenchServerForm.createTmpLoadLinesSalesLines(
            false,
            whsInventTransSumDim,
            c);
    }

    // Initialize parameter from Load
    loadPlanningWorkbenchServerForm.parmLoadPaysFreight(
            whsLoadTable.LoadPaysFreight);
    
    // Add lines using inventTransId
    addLine('012512');
    addLine('012513');

    // Add lines to load
    loadPlanningWorkbenchServerForm.addLoadLines(whsLoadTable);
}

All sales order lines of an sales order

static void Job1(Args _args)
{
    WHSLoadPlanningWorkbenchServerForm loadPlanningWorkbenchServerForm = new WHSLoadPlanningWorkbenchServerForm();  
    WHSInventTransSumDim whsInventTransSumDim;
    WHSLoadTable whsLoadTable = whsLoadTable::find("USMF-000004");
    InventTransId inventTransId = "012512";
    
    // Only one InventTransId must be selected,
    // loadPlanningWorkbenchServerForm processes all sales lines
    // with same Sales ID
    select whsInventTransSumDim
    where whsInventTransSumDim.InventTransId == inventTransId;     

 

    loadPlanningWorkbenchServerForm.createTmpLoadLinesSalesLines(
            true,
            whsInventTransSumDim,
            0);        
   
    // Add lines to load
    loadPlanningWorkbenchServerForm.addLoadLines(whsLoadTable);
}

 

These post applies to following version:
Dynamics AX 2012

Add comment

 

 
 
 
posts of the actual month
Januar 2019
MoDiMiDoFrSaSo
 123456
78910111213
14151617181920
21222324252627
28293031 
 
 
© 2006-2019 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.