Inventdim (findORCreate) using x++ :
private void createJournalLine(InventJournalTable inventJournalTable,TIDMaterialSupportLines _TIDMaterialSupportLines)
{
InventJournalTrans inventJournalTrans;
InventJournalNameId inventJournalName;
InventDim inventDim;
//Below code creates journal lines
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.ItemId = _TIDMaterialSupportLines.ItemId;
inventJournalTrans.initFromInventTable(InventTable::find(_TIDMaterialSupportLines.ItemId));
inventJournalTrans.Qty = _TIDMaterialSupportLines.Qty * -1;
// inventJournalTrans.InventDimId = _TIDMaterialSupportLines.inventDimId; // Remark By Randa
// Add By Randa
inventDim.InventLocationId = _TIDMaterialSupportLines.InventLocationId;
inventDim.InventSiteId = InventLocation::find(_TIDMaterialSupportLines.InventLocationId).InventSiteId;
inventDim = InventDim::findOrCreate(inventDim);
inventJournalTrans.InventDimId = inventDim.inventDimId;
// End Added By Randa
inventJournalTrans.insert();
//Below code for update material status lines
_TIDMaterialSupportLines.selectForUpdate();
// _TIDMaterialSupportLines.DocRefNumber = inventJournalTrans.JournalId; // Remark By Randa
_TIDMaterialSupportLines.JournalRefNumber = inventJournalTrans.JournalId; // Add By Randa
//_TIDMaterialSupportLines.TIDMaterialSupportLineStatus = TIDMaterialSupportLineStatus::Partial; // Remark By Randa
_TIDMaterialSupportLines.DocRefRecId = inventJournalTrans.RecId;
_TIDMaterialSupportLines.update();
info(strFmt('Create journal line for item %1 ',inventJournalTrans.ItemId));
}
private void createJournalLine(InventJournalTable inventJournalTable,TIDMaterialSupportLines _TIDMaterialSupportLines)
{
InventJournalTrans inventJournalTrans;
InventJournalNameId inventJournalName;
InventDim inventDim;
//Below code creates journal lines
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.ItemId = _TIDMaterialSupportLines.ItemId;
inventJournalTrans.initFromInventTable(InventTable::find(_TIDMaterialSupportLines.ItemId));
inventJournalTrans.Qty = _TIDMaterialSupportLines.Qty * -1;
// inventJournalTrans.InventDimId = _TIDMaterialSupportLines.inventDimId; // Remark By Randa
// Add By Randa
inventDim.InventLocationId = _TIDMaterialSupportLines.InventLocationId;
inventDim.InventSiteId = InventLocation::find(_TIDMaterialSupportLines.InventLocationId).InventSiteId;
inventDim = InventDim::findOrCreate(inventDim);
inventJournalTrans.InventDimId = inventDim.inventDimId;
// End Added By Randa
inventJournalTrans.insert();
//Below code for update material status lines
_TIDMaterialSupportLines.selectForUpdate();
// _TIDMaterialSupportLines.DocRefNumber = inventJournalTrans.JournalId; // Remark By Randa
_TIDMaterialSupportLines.JournalRefNumber = inventJournalTrans.JournalId; // Add By Randa
//_TIDMaterialSupportLines.TIDMaterialSupportLineStatus = TIDMaterialSupportLineStatus::Partial; // Remark By Randa
_TIDMaterialSupportLines.DocRefRecId = inventJournalTrans.RecId;
_TIDMaterialSupportLines.update();
info(strFmt('Create journal line for item %1 ',inventJournalTrans.ItemId));
}
1 comments:
I always spent my half an hour to read this weblog's articles all the time along with a mug of coffee.
Post a Comment