Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

NextNumero

NextNumero([cAlias],[nOrdem],[cNomeCpo],[lSomar],[cVar]) -> cNumero

Obtains a candidate next sequential number.

NextNumeroAdvPL
01 · OVERVIEW

Overview

The historical P8.11/P10 reference describes alias, index order, field, lSomar and cVar. True lSomar returns the next number; false returns cVar if absent or calculates the next if already present. An empty table yields 1 padded to field width. This contract does not document atomic reservation across users. The community sample queries SC7; this adaptation prepares a block without reading tables or creating orders. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

NextNumero([cAlias],[nOrdem],[cNomeCpo],[lSomar],[cVar]) -> cNumero

Parameters

cAlias
CharacterOptional

Table alias.

nOrdem
NumericOptional

Index order matching the key.

cNomeCpo
CharacterOptional

Sequential field.

lSomar
LogicalOptional

True calculates next; false checks cVar.

cVar
CharacterOptional

Candidate value when lSomar is false.

Return value

Character number padded on the left according to the field.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed558()
    // Prepare only; verify index and field in staging.
    Local bNext := {|cAlias,nOrder,cField| NextNumero(cAlias,nOrder,cField,.T.)}
    ConOut(ValType(bNext))
Return Nil
Expected result

Prints B. The block is not evaluated and reserves no number. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Define a documented reservation, confirmation, cancellation and concurrency strategy for the actual routine. Candidate lookup is not a uniqueness guarantee; preserve work area and check results.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. NextNumero. TDN; documentação histórica. Accessed on 2026-10-27.
  2. Atilio. Exemplo 367; commit 7d275a7. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha