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

This entry was posted in AX 2012, Microsoft Dynamics AX and tagged , , , , . Bookmark the permalink.

6 Responses to Posting a Transfer Order using X++

  1. Rosa says:

    Hi how can I save the picking qty value and the printpickinglist check mark on the inventtransferparmpicking form?

    Thanks in advance!


  2. Rosa says:

    Hi Steve,

    Thanks for quick reply, I will check it tomorrow , I don’t have any AX at home, then I will let you know if I get it.

    Thanks again

  3. Rosa says:

    Hi Steve,
    It works! Thanks a lot for your help!

    Have nice weekends!

Comments are closed.