Hi Experts,
I want to write a code in X in MAP- InventInventoryJournalEntryMap in method -setJournalNumber with following condition.
1- If the JournalType = Movement and “Original journal No.” field has value.
2- If the existing Journal is “blocked” by system or any user.
If any condition fulfilled then a new journal movement will be created.
I have written a code for this but getting error.[ExtensionOf(mapstr(InventInventoryJournalEntryMap))]
public final class CreateInventoryMomentJournal_CAP_Extension
{
public static void setJournalNumber( InventJournalType _expectedJournalType,int64 _approxNumberOfLines = 1000)
{
// next setJournalNumber();
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventJournalNameId inventJournalNameId;
InventJournalName inventJournalName;
InventDim inventDim;
DimensionAttributeValueCombination dimAttrValueCombo;
JournalCheckPost journalCheckPost;
int numOfLines = 0;
select forupdate inventJournalTable
where inventJournalTable.JournalType == InventJournalType::Movement && inventJournalTable.JournalIdOrignal
|| inventJournalTable.SystemBlocked == true;
if (inventJournalTable)
// if (( inventJournalTable.JournalType == InventJournalType::Movement && inventJournalTable.JournalIdOrignal ) || inventJournalTable.SystemBlocked == true)
{
ttsbegin;
inventJournalTable.clear();
inventJournalNameId = InventJournalName::standardJournalName(InventJournalType::Movement);
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalNameId));
inventJournalTable.insert();
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemDateGet();
inventJournalTrans.ItemId = '1000';
inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId));
inventJournalTrans.Qty = 1;
inventdim.InventSiteId = '1';
inventdim.InventLocationId = '11';
inventJournalTrans.InventDimId = InventdIm::findOrCreate(inventDim).inventDimId;
dimAttrValueCombo.clear();
select firstonly RecId from dimAttrValueCombo
where dimAttrValueCombo.MainAccount == MainAccount::findByMainAccountId("110110").RecId
&& dimAttrValueCombo.DisplayValue == '110110';
inventJournalTrans.LedgerDimension = dimAttrValueCombo.RecId;
if(inventJournalTrans.Qty > 0)
{
numOfLines ;
inventJournalTrans.insert();
}
inventJournalTable.NumOfLines = numOfLines;
inventJournalTable.update();
ttscommit;
info(strFmt("Movement Journal ID: %1", inventJournalTable.JournalId));
}
// journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
//journalCheckPost.run();
}
}
Hi,
I think the message is rather clear. The method you extend is not a static method but in your extension it is static. Hence I think ou need to remove static key.
public static(remove) void setJournalNumber
Hi HARISH,
For the error message, the COC method must have the final keyword, and the Wrapper methods must always call next method, I think you need to read Microsoft Doc carefully.
André Arnaud de Cal...
292,031
Super User 2025 Season 1
Martin Dráb
230,868
Most Valuable Professional
nmaenpaa
101,156