cAliasAlias of the table to search.
AdvPL GuidePosicione( <cAlias>, <nOrdem>, <cSeek>, <cField>, [cNickName] ) → xRetSearches an indexed record and returns one field value directly.
Posicione() combines table selection, index selection, key lookup and field reading in one call. It is useful for retrieving related information without repeatedly writing DbSelectArea(), DbSetOrder(), DbSeek() and field access. The function changes the queried alias work area and record pointer, so use it carefully when a routine works with multiple tables.
Posicione( <cAlias>, <nOrdem>, <cSeek>, <cField>, [cNickName] ) → xRetcAliasAlias of the table to search.
nOrdemIndex order number; ignored when cNickName is supplied.
cSeekLookup key assembled according to the selected index expression.
cFieldName of the field whose value is returned.
cNickNameOptional index nickname; when supplied, it replaces nOrder.
Returns the value of cField in its AdvPL type. When no key is found, handle the value according to the business rule and the expected field type.
User Function ExPosicioneCustomer()
Local cCustomerName := ""
cCustomerName := Posicione( ;
"SA1", 1, ;
xFilial("SA1") + SF2->F2_CLIENTE + SF2->F2_LOJA, ;
"A1_NOME" ;
)
MsgInfo(cCustomerName, "Customer")
ReturnThe function finds the customer and returns A1_NOME.
User Function ExPosicioneProduct()
Local aArea := GetArea()
Local cDescription := Posicione("SB1", 1, xFilial("SB1") + "000001", "B1_DESC")
RestArea(aArea)
MsgInfo(cDescription, "Product")
ReturnThe original work area and pointer are restored after the lookup.
// See the Portuguese example; cNickName replaces nOrder.The index nickname is used when supplied.
© 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