D365FO – AX – Posting a Transfer Order using X++

While working with unit testing in AX, I came across the need to generate a transfer order and post it to generate the associated tables. I have used the FormLetter classes for posting Sales Orders & Purchase Orders in the past so I started looking for a similar process for Transfer Orders. I started by examining the code that is used in AX for the same purpose. This search led me to the following information.

For posting Transfer Orders the InventTransferUpd classes are used to post a single Transfer Order, while the InventTransferMulti classes are used to post multiple Transfer Orders in a single run.

The InventTransferUpd classes contain a static method that constructs a new instance using an InventTransferParmTable record to set the posting options. The classes also contain a run() method that performs the actual posting.

The following example demonstrates a potential usage of all three types of the InventTransferUpd classes.

static InventTransferUpd PostTransferOrder(InventTransferParmTable _invTransParmTbl)
    InventTransferUpd    invTranUpd;
        case InventTransferUpdateType::PickingList:
            invTranUpd = InventTransferUpdPick::newParmBuffer(_invTransParmTbl);
        case InventTransferUpdateType::Shipment:
            invTranUpd = InventTransferUpdShip::newParmBuffer(_invTransParmTbl);
        case InventTransferUpdateType::Receive:
            invTranUpd = InventTransferUpdReceive::newParmBuffer(_invTransParmTbl);
            return null;        
    return invTranUpd;    

This method could be called in the following manner:

InventTransferParmTable invTransParmTbl;
invTransParmTbl.TransferId = [TRANSFER ID];
invTransParmTbl.EditLines = true;
invTransParmTbl.AutoReceiveQty = true;
invTransParmTbl.UpdateType = InventTransferUpdateType::PickingList;
invTransParmTbl.PickUpdateQty = InventTransferPickUpdateQty::All;
invTransParmTbl.TransDate = systemDateGet();

This quick solution was sufficient for my need of generating some unit test data, but you can browse the methods and fields of the classes & tables demonstrated here to get a better understanding of which fields may be needed for your particular circumstance.

If you have more information on this topic, I welcome any feedback


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...