Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

receive partial transfer order

Posted on by 270

Hi ! I have a transfer order, and i need to make a receive of only some of the products. The code i have, marks the entire order as received. 

If i only execute the last 2 lines of code "itur = InventTransferUpdReceive::newParmBuffer(itpt); itur.run(); ", then nothing gets marked as received. Here is the code:

 

 

private void receiveProducts(inventTransferId _transferId, Map mapQtyArtSFull)

{

    InventTransferParmTable     itpt;

    InventTransferParmLine      itpl;

    InventTransferUpdReceive    itur;

    boolean                     transferHasPendingItems;//si aun faltan recibir otros productos, no completo el recibo

 

    WMSJournalTrans             wmsJournalTrans;

    ;

 

    itpt.clear();

    itpt.initParmDefault();

    //add check to make sure this is only posted if it needs to be posted

    itpt.ParmId = RunBaseMultiParm::getSysParmId();

    itpt.TransferId = _transferId;

    itpt.UpdateType = InventTransferUpdateType::Receive;

    itpt.PrintTransferReceipt = NoYes::No;

    itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All; //<--funciona con ALL, estaba registered

    itpt.EditLines = NoYes::Yes;

    itpt.ExplodeLines = NoYes::Yes;

    //itpt.InventDimFixedReceiveList = 245; // See note below on how to compute this.

    itpt.InventDimFixedReceiveList = 0; // See note below on how to compute this.

 

    itpt.createLines(NoYes::Yes);

 

 

    while select forUpdate itpl

        where itpl.ParmId == itpt.ParmId

    {

        if (mapQtyArtSFull.exists(itpl.ItemId))

        {

            itpl.QtyReceiveNow = mapQtyArtSFull.lookup(itpl.ItemId);

        }

        else

        {

            itpl.QtyReceiveNow = 0;

        }

        itpl.update();

    }

 

  

     itur = InventTransferUpdReceive::newParmBuffer(itpt);

     itur.run();

}

 

And this is the code that generates the order:

 

 

private InventTransferId inventJournalTransfer(Map mapQtyArtSFull, InventSiteId inventSiteId, InventLocationId inventLocationIdFrom, InventLocationId inventLocationIdTo, PackingSlipId packingList)

{

    InventTransferTable     inventTransferTable;

    InventTransferLine      inventTransferLine;

    InventDim               inventDim;

    InventTable             inventTable;

    InventTransferParmLine  inventTransferParmLine;

    InventTransferParmTable   inventTransferParmTable;

 

    inventTransferUpdShip inventTransferUpdShip;

    MapEnumerator mapEnumerator;

   // Ctr_LogisticSeries      ctr_LogisticSeries;

 

    ;

 

    //Order headerInventTransferParmLine

    inventTransferTable.clear();

    inventTransferTable.initValue();

    inventTransferTable.TransferId = InventTransferTable::numberSeq().num();

    inventTransferTable.InventLocationIdFrom = inventLocationIdFrom;

    inventTransferTable.InventLocationIdTo = inventLocationIdTo;

    inventTransferTable.PackingList = PackingList;

 

    inventTransferTable.DlvModeId = CustVendTransportPointLine::defaultDeliveryMode(inventTransferTable.InventLocationIdFrom,'','','','',inventTransferTable.InventLocationIdTo);

    inventTransferTable.InventLocationIdTransit = InventLocation::find(inventTransferTable.InventLocationIdFrom).InventLocationIdTransit;

 

    inventTransferTable.initFromAddress();

    inventTransferTable.initToAddress();

 

    inventTransferTable.ShipDate = SystemDateget();

    inventTransferTable.ReceiveDate = SystemDateget();

 

    if (inventTransferTable.validateWrite())

    {

        inventTransferTable.insert();

 

        mapEnumerator = mapQtyArtSFull.getEnumerator();

        while (mapEnumerator.moveNext())

        {

            select firstonly inventTable

                where inventTable.itemId == mapEnumerator.currentKey();

 

            //Order line

            inventDim.clear();

            inventDim.InventSiteId = inventSiteId;

            inventDim.InventLocationId = inventLocationIdTo;

 

            inventTransferLine.clear();

            inventTransferLine.initValue();

 

            inventTransferLine.ItemId = inventTable.ItemId;

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

            inventTransferLine.QtyTransfer = mapEnumerator.currentValue();

            //inventTransferLine.PackingList = packingList;

 

            inventTransferLine.initFromInventTableModule(InventTableModule::find(inventTransferLine.ItemId,ModuleInventPurchSales::Invent));

 

            inventTransferLine.QtyRemainReceive = inventTransferLine.QtyTransfer;

            inventTransferLine.QtyRemainShip = inventTransferLine.QtyTransfer;

 

            inventTransferLine.ShipDate = SystemDateget();

            //inventTransferLine.ReceiveDate = str2Date(#ReceiveDate, 213);

            inventTransferLine.ReceiveDate = SystemDateget();

 

 

            inventTransferLine.initFromInventTransferTable(inventTransferTable, false);

            inventTransferLine.LineNum = InventTransferLine::lastLineNum(inventTransferLine.TransferId) + 1.0;

 

            if (inventTransferLine.validateWrite())

            {

                inventTransferLine.insert();

            }

            else

            {

                throw error("Order line");

            }

        }

    }

    else

        throw error("Order header");

 

 

    //

    inventTransferParmTable.clear();

    inventTransferParmTable.initParmDefault();

    inventTransferParmTable.ParmId = RunBaseMultiParm::getSysParmId();

    inventTransferParmTable.TransferId = inventTransferTable.TransferId;

    inventTransferParmTable.UpdateType = InventTransferUpdateType::Shipment;

    inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;

    //inventTransferParmTable.PickUpdateQty =  InventTransferPickUpdateQty::AvailableQty;

 

    inventTransferParmTable.EditLines = false;

 

    this.createPickLines(inventTransferParmTable);

    //inventTransferParmTable.ExecutedDateTime = systemDateGet()

 

    inventTransferUpdShip = InventTransferUpdShip::newParmBuffer(inventTransferParmTable);

    inventTransferUpdShip.run();

    return inventTransferTable.TransferId;

 

}

 

 

I googles a lot, tried for days, dunno what else to try . Help please!!

 

Thanks,

Jorge

 

*This post is locked for comments

  • Nik_2015 Profile Picture
    Nik_2015 70 on at
    RE: receive partial transfer order

    Hi,

    For partial transfer order postings, i used the below approach-

    1. Loop through Table/InventTransferLine(assuming you already have a transfer order ID) and check for fields QtyRemainShip & QtyRemainReceive. if they are not zero, that means either the lines are partially shipped or received or is not shipped and received at all.

    2. Within the loop Table/InventTransferLine, update QtyShipNow with QtyRemainShip. 

    3. Now create records in Table/InventTransferParmTable.

    4. Use Class/InventTransferUpd for final posting.

    Below is an example-

    InventTransferUpd invTranUpd;
    InventTransferLine inventTransferLine, inventTransferLineLocal;
    InventTransferParmTable invTransParmTable;

    while select inventTransferLine
    order by LineNum
    where inventTransferLine.TransferId == "00001"
    {
    if(inventTransferLine.QtyRemainShip != 0)
    {
    inventTransferLineLocal = null;

    ttsBegin;
    select forUpdate inventTransferLineLocal
    where inventTransferLineLocal.RecId == inventTransferLine.RecId;

    inventTransferLineLocal.QtyShipNow = inventTransferLine.QtyRemainShip;
    inventTransferLineLocal.update();
    ttsCommit;

    inventTransferLine.reread();

    ttsBegin;
    invTransParmTable.clear();
    invTransParmTable.TransferId = inventTransferLine.TransferId;
    invTransParmTable.EditLines = true;
    invTransParmTable.AutoReceiveQty = true;
    invTransParmTable.UpdateType = InventTransferUpdateType::Shipment;
    invTransParmTable.PickUpdateQty = InventTransferPickUpdateQty::All;
    invTransParmTable.TransDate = systemDateGet();

    switch(invTransParmTable.UpdateType)
    {
    case InventTransferUpdateType::PickingList:
    invTranUpd = InventTransferUpdPick::newParmBuffer(invTransParmTable);
    break;
    case InventTransferUpdateType::Shipment:
    invTranUpd = InventTransferUpdShip::newParmBuffer(invTransParmTable);
    break;
    case InventTransferUpdateType::Receive:
    invTranUpd = InventTransferUpdReceive::newParmBuffer(invTransParmTable);
    break;
    default:
    }

    invTranUpd.run();
    ttsCommit;
    }

    inventTransferLine.reread();

    if(inventTransferLine.QtyRemainReceive != 0)
    {
    inventTransferLineLocal = null;

    ttsBegin;
    select forUpdate inventTransferLineLocal
    where inventTransferLineLocal.RecId == inventTransferLine.RecId;

    inventTransferLineLocal.QtyReceiveNow = inventTransferLine.QtyRemainReceive;
    inventTransferLineLocal.update();
    ttsCommit;

    inventTransferLine.reread();

    ttsBegin;
    invTransParmTable.clear();
    invTransParmTable.TransferId = inventTransferLine.TransferId;
    invTransParmTable.EditLines = true;
    invTransParmTable.AutoReceiveQty = true;
    invTransParmTable.UpdateType = InventTransferUpdateType::Receive;
    invTransParmTable.PickUpdateQty = InventTransferPickUpdateQty::All;
    invTransParmTable.TransDate = systemDateGet();

    switch(invTransParmTable.UpdateType)
    {
    case InventTransferUpdateType::PickingList:
    invTranUpd = InventTransferUpdPick::newParmBuffer(invTransParmTable);
    break;
    case InventTransferUpdateType::Shipment:
    invTranUpd = InventTransferUpdShip::newParmBuffer(invTransParmTable);
    break;
    case InventTransferUpdateType::Receive:
    invTranUpd = InventTransferUpdReceive::newParmBuffer(invTransParmTable);
    break;
    default:
    }

    invTranUpd.run();
    ttsCommit;
    }
    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: receive partial transfer order

    I am not sure you found the solution, I come across the same situation and found a work around , Please share if you have a better solution 

    approach one : 

    Don't create line instead just update InventTransferLine.QtyReceiveNow  with actual receive 

    Second one is little tricky as you are already create line and set edit lines set to true 

    instead your last line change like this 

     itpt.EditLines = NoYes::No ;
    itur = InventTransferUpdReceive::newParmBuffer(itpt);
    itpt.EditLines = NoYes::Yes ;
    itur.run();

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans