
Hi Experts,
I want to create picklist journal through code in D365 and also I want to create this through release button of the production order.
Also generate the print picklist report.
Please suggest the right path to achieve the same.
Regards
Sona Jee
Hi Sona,
Check the following code:
static void PickingListJournal(Args _args)
{
ProdJournalTable prodJournalTable;
ProdJournalBOM prodJournalBOM;
ProdTable prodTable = prodTable::find("POnumber");
prodJournalTable.clear();
prodJournalTable.initValue();
prodJournalTable.JournalType = ProdJournalType::Picklist;
prodJournalTable.JournalNameId = "nameid";
prodJournalTable.Description = "Description";
prodJournalTable.ProdId = prodTable.ProdId;
prodJournalTable.VoucherDraw = JournalVoucherDraw::Post;
prodJournalTable.VoucherSeqRecId = NumberSequenceTable::find(ProdParameters::numRefProdJournalVoucherId().NumberSequenceId).RecId;
prodJournalTable.insert();
prodJournalBOM.clear();
prodJournalBOM.initValue();
prodJournalBOM.JournalId = prodJournalTable.JournalId;
prodJournalBOM.initFromInventTable(InventTable::find("..."));
prodJournalBom.ProdId = prodTable.ProdId;
prodJournalBom.LineNum = 1;
prodJournalBom.InventDimId = "...";
prodJournalBom.TransDate = systemDateGet();
prodJournalBom.BOMUnitId = "Pcs";
prodJournalBom.BOMConsump = 1;
prodJournalBom.InventConsump = 1;
prodJournalBom.insert();
ttsBegin;
prodJournalTable.selectForUpdate(true);
prodJournalTable.NumOfLines = 1;
prodJournalTable.update();
ttsCommit;
info(strFmt("Journal %1 created",prodJournalTable.JournalId));
}
You could check the standard code in the createProdPickingListJournal method in the WHSProductionScrapHistory table.