How to get the last sequence number through code?

By | September 29, 2015

We all know how to generate the sequence number through code. Suppose if we want to know the last generated sequence number with the same parameter which we used to generate it.

New Stuff: How to get ascii value of any char

In order to retrieve the last generated sequence number through code with X3 action (NUMERO_PREC). Here the parameters and its definition with example input & outputs for the same.


The first 4 parameters are made for input for the standard X3 sequence generation. And next 3 parameters are the output.

Parameter Definition
Char COMPTEUR Sequence Number Counter name
Char SIT Site
Char DAT Date
Char COMP Value of the additional field
Char NUMERO Sequence Number Counter value
Integer SEQ Sequence Number
Integer STAT Error status(0=OK, else error)

Sample code:

The below screen shot is represented with valid parameter to retrieve the last generated sequence number by the standard x3 Sequence generation.


The Output will be,

Description Output
NUMERO ‘000000025’
SEQ 25

Note: This action will not increase the sequence number which is an advantage to use this below action.

About Us
Greytrix – a globally recognized Premier Sage Gold Development Partner is a one-stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development and implementation expertise.

Greytrix caters to a wide range of Sage Enterprise Management (Sage X3) offerings – a Sage Business Cloud Solution. Our unique GUMU™ integrations include Sage Enterprise Management (Sage X3) for Sage and Magento eCommerce along with Implementation and Technical Support worldwide for Sage Enterprise Management (Sage X3). Currently we are Sage Enterprise Management Implementation Partner in East Africa, Middles East, Australia, Asia. We also offer best-in-class Sage X3 customization and development services, integrated applications such as POS | WMS | Payment Gateway | Shipping System | Business Intelligence | eCommerce and have developed add-ons such as Catch – Weight  and Letter of Credit for Sage Enterprise Management to Sage business partners, end users and Sage PSG worldwide.

Greytrix is a recognized Sage Rockstar ISV Partner for GUMU™ Sage Enterprise Management – Sage CRM integration also listed on Sage Marketplace; GUMU™ integration for Sage Enterprise Management – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information on Sage X3 Integration and Services, please contact us at We will be glad to assist you.