Number Series How To
  • 16 Apr 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Number Series How To

  • Dark
    Light

Article summary


Number Series

Number series are a way to generate numbers for data transaction and are widely used in the Comactivity Supply Chain Suite.

The function includes a setup of number series and an API to retrieve the next number.

The setup is done in the menu under System Administration/Application Settings. See example below.

The tables and columns for number series are in Rep_CACORE (and more lately also in the ComActivityBASE project, but still in metadataid CACORE), which is the intended place for them in the future.

The API for retrieving values from a number series is net.comactivity.core.applications.services.NumberSeriesService and it is found in project net.comactivity.core.

Examples

Example 1: Getting a package number from number series:

cid:8DE53550-3905-49C6-9EAD-D6E1C3543B0C@comactivity.net

cid:0CA012A2-F182-4A4C-B239-333868F20053@comactivity.net

Using the API:

public class PackagingReportStartNewPacking extends AbstractRule {

...

public static int retrieveNewPackageNo(LogicalUnitOfWork luow) {


        try {

// Retrieve next Package Number from number serie 650 

NumberSeriesService ns = (NumberSeriesService) SystemWorkspace.getApplicationService("NumberSeriesService");

String enterprise = luow.getSessionValues().getValue("Enterprise");

NumberSeries nsPackageNo = ns.getNumberSeries(enterprise, "650");

int packageNo = ns.getNextNumber(enterprise, nsPackageNo, null, null);


return packageNo;


        } catch (Exception e) {

        AppErr.handleException(luow, PackageHeader.class, e);

            return 0;

        }


}

Example: 

Retrieving a new invoice number for an invoice within the Supply Chain Suite, controlled by Company and by Sales order category (0 = Normal invoice, 1= Credit, 8 = Internal invoice, 9 = Distribution Order):

cid:8D5F662F-D926-4D44-9606-2372A364C77B@comactivity.net

cid:B4A85F0C-915D-44CB-BCAC-FC8B7CF68A73@comactivity.net

You can see from the above that the intention is that company 001 invoices range from 1-1999999, company 002 from 2000000 to 2999999 and company 004 from 4000000 to 4999999, and within these ranges there are subranges to easily distinguish different kinds of invoices.

When I set the  number series up like this it also means I need to pass more paremeters into the interface, which is illustrated below.

public class SalesOrderInvoicingRunImpl extends ApplicationService implements SalesOrderInvoicingRun {

...

// Use right number series for sales invoice number

numberserie = NoSeriesHeader.NOSERIESID_SALES_INVOICE;


try {

value1 = sotype.getCompany();

String value2 = String.valueOf(sotype.getSOCategory());

salesInvoiceNo = NoSeriesHeader.getNewOrderNumber(salesDeliveryHeader.getEnterprise(), numberserie, value1, value2);

} catch (ApplicationException err) {

// no invoice number found, terminate

ApplicationError numberSeriesError = null;

if (err.getCAError() instanceof ApplicationError) {

numberSeriesError = (ApplicationError) err.getCAError();

AppErr.handleException(env, getClass(), numberSeriesError);

else {

AppErr.handleException(env, getClass(), "Number series error: " + numberserie);

}

error = true;

}

Note: The number series component itself never operates under commit control since this would create a bottleneck in the system. Which of course does not stop you to invoke from within a database transaction with commit control - but also if you end rolling back, that number series will be consumed.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.