Monday, December 23, 2013

Creating Transfer Order through X++ code



    numberSeq = NumberSeq::newGetNum(Inventparameters::numRefTransferId()); // Parameters Table
 
 
    InventDim = InventDim::find(prodbomchk.InventDimId);
    inventTransferTable.TransferId = numberSeq.num(); // Next NumberSeq generated
    inventTransferTable.InventLocationIdFrom = prodBOM.FromWareHouse;//FromWarehouse;
    inventTransferTable.InventLocationIdTo = InventDim.InventLocationId;
    inventTransferTable.modifiedField(fieldNum(inventTransferTable, InventLocationIdTo));
    inventTransferTable.ShipDate = today();
    inventTransferTable.ReceiveDate = today() + 21;
    inventTransferTable.ProductionNo = prodBOM.ProdId;
    inventTransferTable.TransferStatus = InventTransferStatus::Created;
    inventTransferTable.initFromAddress();
    inventTransferTable.initValue();
    //inventTransferTable.initDeliveryMode();
    inventTransferTable.initToAddress();
    inventTransferTable.insert();

    while(prodBOM) // loop till last record
    {


        inventTransferLine.clear();
        inventTransferLine.initFromInventTransferTable(inventTransferTable,NoYes::Yes);
        inventTransferLine.ItemId = prodBOM.ItemId;
        inventTransFerLine.LineNum = InventTransferLine::lastLineNum(inventTransferTable.TransferId) + 1;
        inventTable = InventTable::find(InventTransferLine.ItemId);
        inventTransferLine.initFromInventTable(InventTable);
     
        inventTransferLine.ConsumedQty = consumedQty;
        inventTransferLine.ProductionNo = prodBOM.ProdId;
        inventTransferLine.QtyTransfer = prodBOM.productionQty;
        inventTransferLine.QtyRemainShip = prodBOM.productionQty;
        inventTransferLine.QtyRemainReceive = prodBOM.productionQty;
        inventTransferLine.QtyShipNow = 0;
        inventTransferLine.QtyReceiveNow = 0;

        inventTransferLine.insert(NoYes::Yes);

     }



No comments:

Post a Comment