Get number sequence for EDT or parameter

The first example is the ‘normal’ method for getting the number sequence for normal parameters. All you need to now is the parameters table in which the sequence parameter hide:

static void getNumberSequenceForParameter(Args _args)
{
     NumberSeq num;
     InventJournalTable  inventJournalTable; //Table Buffer
      
     ttsbegin;
     num = NumberSeq::newGetNum(InventParameters::numRefJournalNum());
     inventJournalTable.journalId= num.num(); // Generated sequence
     inventJournalTable.insert();
     num.used(); // Set number to used
     ttscommit;
}

The other way is to find the sequence by an EDT:

static void getNumberSequenceForEDT(Args _args)
{
     InventJournalTable  inventJournalTable; //Table Buffer
     InventJournalId inventJournalId;
     ExtendedTypeId edtId= extendedTypeNum(inventJournalId); 
     NumberSeq num = NumberSeq::newGetNum(NumberSequenceReference::find(edtId));
     ;
     ttsbegin;
     inventJournalTable.journalId= num.num(); // Generated sequence
     inventJournalTable.insert();
     num.used(); // Set number to used
     ttscommit;
}

Special for InventJournalTable

InventJournalTableData journalTableData = new InventJournalTableData(inventJournalTable);
NumberSequenceReference reference = journalTableData.journalStatic().numRefJournalId();
NumberSeq num = NumberSeq::newGetNum(reference);

Leave a Comment