Sunday, July 26, 2020

Create Transfer Order using X++.


InventTransferTable                 inventTransferTable;

InventTransferLine                  inventTransferLine;

InventTransferId                      inventTransferId;


public void createTransferOrder()

{

     ttsBegin;

     createHeader();

        createLine()

    ttsCommit;

}

Sample code to create header of the Transfer Order

public void createHeader()

{        

        //create the transfer order id.

        inventTransferId = InventTransferTable::numberSeq().num(); 

        inventTransferTable.clear();

        inventTransferTable.initValue();

        inventTransferTable.TransferId = inventTransferId; // assign the transfer order id

        inventTransferTable.InventLocationIdFrom = “FromWarehouse”;  // assign the from warehouse

        inventTransferTable.InventLocationIdTo = “ToWarehouse”; // assign the to warehouse

        inventTransferTable.TransferStatus = InventTransferStatus::Created; // assign the transfer status

        inventTransferTable.DlvModeId = “ShipMethod”; 

        inventTransferTable.ShipDate = “ShipDate”; // assign the ship date

        inventTransferTable.ReceiveDate = “ReceiveDate”; // assign the receive date

        inventTransferTable.AutoReservation = NoYes::No;

        inventTransferTable.initToAddress();

        inventTransferTable.initFromAddress();

        inventTransferTable.InventLocationIdTransit = InventLocation::find(“FromWarehouse”).InventLocationIdTransit;

        inventTransferTable.validateWrite();

        inventTransferTable.insert();

   

Sample code to create line of the Transfer Order

    public void createLine()

    {

        InventDim                   inventDim;

        inventDim.clear();

        inventTransferLine.clear();

        inventDim = inventTransferLine.inventDim();

        inventDim.InventSiteId = InventLocation::find(inventTransferTable.InventLocationIdFrom).InventSiteId;

        inventDim.InventLocationId = inventTransferTable.InventLocationIdFrom;             

        inventTransferLine.initFromInventTransferTable(inventTransferTable,NoYes::Yes);

        inventTransferLine.ItemId = “ItemId”;

        inventTransferLine.LineNum = inventTransferLine::lastLineNum(inventTransferTable.TransferId) + 1;

        inventTransferLine.initFromInventTable(InventTable::find(“ItemId”));

        inventTransferLine.QtyTransfer = “Quantity”;

        inventTransferLine.QtyRemainReceive = “Quantity”;

        inventTransferLine.QtyRemainShip = “Quantity”;

        inventTransferLine.QtyShipNow = 0;

        inventTransferLine.QtyReceiveNow = 0;

        inventTransferLine.RemainStatus = InventTransferRemainStatus::Shipping;

        inventTransferLine.AutoReservation  = NoYes::No;

        inventTransferLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;;

        inventTransferLine.insert();      

    }


No comments:

Post a Comment