Wednesday, May 29, 2024

Add sales order line to existing load through code X++

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);
}

No comments:

Post a Comment

Copying and Auto populating financial dimension from inventSite X++

 APPROACH 1 //calling method DimensionAttributeValueSetStorage  valueStorage = this.getDefaultDimension(inventsite); purchTable.defaultdimen...