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

 
 

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 2006-2024 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.