Calling report using menu item (args.record(namatable)) in x++ :
void clicked()
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventDim localInventDim;
CustInvoiceTrans custInvoiceTrans;
TECCustInOutClaimTable localTECCustInOutClaimTable;
TECCustInOutClaimLine localTECCustInOutClaimLine, CustInOutClaimLine;
RetailTransactionSalesTrans retailTransactionSalesTrans;
InventJournalCheckPost journalCheckPost;
Args args = new Args();
;
super();
TECCustInOutClaimLine_ds.write();
select firstOnly inventJournalTable
where inventJournalTable.TECCustInClaimLineRefRecId == TECCustInOutClaimLine.RecId;
if (!inventJournalTable)
{
inventJournalTable.clear();
inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TECCustInClaimJournalNameId));
inventJournalTable.insert();
select firstOnly localTECCustInOutClaimTable
where localTECCustInOutClaimTable.RecId == TECCustInOutClaimLine.TECCustInOutClaimTableRefRecId;
select firstOnly retailTransactionSalesTrans
where retailTransactionSalesTrans.receiptId == localTECCustInOutClaimTable.RetailReceiptId
&& retailTransactionSalesTrans.ItemId == TECCustInOutClaimLine.ItemId;
localInventDim.clear();
// localInventDim.InventSiteId = custInvoiceTrans.inventSiteId();
// localInventDim.InventLocationId = custInvoiceTrans.inventLocationId();
// localInventDim.inventDimId = retailTransactionSalesTrans.inventDimId;
// localInventDim = InventDim::findOrCreate(localInventDim);
while select CustInOutClaimLine
where CustInOutClaimLine.TECCustInOutClaimTableRefRecId == TECCustInOutClaimLine.TECCustInOutClaimTableRefRecId
{
ttsBegin;
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.initFromInventTable(InventTable::find(CustInOutClaimLine.ItemId));
inventJournalTrans.InventDimId = InventDim.inventDimId;
inventJournalTrans.Qty = TECCustInOutClaimLine.SalesQty;
inventJournalTrans.CostPrice = retailTransactionSalesTrans.price;
inventJournalTrans.CostAmount = inventJournalTrans.Qty * inventJournalTrans.CostPrice;
inventJournalTrans.DefaultDimension = getNewDefaultDimensionTEC(InventTable::find(CustInOutClaimLine.ItemId).DefaultDimension, "1. STORE", StorageDimensions_InventLocationId.valueStr());
inventJournalTrans.insert();
ttsCommit;
}
info(strFmt('Claim in movement journal: %1 has been created.', inventJournalTable.JournalId));
while select forUpdate localTECCustInOutClaimLine
//where localTECCustInOutClaimLine.TECCustInOutClaimTableRefRecId == TECCustInOutClaimLine.TECCustInOutClaimTableRefRecId
where localTECCustInOutClaimLine.RecId == TECCustInOutClaimLine.RecId
{
ttsBegin;
localTECCustInOutClaimLine.ClaimInJournalId = inventJournalTable.JournalId;
localTECCustInOutClaimLine.TECClaimInStatus = TECClaimInStatus::Received;
// add by Tyo -(79 OPERATION - Sales return, Trade In dan Claim supplier In: - Harus ada siapa yang terima di gudang)
localTECCustInOutClaimLine.TIDReceiptPerson = curUserId();
// end by Tyo
localTECCustInOutClaimLine.update();
ttsCommit;
}
}
if (inventJournalTable.Posted == NoYes::No)
{
journalCheckPost = new InventJournalCheckPost();
if (InventJournalCheckPost::newPostJournal(inventJournalTable).validate())
InventJournalCheckPost::newPostJournal(inventJournalTable).run();
info(strFmt('Claim in movement journal: %1 has been posted.', inventJournalTable.JournalId));
}
if (TECCustInOutClaimLine.IsDelivery == NoYes::Yes)
{
element.PostDOWithdrawal(inventJournalTable.JournalId);
}
TECCustInOutClaimLine_ds.executeQuery();
//args.record(inventJournalTable);
//new MenuFunction(MenuItemDisplayStr(CustFreeInvoice), MenuItemType::Display).run(args);
// add by tyo - create picking list report
args.record(TECCustInOutClaimLine);
new MenuFunction(menuitemOutputStr(TECPickingList), MenuItemType::Output).run(Args);
// end by tyo - create picking list report
}
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventDim localInventDim;
CustInvoiceTrans custInvoiceTrans;
TECCustInOutClaimTable localTECCustInOutClaimTable;
TECCustInOutClaimLine localTECCustInOutClaimLine, CustInOutClaimLine;
RetailTransactionSalesTrans retailTransactionSalesTrans;
InventJournalCheckPost journalCheckPost;
Args args = new Args();
;
super();
TECCustInOutClaimLine_ds.write();
select firstOnly inventJournalTable
where inventJournalTable.TECCustInClaimLineRefRecId == TECCustInOutClaimLine.RecId;
if (!inventJournalTable)
{
inventJournalTable.clear();
inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TECCustInClaimJournalNameId));
inventJournalTable.insert();
select firstOnly localTECCustInOutClaimTable
where localTECCustInOutClaimTable.RecId == TECCustInOutClaimLine.TECCustInOutClaimTableRefRecId;
select firstOnly retailTransactionSalesTrans
where retailTransactionSalesTrans.receiptId == localTECCustInOutClaimTable.RetailReceiptId
&& retailTransactionSalesTrans.ItemId == TECCustInOutClaimLine.ItemId;
localInventDim.clear();
// localInventDim.InventSiteId = custInvoiceTrans.inventSiteId();
// localInventDim.InventLocationId = custInvoiceTrans.inventLocationId();
// localInventDim.inventDimId = retailTransactionSalesTrans.inventDimId;
// localInventDim = InventDim::findOrCreate(localInventDim);
while select CustInOutClaimLine
where CustInOutClaimLine.TECCustInOutClaimTableRefRecId == TECCustInOutClaimLine.TECCustInOutClaimTableRefRecId
{
ttsBegin;
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.initFromInventTable(InventTable::find(CustInOutClaimLine.ItemId));
inventJournalTrans.InventDimId = InventDim.inventDimId;
inventJournalTrans.Qty = TECCustInOutClaimLine.SalesQty;
inventJournalTrans.CostPrice = retailTransactionSalesTrans.price;
inventJournalTrans.CostAmount = inventJournalTrans.Qty * inventJournalTrans.CostPrice;
inventJournalTrans.DefaultDimension = getNewDefaultDimensionTEC(InventTable::find(CustInOutClaimLine.ItemId).DefaultDimension, "1. STORE", StorageDimensions_InventLocationId.valueStr());
inventJournalTrans.insert();
ttsCommit;
}
info(strFmt('Claim in movement journal: %1 has been created.', inventJournalTable.JournalId));
while select forUpdate localTECCustInOutClaimLine
//where localTECCustInOutClaimLine.TECCustInOutClaimTableRefRecId == TECCustInOutClaimLine.TECCustInOutClaimTableRefRecId
where localTECCustInOutClaimLine.RecId == TECCustInOutClaimLine.RecId
{
ttsBegin;
localTECCustInOutClaimLine.ClaimInJournalId = inventJournalTable.JournalId;
localTECCustInOutClaimLine.TECClaimInStatus = TECClaimInStatus::Received;
// add by Tyo -(79 OPERATION - Sales return, Trade In dan Claim supplier In: - Harus ada siapa yang terima di gudang)
localTECCustInOutClaimLine.TIDReceiptPerson = curUserId();
// end by Tyo
localTECCustInOutClaimLine.update();
ttsCommit;
}
}
if (inventJournalTable.Posted == NoYes::No)
{
journalCheckPost = new InventJournalCheckPost();
if (InventJournalCheckPost::newPostJournal(inventJournalTable).validate())
InventJournalCheckPost::newPostJournal(inventJournalTable).run();
info(strFmt('Claim in movement journal: %1 has been posted.', inventJournalTable.JournalId));
}
if (TECCustInOutClaimLine.IsDelivery == NoYes::Yes)
{
element.PostDOWithdrawal(inventJournalTable.JournalId);
}
TECCustInOutClaimLine_ds.executeQuery();
//args.record(inventJournalTable);
//new MenuFunction(MenuItemDisplayStr(CustFreeInvoice), MenuItemType::Display).run(args);
// add by tyo - create picking list report
args.record(TECCustInOutClaimLine);
new MenuFunction(menuitemOutputStr(TECPickingList), MenuItemType::Output).run(Args);
// end by tyo - create picking list report
}
0 comments:
Post a Comment