AX 2009 库存转移日记账
转移日记账
一些生产业务需要产生相应的转移日记账,这里写一个转移日记账的创建方法
void clicked()
{
MapIterator m_mapItor;
ModelApplyTable ModelApplyList,m_Model;
InventJournalTable m_InvJourT;
InventJournalTrans m_InvJourTrans;
InventJournalName m_InvJourName;
InventLocationId m_LocatId;
ProdTable m_Prod;
List list = new List(Types::Record);
ListIterator listItor;
JournalTableData JournalTableData;
InventDim dim;
;
{
MapIterator m_mapItor;
ModelApplyTable ModelApplyList,m_Model;
InventJournalTable m_InvJourT;
InventJournalTrans m_InvJourTrans;
InventJournalName m_InvJourName;
InventLocationId m_LocatId;
ProdTable m_Prod;
List list = new List(Types::Record);
ListIterator listItor;
JournalTableData JournalTableData;
InventDim dim;
;
//日记账名称表
m_InvJourName = InventJournalName::find("C_MOD_01");
m_InvJourName = InventJournalName::find("C_MOD_01");
//日记账头
m_InvJourT.clear();
m_InvJourT.JournalNameId = m_InvJourName.JournalNameId;
m_InvJourT.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));
JournalTableData = JournalTableData::newTable(m_InvJourT);
m_InvJourT.JournalId = JournalTableData.nextJournalId(); //产生日记账号
m_InvJourT.clear();
m_InvJourT.JournalNameId = m_InvJourName.JournalNameId;
m_InvJourT.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));
JournalTableData = JournalTableData::newTable(m_InvJourT);
m_InvJourT.JournalId = JournalTableData.nextJournalId(); //产生日记账号
m_InvJourT.SystemBlocked = ture; //日记账闭塞锁
m_InvJourT.Posted = true; //过账
m_mapItor = FormMarkupClass.getMapIterator();
while (m_mapItor.more())
{
update_recordset ModelApplyList
setting
ModelClass = ModelClass::Send,
ModelState = ModelState::Send
where ModelApplyList.RecId == m_mapItor.key();
m_InvJourT.Posted = true; //过账
m_mapItor = FormMarkupClass.getMapIterator();
while (m_mapItor.more())
{
update_recordset ModelApplyList
setting
ModelClass = ModelClass::Send,
ModelState = ModelState::Send
where ModelApplyList.RecId == m_mapItor.key();
m_Model = m_mapItor.value();
if(m_LocatId == "")
{
m_LocatId = m_Model.InventLocationId;
}
list.addStart(m_Model);
m_mapItor.next();
}
m_InvJourT.iws_locationid = m_LocatId;
m_InvJourT.insert();
listItor = new ListIterator(list);
info(m_InvJourT.VoucherSeqId);
ttsbegin;
while(listItor.more())
{
m_Model = listItor.value();
//日记账行
m_InvJourTrans.clear();
m_InvJourTrans.initValue();
m_InvJourTrans.initFromInventJournalTable(m_InvJourT);
m_InvJourTrans.ItemId = m_Model.ProdItemId;
m_InvJourTrans.initFromInventTable(InventTable::find(m_Model.ProdItemId));
//源InventDim
m_Prod = ProdTable::find(m_Model.ProdId);
dim = m_Prod.inventDim();
m_InvJourTrans.InventDimId = dim.inventDimId;
//到InventDim
dim = m_InvJourTrans.inventDim();
dim.wMSLocationId = m_Model.wMSLocationIdTwo;
dim = InventDim::findOrCreate(dim);
m_InvJourTrans.ToInventDimId = dim.inventDimId;
m_InvJourTrans.Qty = 1;
if (InventJOurnalName::find(m_InvJourT.JournalNameId).ZeroCostFlag && m_InvJourTrans.CostAmount)
{
m_InvJourTrans.CostPrice = 0;
m_InvJourTrans.CostAmount = 0;
}
m_InvJourTrans.insert();
listItor.next();
}
ttscommit;
Model_DS.executeQuery();
}
m_InvJourTrans.clear();
m_InvJourTrans.initValue();
m_InvJourTrans.initFromInventJournalTable(m_InvJourT);
m_InvJourTrans.ItemId = m_Model.ProdItemId;
m_InvJourTrans.initFromInventTable(InventTable::find(m_Model.ProdItemId));
//源InventDim
m_Prod = ProdTable::find(m_Model.ProdId);
dim = m_Prod.inventDim();
m_InvJourTrans.InventDimId = dim.inventDimId;
//到InventDim
dim = m_InvJourTrans.inventDim();
dim.wMSLocationId = m_Model.wMSLocationIdTwo;
dim = InventDim::findOrCreate(dim);
m_InvJourTrans.ToInventDimId = dim.inventDimId;
m_InvJourTrans.Qty = 1;
if (InventJOurnalName::find(m_InvJourT.JournalNameId).ZeroCostFlag && m_InvJourTrans.CostAmount)
{
m_InvJourTrans.CostPrice = 0;
m_InvJourTrans.CostAmount = 0;
}
m_InvJourTrans.insert();
listItor.next();
}
ttscommit;
Model_DS.executeQuery();
}
作者:Kurodo
出处:http://Kurodo.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://Kurodo.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。