一些生产业务需要产生相应的转移日记账,这里写一个转移日记账的创建方法
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; ; //日记账名称表 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.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_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();}
转载于:https://www.cnblogs.com/Kurodo/archive/2011/08/23/2150459.html