// Steps to create and Post a BOM journal through X++
void clicked()
{
InventJournalTable journalTable ;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventJournalNameId inventJournalName;
InventTransId num;
InventJournalVoucherId numV;
ComboBOMHeader Header;
Filename filename;
NumberSeq numberSeq,numberSeq1;
ComboBOMLine line;
InventDim inventDim;
Dialog dialog;
DialogField dlgfeild;
str a;
InventJournalCheckPost journalCheckPost;// = new InventJournalCheckPost();
int L = 10;
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
//
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalNameId = InventParameters::find().BOMJournalNameId;
journalTable.JournalType = InventJournalType::BOM;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTable.insert();
journalTrans.clear();
journalTrans.JournalId = journalTable.JournalId;
journalTrans.JournalType = InventJournalType::BOM;
numberSeq1 = NumberSeq::newGetNum(InventParameters::numRefInventJournalVoucherId());
numV = numberSeq1.num();
journalTrans.Voucher = numV;
journalTransData.initFromJournalTable();
dialog = new Dialog();
dlgfeild = dialog.addField(extendedTypeStr(BOMId));
dialog.run();
filename = dlgfeild.value();
select line where line.bomid == filename;
{
journalTrans.LineNum = L;
journalTrans.TransDate = systemdateget();
numberSeq = NumberSeq::newGetNum(Inventparameters::numRefInventTransId());
num = numberSeq.num();
journalTrans.InventTransId = num;
journalTrans.InventTransIdFather = '00162615_068';
journalTrans.ItemId =line.ItemId;
journalTrans.CostAmount = line.CostPrice;
// Dimension details
inventDim.configId = 'HD';
inventDim.InventSizeId ='42';
inventDim.InventColorId ='01';
inventDim.InventSiteId ='1';
inventDim.InventLocationId = '11';
inventDim.inventBatchId = '1001';
//inventDim.wMSLocationId = '11';
journalTrans.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
journalTrans.BOMLine = true;
//journalTransData.create();
journalTrans.insert();
//L += 10;
}
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
InventJournalCheckPost::newPostJournal(journalTable).run();
}
// for Multiple lines
error
void clicked()
{
InventJournalTable journalTable ;
InventJournalTrans journalTrans,inventJournalTransAssembly;
InventTransOrigin inventTransOrigin;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventJournalNameId inventJournalName;
InventTransId inventtransid;
InventTransId num;
InventJournalVoucherId numV;
ComboBOMHeader Header;
Filename filename;
NumberSeq numberSeq,numberSeq1;
ComboBOMLine line;
InventDim inventDim;
Dialog dialog;
DialogField dlgfeild;
str a;
InventJournalCheckPost journalCheckPost;// = new InventJournalCheckPost();
int L = 10;
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
//
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalNameId = InventParameters::find().BOMJournalNameId;
journalTable.JournalType = InventJournalType::BOM;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTable.insert();
journalTrans.clear();
journalTrans.JournalId = journalTable.JournalId;
journalTrans.JournalType = InventJournalType::BOM;
numberSeq1 = NumberSeq::newGetNum(InventParameters::numRefInventJournalVoucherId());
numV = numberSeq1.num();
journalTrans.Voucher = numV;
journalTransData.initFromJournalTable();
dialog = new Dialog();
dlgfeild = dialog.addField(extendedTypeStr(BOMId));
dialog.run();
filename = dlgfeild.value();
while select line where line.bomid == filename
{
journalTrans.LineNum = L;
journalTrans.TransDate = systemdateget();
numberSeq = NumberSeq::newGetNum(Inventparameters::numRefInventTransId());
num = numberSeq.num();
//journalTrans.InventTransId = num;
journalTrans.ItemId =line.ItemId;
if( L <= 10)
{
journalTrans.InventTransId = num;
journalTrans.BOMLine = false;
journalTrans.Qty = line.qty;
}
if(L > 11)
{
journalTrans.BOMLine = true;
inventJournalTransAssembly = InventJournalTrans::findInventTransId(num);
//select InventTransId from journalTrans where journalTrans.InventTransId == inventTransOrigin.InventTransId
//&& inventTransOrigin.InventTransId == num;
//
//journalTrans.InventTransIdFather = num;
journalTrans.Qty = -(line.qty);
//info(strFmt("%1",journalTrans.Qty));
}
journalTrans.CostAmount = line.CostPrice;
// Dimension details
inventDim.configId = '';
inventDim.InventSizeId ='02';
inventDim.InventColorId ='';
inventDim.InventSiteId ='1';
inventDim.InventLocationId = '11';
inventDim.inventBatchId = '1001';
//inventDim.wMSLocationId = '11';
journalTrans.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
//journalTrans.BOMLine = true;
//journalTransData.create();
journalTrans.insert();
L += 10;
}
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
InventJournalCheckPost::newPostJournal(journalTable).run();
}
void clicked()
{
InventJournalTable journalTable ;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventJournalNameId inventJournalName;
InventTransId num;
InventJournalVoucherId numV;
ComboBOMHeader Header;
Filename filename;
NumberSeq numberSeq,numberSeq1;
ComboBOMLine line;
InventDim inventDim;
Dialog dialog;
DialogField dlgfeild;
str a;
InventJournalCheckPost journalCheckPost;// = new InventJournalCheckPost();
int L = 10;
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
//
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalNameId = InventParameters::find().BOMJournalNameId;
journalTable.JournalType = InventJournalType::BOM;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTable.insert();
journalTrans.clear();
journalTrans.JournalId = journalTable.JournalId;
journalTrans.JournalType = InventJournalType::BOM;
numberSeq1 = NumberSeq::newGetNum(InventParameters::numRefInventJournalVoucherId());
numV = numberSeq1.num();
journalTrans.Voucher = numV;
journalTransData.initFromJournalTable();
dialog = new Dialog();
dlgfeild = dialog.addField(extendedTypeStr(BOMId));
dialog.run();
filename = dlgfeild.value();
select line where line.bomid == filename;
{
journalTrans.LineNum = L;
journalTrans.TransDate = systemdateget();
numberSeq = NumberSeq::newGetNum(Inventparameters::numRefInventTransId());
num = numberSeq.num();
journalTrans.InventTransId = num;
journalTrans.InventTransIdFather = '00162615_068';
journalTrans.ItemId =line.ItemId;
journalTrans.CostAmount = line.CostPrice;
// Dimension details
inventDim.configId = 'HD';
inventDim.InventSizeId ='42';
inventDim.InventColorId ='01';
inventDim.InventSiteId ='1';
inventDim.InventLocationId = '11';
inventDim.inventBatchId = '1001';
//inventDim.wMSLocationId = '11';
journalTrans.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
journalTrans.BOMLine = true;
//journalTransData.create();
journalTrans.insert();
//L += 10;
}
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
InventJournalCheckPost::newPostJournal(journalTable).run();
}
// for Multiple lines
error
void clicked()
{
InventJournalTable journalTable ;
InventJournalTrans journalTrans,inventJournalTransAssembly;
InventTransOrigin inventTransOrigin;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventJournalNameId inventJournalName;
InventTransId inventtransid;
InventTransId num;
InventJournalVoucherId numV;
ComboBOMHeader Header;
Filename filename;
NumberSeq numberSeq,numberSeq1;
ComboBOMLine line;
InventDim inventDim;
Dialog dialog;
DialogField dlgfeild;
str a;
InventJournalCheckPost journalCheckPost;// = new InventJournalCheckPost();
int L = 10;
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
//
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalNameId = InventParameters::find().BOMJournalNameId;
journalTable.JournalType = InventJournalType::BOM;
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTable.insert();
journalTrans.clear();
journalTrans.JournalId = journalTable.JournalId;
journalTrans.JournalType = InventJournalType::BOM;
numberSeq1 = NumberSeq::newGetNum(InventParameters::numRefInventJournalVoucherId());
numV = numberSeq1.num();
journalTrans.Voucher = numV;
journalTransData.initFromJournalTable();
dialog = new Dialog();
dlgfeild = dialog.addField(extendedTypeStr(BOMId));
dialog.run();
filename = dlgfeild.value();
while select line where line.bomid == filename
{
journalTrans.LineNum = L;
journalTrans.TransDate = systemdateget();
numberSeq = NumberSeq::newGetNum(Inventparameters::numRefInventTransId());
num = numberSeq.num();
//journalTrans.InventTransId = num;
journalTrans.ItemId =line.ItemId;
if( L <= 10)
{
journalTrans.InventTransId = num;
journalTrans.BOMLine = false;
journalTrans.Qty = line.qty;
}
if(L > 11)
{
journalTrans.BOMLine = true;
inventJournalTransAssembly = InventJournalTrans::findInventTransId(num);
//select InventTransId from journalTrans where journalTrans.InventTransId == inventTransOrigin.InventTransId
//&& inventTransOrigin.InventTransId == num;
//
//journalTrans.InventTransIdFather = num;
journalTrans.Qty = -(line.qty);
//info(strFmt("%1",journalTrans.Qty));
}
journalTrans.CostAmount = line.CostPrice;
// Dimension details
inventDim.configId = '';
inventDim.InventSizeId ='02';
inventDim.InventColorId ='';
inventDim.InventSiteId ='1';
inventDim.InventLocationId = '11';
inventDim.inventBatchId = '1001';
//inventDim.wMSLocationId = '11';
journalTrans.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
//journalTrans.BOMLine = true;
//journalTransData.create();
journalTrans.insert();
L += 10;
}
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
InventJournalCheckPost::newPostJournal(journalTable).run();
}
No comments:
Post a Comment