nPosValid field position.
AdvPL GuideFieldPut( nPos, xValue ) --> xRetAssigns a typed value to a locked record field.
FieldPut requires a type-compatible value and record lock like direct assignment. It returns the assigned value rather than complete business success. The GitHub source modifies SA1 field five without testing RecLock; this adaptation uses only an owned table, finds the named field, checks type/length and writes only after acquiring the lock. It does not replace complete routine validation and error handling. EDTRB is an already-open owned test alias; ED_COD, when used, is a length-10 character field in the teaching schema. (TOTVS, n.d., ref. 1)
FieldPut( nPos, xValue ) --> xRetnPosValid field position.
xValueType- and length-compatible value.
Assigned value; Nil for an invalid field number.
#Include "Protheus.ch"
User Function Ed385()
Local nPosition
Local aStructure
Local cValue := "SAMPLE"
If Select("EDTRB") > 0
nPosition := EDTRB->(FieldPos("ED_COD"))
If nPosition > 0 .And. !EDTRB->(Eof())
aStructure := EDTRB->(DBStruct())
If aStructure[nPosition,2] == "C" .And. aStructure[nPosition,3] >= Len(cValue)
// Write only to the locked test record.
If RecLock("EDTRB", .F.)
EDTRB->(FieldPut(nPosition, cValue))
EDTRB->(MsUnlock())
EndIf
EndIf
EndIf
EndIf
Return NilAssigns fictional text only when requirements are met; no Protheus persistence test performed. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
© 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.