cAliasAlias of the table to be positioned.
AdvPL GuidePosicione( <cAlias>, <nOrdem>, <cSeek>, <cField>, [cNickName] ) --> xRetPositions a Protheus table using an index key and directly returns the requested field value.
Posicione() searches a Protheus table using an index order and a seek expression. After locating the corresponding record, it returns the content of the field specified by cField. The optional cNickName parameter selects the index order by nickname; official documentation states that nOrdem is ignored when cNickName is supplied.
Posicione( <cAlias>, <nOrdem>, <cSeek>, <cField>, [cNickName] ) --> xRetcAliasAlias of the table to be positioned.
nOrdemIndex order number used for the search. It is ignored when cNickName is supplied.
cSeekExpression/key used to locate the record in the selected index order.
cFieldTechnical field name whose value will be returned.
cNickNameIndex-order nickname. When supplied, it takes precedence over nOrdem.
xRet, variant. Value of the field specified by cField for the located record.
User Function ExPosicione()
Local cName := ""
// SA1 order 1: validate the index expression in the target environment.
// F2_CLIENTE means “Customer”, F2_LOJA means “Store”, and A1_NOME means “Name”.
// The key below uses branch + customer + store from the sales invoice header.
cName := Posicione("SA1", 1, ;
xFilial("SA1") + SF2->F2_CLIENTE + SF2->F2_LOJA, ;
"A1_NOME")
// Technical field identifiers remain exactly as defined in Protheus.
ConOut(cName)
ReturnThe function positions SA1 using the supplied key and directly returns the A1_NOME field value.
User Function ExPosicioneNick()
Local cNickName := U_MyIndexNick()
Local cKey := U_MyKey()
Local xValue
// Structural example: use only a nickname that actually exists in the environment.
// When cNickName is supplied, nOrdem is ignored. A1_NOME means “Name”.
xValue := Posicione("SA1", 0, cKey, "A1_NOME", cNickName)
Return xValueThe example demonstrates cNickName precedence without inventing a specific index nickname.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.