Loading...

Number sequences in F&O: why yours is about to break

Number sequences look trivial until yours stops handing out numbers mid-month and order entry grinds to a halt. Four failure modes that surface in production F&O environments, and the NumberSeqApplicationModule extension pattern that avoids them.

Number sequences in F&O: why yours is crashing and how to fix it

Sales-order numbers. Invoice numbers. Customer IDs. Every transaction-entry screen in F&O is quietly calling a number sequence to get the next value. The machinery works invisibly well for years - until one Tuesday morning, a team starts seeing "number sequence is out of range" errors and the order desk stops taking orders.

The failure modes aren't mysterious. They trace back to decisions made at setup time that nobody remembers. Four specific patterns show up in production F&O environments often enough to document.

Mode 1: scope set too narrow, sequence exhausts

A sequence scoped per-company-per-fiscal-year with a 6-digit format maxes at 999,999 per year. For high-volume enterprises (thousands of orders per day), that ceiling hits in month 11 or 12. When it does, saves fail.

Fix: check the scope. For very high volumes, use "Company" scope (no yearly reset) and increase format length. Audit every sequence in NumberSequenceTable periodically to catch pending exhaustion - a quarterly sweep is the minimum hygiene.

Mode 2: pre-allocation clogs

F&O pre-allocates number-sequence ranges to the AOS server for performance - the batch server grabs a range of 100 numbers at a time, hands them out, and allocates the next range when it runs out. If an AOS crashes without releasing its allocation, those numbers are effectively gone.

Over months, accumulated unreleased allocations push "last used" ahead of actual usage by thousands. Fine until it stacks against the narrow-scope issue above.

Fix: the scheduled NumberSequenceCleanUpTask runs cleanup. Default cadence is daily; for stress-tested sequences, bump to every 15 minutes. Adjust under System administration > Inquiries > Number sequence > Clean up.

Mode 3: legal-entity-scoped sequence, cross-company transaction

A transaction touching two legal entities tries to allocate a sequence scoped to Legal Entity A. Works fine if the transaction initiates from A. Fails on intercompany postings initiated from B where the sequence wasn't configured there.

Fix: ensure sequences exist in all LEs that might originate the transaction, or widen the scope. A test script that validates every sequence for every possible originating LE is cheap to run and prevents the whole class of bug.

Mode 4: sequence not registered on module extension

Custom module has a custom sequence referenced in code via NumberSeqReferenceMyModule::numRefMyCustomSeq(). Works in dev. In production, the reference is empty, so .num() returns blank and transactions save with no identifier.

Fix: the NumberSeqApplicationModule extension wasn't deployed to production, or the "Load references" batch wasn't run post-deploy.

The NumberSeqApplicationModule extension pattern

For custom modules that need their own sequences:

Three things have to line up:

  1. The loadModules method is called when the "Load references" wizard runs (System administration > Setup > Number sequences > Generate wizard).
  2. The datatype parameters define the scope the sequence supports and the UI wizard display.
  3. The EDT (MyCustomId here) has IsExtended = Yes and extends Num or similar base EDT.

After the class is deployed to the target environment, an administrator runs the Generate wizard, which detects the new reference and prompts creation or selection of a sequence to fill it.

Recovering from a dead sequence

When a sequence has run out and order entry is frozen:

  1. Immediate: In NumberSequenceTable, find the sequence. Increase the Largest field or add a new range for range-based sequences. Transactions save again.
  2. Short term: Reconfigure scope or format. If yearly-reset hit the max, switch to non-resetting and reset to something safe like 100001 to avoid collision.
  3. Post-mortem: Why didn't monitoring catch this? Add an alert: daily query joining NumberSequenceList with allocations, flagging sequences within 10% of max.

Scoping decision matrix

A default matrix for new custom sequences:

Transaction typeScopeFormatSales order, purchase orderCompany8-digit numericCustomer, vendor masterCompany6-char alphanumeric prefix + 6 digitsInvoicesCompany + fiscal year8-digit numericIntercompanyShared (no company scope)Prefixed with LE code

Company scope unless there's a legal requirement to reset yearly. 8-digit formats on high-volume sequences. Alphanumeric prefixes on master data for human readability.

The quarterly audit script

Run every quarter against the live environment:

Anything over 80% usage goes on the remediation list. This is the discipline that separates stable sequence hygiene from a Saturday outage.

What healthy looks like

An F&O environment with clean number-sequence hygiene has: documented scope decisions, cleanup batch running every 15 minutes, quarterly capacity audit in the ops runbook, monitoring alert at 80%. The scaffolding is boring. The alternative is the Tuesday morning phone call.

Contact Us Now

Share Your Story

We build trust by delivering what we promise – the first time and every time!

We'd love to hear your vision. Our IT experts will reach out to you during business hours to discuss making it happen.

WHY CHOOSE US

"Collaborate, Elevate, Celebrate where Associates - Create Project Excellence"

SapotaCorp beyond the IT industry standard, we are

  • Certificated
  • Assured quality
  • Extra maintenance

Tell us about your project

close