Wednesday, October 28, 2015

The code below can be used to create a new transfer order which is the picked, registered, shipped and received
    InventTransferMultiShip     inventTransferMultiShip;
    inventTransferMultiReceive  inventTransferMultiReceive;
    InventTransferMultiPick       InventTransferMultiPick;
    parmId              parmId;
    
    List list = new List(Types::String);
    WMSPickingRoute localWMSPickingRoute;
    
    numberSequenceReference numberSequenceReference;
    NumberSeq           numberSeq;
    InventTransferTable inventTransferTable;
    InventTransferLine  inventTransferLine;
    InventDim           inventDim;
    Num num;
    
    
    inventTransferParmUpdate    inventTransferParmUpdate;
    inventTransferParmTable     inventTransferParmTable;
    ;

    inventTransferTable.clear();
    inventTransferTable.initValue(); 
   


    ttsBegin;
    numberSeq = NumberSeq::newGetNum(InventParameters::numRefTransferId());
    num = numberSeq.num();
    ttsCommit;
    inventTransferTable.TransferId = num;
    inventTransferTable.InventLocationIdFrom = "AUSTIN";
    inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdFrom));
    inventTransferTable.InventLocationIdTo = "CINCINN";
    inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdTo));
    inventTransferTable.TransferStatus = InventTransferStatus::Created;
    //inventTransferTable.lin = 1;
    inventTransferTable.insert();

    inventTransferLine.clear();
    inventTransferLine.initFromInventTransferTable(inventTransferTable,
    NoYes::Yes);
    inventTransferLine.ItemId = "0001";

    inventDim.inventSiteId = "CENTRAL";
    inventDim.InventLocationId = "AUSTIN";

    inventDim = inventDim::findOrCreate(inventDim);

    inventTransferLine.initFromInventTable(InventTable::find("0001"));

    inventTransferLine.InventDimId = inventDim.inventDimId;
    inventTransferLine.QtyTransfer = 2;
    inventTransferLine.QtyShipNow = 2;
    inventTransferLine.QtyReceiveNow = 2;
    inventTransferLine.QtyRemainShip = 2;
    inventTransferLine.QtyRemainReceive = 2;
   
    
    inventTransferLine.insert();
    
    //Update transfer order as shipped
    //Generate ParmId
    parmId = RunBaseMultiParm::getSysParmId();

    //inventTransferMultiShip
    inventTransferParmUpdate.ParmId =  parmId;
    inventTransferParmUpdate.insert();

    inventTransferParmTable.initValue();
    inventTransferParmTable.ParmId = parmId;
    inventTransferParmTable.TransferId = inventTransferTable.TransferId;
  
    inventTransferParmTable.PickUpdateQty = InventTransferPickUpdateQty::All;
    inventTransferParmTable.EditLines = NoYes::Yes;
    
    inventTransferParmTable.AutoReceiveQty = NoYes::No;
    inventTransferParmTable.TransDate = systemDateGet();
    inventTransferParmTable.UpdateType = InventTransferUpdateType::PickingList;
    inventTransferParmTable.insert();

    InventTransferMultiPick = new InventTransferMultiPick();
    InventTransferMultiPick.runUpdate(inventTransferParmTable);
    
   
    //Picking list registration
    select localWMSPickingRoute
    where localWMSPickingRoute.transRefId == inventTransferTable.TransferId;
    
    list.addEnd(localWMSPickingRoute.PickingRouteID);
    
    WMSPickingRoute::finishMulti(list.pack());//Note - this is not in a single tts, so some routes might be posted and others fail

    wmsDeliverPickedItems::checkDeliverPickedItems(localWMSPickingRoute.PickingRouteID,list.pack());
    
    //Update transfer order as shipped
    //Generate ParmId
    parmId = RunBaseMultiParm::getSysParmId();

    //inventTransferMultiShip
    inventTransferParmUpdate.ParmId =  parmId;
    inventTransferParmUpdate.insert();

    inventTransferParmTable.clear();
    inventTransferParmTable.initValue();
    inventTransferParmTable.ParmId = parmId;
    inventTransferParmTable.TransferId = inventTransferTable.TransferId;
   
    inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;
            
    inventTransferParmTable.EditLines = NoYes::Yes;
    
    inventTransferParmTable.AutoReceiveQty = NoYes::No;
    inventTransferParmTable.TransDate = systemDateGet();
    inventTransferParmTable.UpdateType = InventTransferUpdateType::Shipment;

    inventTransferParmTable.insert();
    
    inventTransferMultiShip = new inventTransferMultiShip();
    inventTransferMultiShip.runUpdate(inventTransferParmTable);
    
    
    //Update transfer order as received
    //Generate ParmId
    parmId = RunBaseMultiParm::getSysParmId();
    
    inventTransferParmUpdate.ParmId =  parmId;
    inventTransferParmUpdate.insert();

    inventTransferParmTable.clear();
    inventTransferParmTable.initValue();
    inventTransferParmTable.ParmId = parmId;
    inventTransferParmTable.TransferId = inventTransferTable.TransferId;
   
    inventTransferParmTable.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All;
    inventTransferParmTable.EditLines = NoYes::Yes;
    
    inventTransferParmTable.AutoReceiveQty = NoYes::No;
    inventTransferParmTable.TransDate = systemDateGet();
    inventTransferParmTable.UpdateType = InventTransferUpdateType::Receive;
    inventTransferParmTable.insert();
    
    inventTransferMultiReceive = new inventTransferMultiReceive();
    inventTransferMultiReceive.runUpdate(inventTransferParmTable);

Thursday, November 22, 2012

How to clear user cache in AX 2012

Each AX user has a cache memory in its desktop. They can be cleared relatively easy. Just look for *.auc file usually located in C:\Users\XXXX\AppData\Local\ and delete it manually

Wednesday, August 22, 2012

I've stumbled across a problem in General Journal in which the primary key (Customer Account Number) was renamed (e.g. from C-000003 to C-DVL) and when it was created as a line in General Journal and then saved will throw a validation error "C-000003 does not exist". This happens because the financial dimension attribute has not been updated from C-000003 into C-DVL, so that everytime the LedgerJournalTrans was checked it will check C-000003 instead of C-DVL. To solve this problem, update the data in DimensionAttributeValueCombination display value from the old account number into the new one.

Tuesday, July 24, 2012

Code to set picked Invent Transaction into on order in Production Picking List
Courtesy of David
//DGU - Released Picked transaction while select inventTransOrigin where InventTransOrigin.InventTransId == this.InventTransId && InventTransOrigin.ItemId == this.ItemId && inventTransOrigin.ReferenceCategory == InventTransType::ProdLine && inventTransOrigin.ReferenceId == this.ProdId { while select forUpdate inventTrans where inventTrans.InventTransOrigin == inventTransOrigin.RecId && inventTrans.inventDimId == this.InventDimId && inventTrans.StatusIssue == StatusIssue::Picked && inventTrans.VoucherPhysical == "" && inventTrans.Voucher == "" { inventMovementPicked = inventTrans.inventMovement(); inventDimPicked = inventMovementPicked.inventdim(); inventDimParmPicked.initFromInventDim(inventDimPicked); inventUpd_Picked = InventUpd_Picked::newParameters(inventMovementPicked,inventDimPicked,inventDimParmPicked, inventDimPicked,inventDimParmPicked,inventTrans.Qty * -1); inventUpd_Picked.updateNow(); } } //End

Sunday, July 22, 2012

Error :
Microsoft SQL Server 2008 Setup: The following error has occurred: A network error occurred while attempting to read from the file: [install-device-name--and-root-of-path-here]\x64\setup\x64\sqlncli[1].msi
Solution :

Uninstall SQL Native Client

Tuesday, July 10, 2012

Useful Classes for Modifications

Here are some useful classes should any modification needs arises :
1. To modify ListPages, look for its Interaction classes. i.e : for PurchReqTableListPage, look for PurchReqTableListPageInteraction class.

2. To change whether an Inventory Dimension required to be mandatory or not, look for InventDimCtrl_Frm class. i.e : for ForecastSales class, look for InventDimCtrl_Frm_Forecast.

Monday, July 9, 2012

How to find On Hand Qty in AX 2012

Here's how to find On Hand Qty filtered by inventory dimension :

display Real itemOnHand()
{
ItemId                      itemId;
InventDimParm               inventDimParm;
InventSumDatePhysicalDim    inventSumDatePhysicalDim;

;

inventDimParm.initFromInventDim(this.inventDim());

return inventSumDatePhysicalDim::onHandQty(today(),this.ItemId,this.inventDim(),inventDimParm);

}