Olá.
Me baseando na sua resposta, olhei o meu código, aparentemente esta igual.
Mesmo assim o registro não aparece quando verifico a tabela dentro do banco.
Att.
#Include "PROTHEUS.Ch"
#Include "TopConn.ch"
#Include "Totvs.ch"
User Function Teste()
Local aTam := {}
Local aCampos := {}
Local cQuery := ''
Local cQuery2 := ''
Local uRet := nil
Local nI := 0
Local oStatement
Local cAlias
Local nX := 0
OpenSm0()
if SM0->(dbSeek( '1004010001' ))
if RpcSetEnv( SM0->M0_CODIGO, SM0->M0_CODFIL ) // abre um ambiente
aTam := TamSX3("E1_FILIAL")
AADD(aCampos,{"FILIAL" ,"C",aTam[1],aTam[2]})
aTam := TamSX3("E1_CLIENTE")
AADD(aCampos,{"CODIGO" ,"C",aTam[1],aTam[2]})
aTam := TamSX3("E1_LOJA")
AADD(aCampos,{"LOJA" ,"C",aTam[1],aTam[2]})
aTam := TamSX3("E1_EMISSAO")
AADD(aCampos,{"DATAX" ,"D",aTam[1],aTam[2]})
AADD(aCampos,{"NUMERO" ,"C",16,0})
aTam := TamSX3("E1_EMISSAO")
AADD(aCampos,{"EMISSAO" ,"D",aTam[1],aTam[2]})
aTam := TamSX3("E1_VENCREA")
AADD(aCampos,{"VENCREA","D",aTam[1],aTam[2]})
aTam := TamSX3("E1_VLCRUZ")
AADD(aCampos,{"VALOR" ,"N",aTam[1],aTam[2]})
AADD(aCampos,{"HISTOR" ,"C",40,0})
AADD(aCampos,{"DC" ,"C",1,0})
aIndices := {}
aAdd( aIndices, { 'TEMP', { "DATAX", 'NUMERO', 'CODIGO', 'DC' } } )
uRet := FWTemporaryTable():New( getNextAlias() )
uRet:SetFields( aCampos )
for nI := 1 to len(aIndices)
uRet:AddIndex(aIndices[nI, 1], aIndices[nI, 2] )
next nI
uRet:Create()
for nX := 1 to 10
RecLock( uRet:oStruct:cAlias, .T. )
( uRet:oStruct:cAlias )->FILIAL := '04010001'
( uRet:oStruct:cAlias )->CODIGO := '0001'
( uRet:oStruct:cAlias )->LOJA := '01'
( uRet:oStruct:cAlias )->DATAX := dDatabase
( uRet:oStruct:cAlias )->NUMERO := '04010001'
( uRet:oStruct:cAlias )->EMISSAO := dDatabase
( uRet:oStruct:cAlias )->VENCREA := dDatabase
( uRet:oStruct:cAlias )->VALOR := nX
( uRet:oStruct:cAlias )->HISTOR := '04010001'
( uRet:oStruct:cAlias )->DC := '1'
( uRet:oStruct:cAlias )->(msUnlock())
next nI
uRet:Delete()
freeobj(uRet)
RpcClearEnv()
endif
endif
Return