trufelli Posted August 13, 2018 Report Share Posted August 13, 2018 O problema era no AINS, porque ao usar essa função o último vetor é eliminado, portanto, precisa ser utilizado o ASIZE ou AADD para incluir um novo vetor no final do array. Exemplo : aArray := { 1, 2, 3 } // Resulta: aArray { 1, 2, 3 } AINS(aArray, 2) // Resulta: aArray { 1, NIL, 2 } Alterei o Metodo AddItem METHOD AddItem( oItem ) CLASS TVoNFe2G local cID, axArray := {},nPos If oItem:Classname=="TVONFEPROD" cID := 'nItem="'+alltrim(str(len(::axItems)+1) ) +'"' aadd(::axItems, {cId,{} } ) aadd(::axItems[len(::axItems),2], {"prod" , ::StruProduto(oItem), 1 } ) aadd(::axItems[len(::axItems),2], {"imposto" , ::StruImpostos(oItem), 1 } ) aadd(::axItems[len(::axItems),2], {"infAdProd", TVoNFeItem():New("C", 0, 1,500,,,oItem:infAdProd )} ) ElseIf oItem:ClassName=="TVONFEREFNF" nPos:=ascan(::axNodes, {|x| x[1]=="ide" } ) if nPos!=0 Do Case Case ::nTipoRef==1 AAdd(::axNodes[nPos,2],{"NFref" , ::SetRefNfe(oItem) }) Case ::nTipoRef==2 AAdd(::axNodes[nPos,2],{"NFref" , ::SetrefNF(oItem) }) Case ::nTipoRef==3 AAdd(::axNodes[nPos,2],{"NFref" , ::SetrefECF(oItem) }) Case ::nTipoRef==4 AAdd(::axNodes[nPos,2],{"NFref" , ::SetrefNFP(oItem) }) EndCase Endif ElseIf oItem:ClassName=="TVONFECOBR" //if ::cModeloDoc == "55" nPos:=ascan(::axNodes, {|x| x[1]=="cobr" } ) if nPos==0 nPos:=ascan(::axNodes, {|x| x[1]=="transp" } ) ASize(::axNodes, Len( ::axNodes ) + 1 ) Ains(::axNodes,nPos+1) ::axNodes[nPos+1]:={"cobr" , {},0 } nPos:=ascan(::axNodes, {|x| x[1]=="cobr" } ) if nPos!=0 aadd(::axNodes[nPos,2], {"fat" , ::StruFatura(oItem) } ) Endif Endif if nPos!=0 //aadd(::axNodes[nPos,2], {"fat" , ::StruFatura(oItem) } ) aadd(::axNodes[nPos,2], {"dup" , ::StruDuplicata(oItem) } ) Endif ElseIf oItem:ClassName=="TVONFEPAG" // pag nPos:=ascan(::axNodes, {|x| x[1]=="pag" } ) if nPos==0 nPos:=ascan(::axNodes, {|x| x[1]=="cobr" } ) if nPos==0 nPos:=ascan(::axNodes, {|x| x[1]=="transp" } ) Endif ASize(::axNodes, Len( ::axNodes ) + 1 ) Ains(::axNodes,nPos+1) ::axNodes[nPos+1]:={ "pag", {}, 0 } nPos:=ascan(::axNodes, {|x| x[1]=="pag" } ) Endif if nPos!=0 aadd(::axNodes[nPos,2], {"detPag" , ::StruDetPag(oItem) } ) aadd(::axNodes[nPos,2], {"vTroco", TVoNFeItem():new("N", 0, 1,15, 02,,oItem:vTroco ) } ) Endif Endif Return( Nil ) Obrigado a todos. Quote Link to comment Share on other sites More sharing options...
gilmer Posted August 14, 2018 Report Share Posted August 14, 2018 No outro tópico eu pedi para vc modificar o aIns e colocar o segundo parâmetro .t., sendo que é justamente isto que ocorre. Quote Link to comment Share on other sites More sharing options...
trufelli Posted August 14, 2018 Author Report Share Posted August 14, 2018 Eu fiz isso, mas não deu certo, porque o AIns não tem esse terceiro parâmetro, mas graças a essa dica consegui "enxergar" o problema. Existe o HB_AIns, esse sim tem 4 parâmetros e um deles é justamente o .T. para incrementar um novo vetor hb_AIns( <aArray>, [<nPos>], [<xValue>], [<lAutoSize>] ) → aArray Obrigado Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.