recently i have written a quick code to to post the invent transfer jounral
/// </summary>
/// <returns>
/// Buffer of the <c>InventJournalTable</c> table.
/// </returns>
Public InventJournalTable populateInventJournalTable()
{
InventJournalTable journalTable;
InventJournalTableData journalTableData;
journalTableData = JournalTableData::newTable(journalTable);
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.Reservation = ItemReservation::Automatic;
journalTable.JournalType = InventJournalType::Transfer;
journalTableData.initFromJournalName(journalTableData.JournalStatic().findJournalName(journalTable.journalNameId));
journalTable.Description = InventDescription.valueStr();
journalTable.insert();
return journalTable;
}
/// </summary>
/// <param name="_InventJournalId">
/// <c>JournalId</c> of the <c>InventJournalTable</c>
/// </param>
/// <returns>
/// Buffer of the <c>InventJournalTrans</c> table.
/// </returns>
public InventJournalTrans populateInventJournalTrans(InventJournalId _InventJournalId)
{
InventJournalTrans inventJournalTrans;
InventDim toInventDim;
inventJournalTrans.TransDate = systemdateget();
inventJournalTrans.ItemId = inventSum.ItemId;
inventJournalTrans.Qty = InventQty.realValue();
// Dimensions from which the transfer performs
inventJournalTrans.InventDimId = inventDimLocal.inventDimId;
inventJournalTrans.initFromInventTable(InventTable::find(inventSum.ItemId), False, False);
// Dimensions To which the transfer performs
toInventDim.inventSiteId = InventSite.valueStr();
toInventDim.InventLocationId = InventWareHouse.valueStr();
inventJournalTrans.ToInventDimId = InventDim::findOrCreate(toInventDim).inventDimId;
inventJournalTrans.insert();
return inventJournalTrans;
}
/// <summary>
/// Creates and posts the Inventory Transfer Journal.
/// </summary>
/// <remarks>
/// If there is any exception then the Inventory Journal data is deleted.
/// </remarks>
public void createAndPostJournal()
{
InventJournalTable inventJournalTable;
InventJournalTrans inventjournalTrans;
JournalCheckPost journalCheckPost;
ttsbegin;
// populates the inventJournalTable table
inventJournalTable = element.populateInventJournalTable();
// populates the inventJournalTrans table
inventjournalTrans = element.populateInventJournalTrans(inventJournalTable.JournalId);
ttsCommit;
if (BOX::yesNo('Do you want to post the Journal ? ', DialogButton::Yes) == DialogButton::Yes)
{
// Call the static method to create the journal check post class
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
if(journalCheckPost.validate())
{
try
{
journalCheckPost.run();
}
catch
{
// Deletes the InventJournalTable table, the InventJournalTrans will auto delete because of the Delete actions.
InventJournalTable.delete();
}
}
}
}
/// <summary>
/// Populates the
buffer of the <c>InventJournalTable</c> table data./// </summary>
/// <returns>
/// Buffer of the <c>InventJournalTable</c> table.
/// </returns>
Public InventJournalTable populateInventJournalTable()
{
InventJournalTable journalTable;
InventJournalTableData journalTableData;
journalTable.clear();
journalTable.JournalNameId =
InventParameters::find().QuickTransferJournalNameId;journalTableData = JournalTableData::newTable(journalTable);
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.Reservation = ItemReservation::Automatic;
journalTable.JournalType = InventJournalType::Transfer;
journalTableData.initFromJournalName(journalTableData.JournalStatic().findJournalName(journalTable.journalNameId));
journalTable.Description = InventDescription.valueStr();
journalTable.insert();
return journalTable;
}
/// <summary>
/// Populates the
buffer of the <c>InventJournalTrans</c> table data./// </summary>
/// <param name="_InventJournalId">
/// <c>JournalId</c> of the <c>InventJournalTable</c>
/// </param>
/// <returns>
/// Buffer of the <c>InventJournalTrans</c> table.
/// </returns>
public InventJournalTrans populateInventJournalTrans(InventJournalId _InventJournalId)
{
InventJournalTrans inventJournalTrans;
InventDim toInventDim;
inventJournalTrans.JournalId
= _InventJournalId;
inventJournalTrans.JournalType = InventJournalType::Transfer;inventJournalTrans.TransDate = systemdateget();
inventJournalTrans.ItemId = inventSum.ItemId;
inventJournalTrans.Qty = InventQty.realValue();
// Dimensions from which the transfer performs
inventJournalTrans.InventDimId = inventDimLocal.inventDimId;
inventJournalTrans.initFromInventTable(InventTable::find(inventSum.ItemId), False, False);
// Dimensions To which the transfer performs
toInventDim.inventSiteId = InventSite.valueStr();
toInventDim.InventLocationId = InventWareHouse.valueStr();
inventJournalTrans.ToInventDimId = InventDim::findOrCreate(toInventDim).inventDimId;
inventJournalTrans.insert();
return inventJournalTrans;
}
/// <summary>
/// Creates and posts the Inventory Transfer Journal.
/// </summary>
/// <remarks>
/// If there is any exception then the Inventory Journal data is deleted.
/// </remarks>
public void createAndPostJournal()
{
InventJournalTable inventJournalTable;
InventJournalTrans inventjournalTrans;
JournalCheckPost journalCheckPost;
ttsbegin;
// populates the inventJournalTable table
inventJournalTable = element.populateInventJournalTable();
// populates the inventJournalTrans table
inventjournalTrans = element.populateInventJournalTrans(inventJournalTable.JournalId);
ttsCommit;
if (BOX::yesNo('Do you want to post the Journal ? ', DialogButton::Yes) == DialogButton::Yes)
{
// Call the static method to create the journal check post class
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
if(journalCheckPost.validate())
{
try
{
journalCheckPost.run();
}
catch
{
// Deletes the InventJournalTable table, the InventJournalTrans will auto delete because of the Delete actions.
InventJournalTable.delete();
}
}
}
}