AX Consulting

Just another WordPress.com site

Category Archives: Dynamics Ax

How to register Item In Ax 2009 code (using X++)

Last days user created transfer Order to transfer Qty from warehouse to new warehouse, but unfortunately the new warehouse not has default location so The QTY already shipped but could not received at new warehouse.

solution:

1- Create default location for new warehouse.

2- Assign default location to each line in transfer order by go to Inventory —> registration

image 

3- Set Default location for new warehouse

image

4- select auto check box

5- Then click post all.

All steps above you have to it for each line in transfer order, so in case you have many transfer orders it will be tuff task.

In that case I have create below job to register items automatically for transfer order

static void InventTransRegistrationFromCode(Args _args)
{
    InventTransWMS_Register inventTransWMS_register;
    InventTrans             inventTrans ;

    InventDim               inventDim  ;

    TmpInventTransWMS       tmpInventTransWMS;

    inventmovement          movement;
    Common common;
    InventTransferTable     transferTable;
    inventTransferLine      transferLine;
    int                     row;

    ;

    while select transferline where Transferline.TransferId == ‘TRO-180587’
    {

        inventtrans = inventtrans::findTransId(transferline.InventTransIdReceive) ;

        if(inventTrans.StatusReceipt == StatusReceipt::Registered)
            continue ;

        inventDim = inventTrans.inventDim();
        if(!(inventdim.InventLocationId == ‘28995’ && inventDim.wMSLocationId == ”))
            continue ;

        row++;

        tmpInventTransWMS.clear();
        tmpInventTransWMS.initFromInventTrans(inventTrans);
        tmpInventTransWMS.InventQty = inventTrans.Qty;
        inventDim.wMSLocationId = ’00’;
        tmpInventTransWMS.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
        tmpInventTransWMS.insert();

        Common = inventTrans ;

        movement = InventMovement::construct(common);

        if (movement.newMovement_TransferReceipt())
        {
            movement = movement.newMovement_TransferReceipt();
            movement = movement.newMovement_TransferIssueReceive() ? movement.newMovement_TransferIssueReceive() : movement;
            movement = movement.newMovement_TransferReceipt() ? movement.newMovement_TransferReceipt() : movement;
        }

        inventTransWMS_register = new inventTransWMS_register( movement , tmpInventTransWMS);
        inventTransWMS_register.writeTmp(tmpInventTransWMS,tmpInventTransWMS.orig(),true);

        inventTransWMS_register::updateInvent(inventTransWMS_register, tmpInventTransWMS);
    }

    info(queryvalue(row));
}

 

Hint: Kindly in case you have comment or alternative solution please added below.

Advertisements