Get the Number Sequence through X++
//This following code to get the number sequece by using code.
//this following example describe to get purchID and ProjJournalID
ProjJournalTable _projJournalTable;
PurchTable _PurchTable;
_projJournalTable.JournalId = NumberSeq::newGetNum(ProjParameters::numRefProjJournalId()).num();
_PurchTable.PurchId = NumberSeq::newGetNum(PurchParameters::numRefPurchId()).num();
Found here: http://axhelper.blogspot.dk/2011/10/get-number-sequence-through-x.html