Tuesday, August 18, 2015

Inventory Item Registration lines Auto in ax 2012

//Inventory Item Registration in Transfer Order lines Auto in ax 2012
//Registering an Item , success only when On hand Avail physical Qty is greater than Zero

static void San_InvTransRegistrationCode(Args _args)
{
    InventTransferTable     transferTable;
    InventTransferLine      transferLine;
    InventTransWMS_Register inventTransWMS_register;
    InventTrans             inventTrans;
    TmpInventTransWMS       tmpInventTransWMS;
    InventDim               inventDim,Dimtmp,inventDimCreate;
    int                     i;
    Name                    size,color,warehouse,wmslocation,site;

    while select transferTable
                where transferTable.InventLocationIdFrom == "<from warehouse number>"   && transferTable.InventLocationIdTo == "<To Warehouse number>"
                            && transferTable.TransferStatus == InventTransferStatus::Shipped
                            //&& transferTable.TransferId =="<Transfer Order id>"
    {
        while select transferLine where transferLine.TransferId == transferTable.TransferId
               //&&  transferLine.ItemId == "<Item number >"
        {
            Dimtmp.clear();
            Dimtmp.InventSizeId = InventDim::find(transferLine.inventDimId).InventSizeId;
            Dimtmp.InventColorId = InventDim::find(transferLine.inventDimId).InventColorId;
            Dimtmp.InventLocationId = transferTable.InventLocationIdTo;
            Dimtmp.wMSLocationId = "Default";
            Dimtmp.InventSiteId = InventDim::find(transferLine.inventDimId).InventSiteId;
            inventDimCreate = inventDim::findOrCreate(Dimtmp);

            ttsBegin;
            inventTrans = InventTrans::findTransId(transferLine.InventTransIdReceive,true);
            if(inventTrans)
            {
                inventTrans.inventDimId = inventDimCreate.InventDimId;
                inventTrans.update();
            }
            ttsCommit;

            inventDim = inventDim::find(inventTrans.inventDimId);
            inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
            tmpInventTransWMS.clear();
            tmpInventTransWMS.initFromInventTrans(inventTrans);
            tmpInventTransWMS.InventQty = transferLine.QtyShipped;
            tmpInventTransWMS.InventDimId = inventTrans.InventDimId;          
            tmpInventTransWMS.insert();

            inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,inventTrans,inventTrans.inventDim());
            inventTransWMS_register.updateInvent(transferLine);
  i++;
        }
    }
}

2 comments:

  1. Hello!
    its code is good, but it will be error if it does not send the item (tmpInventTransWMS.ItemId = transferLine.ItemId;) to take into account and because it updates the inventtrans table?

    ReplyDelete
    Replies
    1. Hi,

      Please find this code.
      inventTrans = InventTrans::findTransId(transferLine.InventTransIdReceive,true);

      This code of line, system will find inventTrans against InventTransId.

      And also, for tmpInventTransWMS.itemId system will fetch automatically from this below line of code tmpInventTransWMS.initFromInventTrans(inventTrans);

      In case, still if u any queries let me know.

      Thanks and Regards
      Sangeeth

      Delete

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...