array varinat

Delphi

07/10/2013

esta aparecendo esta mensagem em um cliente e na minha maquina isso nao acontece
"Tipo de array variant esta bloqueado"
ele tem windows xp mas so que ja testei aqui em um xp e funcionou
LGUEM JA VIU ESTE ERRO E como resolveu ?
preciso de ajuda com urgencia meu cliente esta p e nao estou conseguindo resolver
Usuarios Offline

Usuarios Offline

Curtidas 0

Respostas

Joel Rodrigues

Joel Rodrigues

07/10/2013

Em que momento/trecho isso ocorre?
GOSTEI 0
Deivison Melo

Deivison Melo

07/10/2013

Estranho!

Poderia postar seu código por favor?

Abração e bons códigos!!
GOSTEI 0
Volmir Santos

Volmir Santos

07/10/2013

Ai é que esta o problema pois nao consigo descobrir onde ocorre o erro especificamente pois só acontece na maquina do cliente no meu micro nao ocorre ai nao consigo debugar,
mas de qualquer forma vou postar a rotina onde ocorre o erro

procedure TFImportacao_xml.btnimportaClick(Sender: TObject);
var
cpf_cnpj, cpf_cnpj_transp, xml, retornoxml, xml_consulta:string;
vXMLDoc: TXMLDocument;
NodeRec, NodeTmp: IXMLNode;
f : Textfile;
j, a : string;
tpAmb, chNFe, dhRecbto, cStat, xMotivo, nProt, verAplic, digVal, uf_emit:string;
xml_ret:String;
begin
LimpaCampos;
OpenDialog1.FileName :='';
OpenDialog1.Title :='Selecione a NFE';
OpenDialog1.DefaultExt:='*.XML';//'*.XML';
OpenDialog1.Filter :='Arquivos XML (*.XML)|*.XML|Todos os Arquivos (*.*)|*.*';//'Todos os Arquivos (*.*)|*.*';
if OpenDialog1.Execute then
begin
XMLTNotas.XMLDataFile:=OpenDialog1.FileName;
XMLTProd.XMLDataFile :=OpenDialog1.FileName;
XMLTVenc.XMLDataFile :=OpenDialog1.FileName;
CDProd.Open;
CDNotas.Open;
CDVenc.Open;
DBdados.Enabled:=true;
end
else
exit;
LBSTATUSPROCESSO.Color:=clGradientInactiveCaption;
LBSTATUSPROCESSO.Caption:='AGUARDE CARRENGANDO XML!!!!!!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
vXMLDoc := TXMLDocument.Create(Self);
vXMLDoc.Options:=[doNodeAutoCreate,doNodeAutoIndent,doAttrNull,doAutoPrefix,doNamespaceDecl,doAutoSave];
vXMLDoc.ParseOptions:=[poResolveExternals,poValidateOnParse,poPreserveWhiteSpace,poAsyncLoad];
vXMLDoc.LoadFromFile(OpenDialog1.FileName);
vXMLDoc.Active:=true;
vXMLDoc.Version := '1.0';
vXMLDoc.Encoding := 'UTF-8';
xml:=vXMLDoc.XML.Text;
//xml:=StringReplace(xml,#13,'',[rfReplaceAll,rfIgnoreCase]);
//se estiver configurado pra buscar informacoes da nota na receita
//se o cliente nao emite nota eletronica e quser utilizar esta opcao
//configurar o sistema pra consultar utilizando o cert da empresa
//cert:ssl.pfx - senha:gatopreto (configurar no jose e no sistema)
//Obs somente funciona pra consulta de notas
if LocalizaConf('EMP_CONSULTA_NFE_FORNEC')='S' then
begin
if Length(Trim(CDNotasnProt.AsString))=0 then
uf_emit:=vXMLDoc.ChildNodes['NFe'].ChildNodes['infNFe'].ChildNodes['emit'].ChildNodes['enderEmit'].ChildNodes['UF'].Text
else
uf_emit:=vXMLDoc.ChildNodes['nfeProc'].ChildNodes['NFe'].ChildNodes['infNFe'].ChildNodes['emit'].ChildNodes['enderEmit'].ChildNodes['UF'].Text;
if NFecon.Conecta_ZettaNfe(uf_emit)=false then //conecta com José /////////////////////////////////////////////
begin
MessageDlg('Não foi possivel conectar com o serviço de envio de NFe.',mtWarning, [mbOK], 0);
LimpaCampos;
exit;
end;
LBSTATUSPROCESSO.Caption:='AGUARDE VALIDANDO ASSINATURA DO XML!!!!!!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
retornoxml:=NFecon.enviar_xml('117 '+trim(xml)); //valida a assinatura do xml;
if (copy(retornoxml,1,3)='300') or (copy(retornoxml,1,3)='600') then
begin
MessageDlg('XML com Assinatura Inválida. Entre em contato com seu Forncedor! '+retornoxml,mtInformation,[mbOK],1);
NFecon.desconectar; //fecha a conexao
LimpaCampos;
Exit;
end;
a:= 'TesteXmlImportacaoEstrutura.xml';
j:=xml;
Assignfile(f,ExtractFilePath(Application.ExeName)+ a);
rewrite(f);
writeln(f,j);
CloseFile(f);

LBSTATUSPROCESSO.Caption:='AGUARDE VALIDANDO ESTRUTURA DO XML!!!!!!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
retornoxml:=NFecon.enviar_xml('116 '+trim(xml)); //Validar o Xml com o Xsd (schema)
if (copy(retornoxml,1,3)='300') or (copy(retornoxml,1,3)='600') then
begin
MessageDlg('Xml com Estrutura Inválida. Entre em contato com seu Forncedor! '+retornoxml,mtInformation,[mbOK],1);
NFecon.desconectar; //fecha a conexao
LimpaCampos;
Exit;
end;
//consulta NFe na receita
if Length(Trim(CDNotasnProt.AsString))=0 then
NodeTmp:= vXMLDoc.ChildNodes['NFe'].ChildNodes['infNFe']
else
NodeTmp:= vXMLDoc.ChildNodes['nfeProc'].ChildNodes['NFe'].ChildNodes['infNFe'];
chNFe:=copy(NodeTmp.Attributes['Id'],4,44);
tpAmb:=NodeTmp.ChildNodes['ide'].ChildNodes['tpAmb'].Text;
//cria o xml de consulta
xmlnfe:=XML_NFE.Create;
xml_consulta:=xmlnfe.XmlConsultaNfe(chNFe, tpAmb);
xmlnfe:=nil;
//Tira os caracteres malucos da quebra de linha
xml_consulta:=StringReplace(xml_consulta,#$D#$A,'',[rfReplaceAll,rfIgnoreCase]);
//envia o xml de consulta pro jose realizar a consulta na receita
retornoxml:=NFecon.enviar_xml('102 '+xml_consulta); //e armazena o xml de retorno em uma variavel
if copy(retornoxml,1,3)='600' then
begin
MessageDlg('Erro ao consultar NFe! '+retornoxml,mtInformation,[mbOK],1);
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
NFecon.desconectar; //fecha a conexao //////
LimpaCampos;
Exit;
end
else
begin
LBSTATUSPROCESSO.Caption:='AGUARDE.... CONSULTANDO NFe NA RECEITA!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
// Cria a variável baseada no TXMLDocument
vXMLDoc := TXMLDocument.Create(self);
// Le conteúdo do arquivo XML de retorno da consulta recebido do jose
vXMLDoc.XML.Text:=copy(retornoxml,5,length(retornoxml)-4);
vXMLDoc.Active:=true;
NodeTmp := vXMLDoc.ChildNodes['retConsSitNFe'];
//se cStat for 100 esta autorizada pega os dados da nota
//se for 101 é cancelada pega os dados do cancelamento
//se for 217 é por q a nota nao consta na sefaz
if NodeTmp.ChildNodes['cStat'].text='100' then
NodeTmp := vXMLDoc.ChildNodes['retConsSitNFe'].ChildNodes['protNFe'].ChildNodes['infProt']
else if NodeTmp.ChildNodes['cStat'].text='101' then
NodeTmp := vXMLDoc.ChildNodes['retConsSitNFe'].ChildNodes['retCancNFe'].ChildNodes['infCanc']
else if NodeTmp.ChildNodes['cStat'].text='217' then
begin
MessageDlg('NFe não consta na base da Sefaz, Entre em contato com seu fornecedor!',mtInformation,[mbOK],1);
NFecon.desconectar; //fecha a conexao //////
LimpaCampos;
Exit;
end;
vXMLDoc.SaveToFile('RetornoConsultaNFeSefaz.xml');
if copy(retornoxml,1,3)='300' then
begin
NodeRec := vXMLDoc.ChildNodes.FindNode('erro');
LBSTATUSPROCESSO.Caption:=NodeRec.Text;
LBSTATUSPROCESSO.Refresh;
LBSTATUSPROCESSO.Color:=clRed;
NFecon.desconectar; //fecha a conexao //////
LimpaCampos;
exit;
end
else
begin
// pega os dados que vc quiser dentro da tag <infProt>
tpAmb :=NodeTmp.ChildNodes['tpAmb'].text;
chNFe :=NodeTmp.ChildNodes['chNFe'].text;
dhRecbto :=NodeTmp.ChildNodes['dhRecbto'].text;
cStat :=NodeTmp.ChildNodes['cStat'].text;
xMotivo :=NodeTmp.ChildNodes['xMotivo'].text;
nProt :=NodeTmp.ChildNodes['nProt'].text;
verAplic :=NodeTmp.ChildNodes['verAplic'].text;
digVal :=NodeTmp.ChildNodes['digVal'].text;
//cria o xml das informacoes de protolo da receita
xml_ret:='<infProt>'+
'<tpAmb>'+tpAmb+'</tpAmb>'+
'<verAplic>'+verAplic+'</verAplic>'+
'<chNFe>'+chNFe+'</chNFe>'+
'<dhRecbto>'+dhRecbto+'</dhRecbto>'+
'<nProt>'+nProt+'</nProt>'+
'<digVal>'+digVal+'</digVal>'+
'<cStat>'+cStat+'</cStat>'+
'<xMotivo>'+xMotivo+'</xMotivo>'+
'</infProt>';

a:= 'RetornoConsultaNotaFornec.xml';
j:=xml_ret;
Assignfile(f,ExtractFilePath(Application.ExeName)+ a);
rewrite(f);
writeln(f,j);
CloseFile(f);

if cStat<>'100' then //=OK
begin
ShowMessage('Não será possivel importar esta nota. Motivo: '+ cStat + ' ' +xMotivo);
NFecon.desconectar; //fecha a conexao //////
LimpaCampos;
Exit;
end
else if cStat='100' then //cancelada
begin
LBSTATUSPROCESSO.Color:=clGradientInactiveCaption;
LBSTATUSPROCESSO.Caption:='Nota autorizada para uso pela receita!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
end;
end;
LBSTATUSPROCESSO.Caption:='RETORNO RECEBIDO COM SUCESSO!';
end;
NFecon.desconectar; //fecha a conexao //////
//verifica se o xml recebido continha as tags nfeProc
//se nao possui a tag de nr protoloco é porq nao contam xml distrib
if Length(Trim(CDNotasnProt.AsString))=0 then
begin
vXMLDoc := TXMLDocument.Create(Self);
vXMLDoc.LoadFromFile(OpenDialog1.FileName);
vXMLDoc.Active:=true;
xml:=vXMLDoc.XML.Text;
xml:=StringReplace(xml,#$D#$A,'',[rfReplaceAll,rfIgnoreCase]);
retornoxml:=xmlnfe.XmlDistr(xml,xml_ret);
//limpa os campos pra depois carregar o novo xml
LimpaCampos;
//salva o novo xml com a distrib
a:= 'XmlNovoFornecComDistrib.xml';
j:=retornoxml;
Assignfile(f,ExtractFilePath(Application.ExeName)+ a);
rewrite(f);
writeln(f,j);
CloseFile(f);
//carrega o novo xml
OpenDialog1.FileName :=ExtractFilePath(Application.ExeName)+ a;
XMLTNotas.XMLDataFile:=OpenDialog1.FileName;
XMLTProd.XMLDataFile :=OpenDialog1.FileName;
XMLTVenc.XMLDataFile :=OpenDialog1.FileName;
CDProd.Open;
CDNotas.Open;
CDVenc.Open;

LBSTATUSPROCESSO.Color:=clGradientInactiveCaption;
LBSTATUSPROCESSO.Caption:='AGUARDE CARRENGANDO O NOVO XML!!!!!!';
LBSTATUSPROCESSO.Refresh;
DBdados.Enabled:=true;
Application.ProcessMessages;
end;
end;
//******************** até aqui valida na receita *********************
if CDNotasversao2.AsString='1.10' then
begin
MessageDlg('NFe Emitida na Versão 1.10, Não é possivel fazer a Importação!',mtInformation,[mbOK],1);
LimpaCampos;
Exit;
end;
if CDNotasemit_CNPJ.AsString=DMSC2000.Qcomp_dad.FieldByName('CGC_EMPR').AsString then
begin
MessageDlg('Nota emitida pela própria empresa, não será possivel gerar a entrada!',mtInformation,[mbOK],1);
LimpaCampos;
Exit;
end;
if CDNotastpAmb1.AsString='2' then
begin
MessageDlg('Nota emitida em ambiente de Homologação/Teste, não será possivel gerar a entrada!',mtInformation,[mbOK],1);
LimpaCampos;
Exit;
end;
if CDNotascStat.AsString <> '100' then
begin
MessageDlg('Nota sem autorização de uso pela receita!',mtInformation,[mbOK],1);
LimpaCampos;
Exit;
end;
LBSTATUSPROCESSO.Caption:='AGUARDE CONSULTANDO TRANSPORTADORA!!!!!!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
/////////Transportadora
if CDNotasmodFrete.AsString<>'9' then
begin
if Length(CDNotasCPF.AsString)>0 then
cpf_cnpj_transp:=CDNotasCPF.AsString
else if Length(CDNotasCNPJ.AsString)>0 then
cpf_cnpj_transp:=CDNotasCNPJ.AsString;
if Length(cpf_cnpj_transp)=0 then
cod_transp:=0
else
begin
with DMSC2000.QRTransportadora do
begin
Close;
SQL.Clear;
SQL.Add('SELECT codigo, nome, endereco, cidade, estado, cgc, inscricao, fone, '+
'placa, uf_placa, cod_pais, cep '+
'FROM transportadoras where cgc='''+cpf_cnpj_transp+''' ');
Open;
end;
if DMSC2000.QRTransportadora.IsEmpty then
cod_transp:=BuscaTransp(cpf_cnpj_transp)
else
cod_transp:=DMSC2000.QRTransportadora.fieldbyname('codigo').AsInteger;
end;
end
else
cod_transp:=0;
LBSTATUSPROCESSO.Caption:='AGUARDE CONSULTANDO FORNECEDOR!!!!!!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
////////// Fornecedor
if Length(CDNotasemit_CPF.AsString)>0 then
cpf_cnpj:=CDNotasemit_CPF.AsString
else
cpf_cnpj:=CDNotasemit_CNPJ.AsString;
with DMSC2000.QRFornecedor do
begin
Close;
SQL.Clear;
SQL.Add('SELECT codigo, nome, endereco, cidade, bairro, cep, uf, cpf, fone, dt_nasc, '+
'insc_est, nome_repr, fone_repr, cid_repr, nm_fant, cel_repr, '+
'fax, cx_post, hp, e_mail, obs, reg_esp, cod_pais '+
'FROM fornecedores where cpf='''+cpf_cnpj+''' ');
Open;
end;
if DMSC2000.QRFornecedor.IsEmpty then //se nao retornar nada
NEfornec.AsInteger:=BuscaFornec(cpf_cnpj) //insere e retorna o codigo gerado
else
NEfornec.AsInteger:=DMSC2000.QRFornecedor.fieldbyname('codigo').AsInteger;
NEfornecExit(Sender);
LBSTATUSPROCESSO.Caption:='AGUARDE CARREGANDO DADOS DO XML!!!!!!';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
Mkdataemis.Date:=StrToDate(FormataData(CDNotaside_dEmi.AsString));
if Length(CDNotasdSaiEnt.AsString)>0 then
Mkdatasai.Date:=StrToDate(FormataData(CDNotasdSaiEnt.AsString))
else
Mkdatasai.Date:=Now;
{pega o tipo de frete}
if CDNotasmodFrete.AsString='0' then
cbbTipoFrete.ItemIndex:=0
else if CDNotasmodFrete.AsString='1' then
cbbTipoFrete.ItemIndex:=1
else if CDNotasmodFrete.AsString='2' then
cbbTipoFrete.ItemIndex:=2
else
cbbTipoFrete.ItemIndex:=3;
SetLength(HintDB,CDProd.RecordCount);
SetLength(HintCusto,CDProd.RecordCount);
SetLength(HintPrecoVenda,CDProd.RecordCount);
{chama procedure pra Atualizar os produtos como custo margem preco etc}
AtualizaProdutos;
{atualiza as duplicatas}
CDVenc.First;
if CDVencdVenc.AsString <> '' then
JvD1venc.Date:=StrToDate(FormataData(CDVencdVenc.AsString));
NEparcelas.AsInteger:=CDVenc.RecordCount;
SomaDuplicatas(true);
PBstatus.Visible:=false;
PBstatus.Max:=0;
LBSTATUSPROCESSO.Caption:='XML - OK';
LBSTATUSPROCESSO.Refresh;
Application.ProcessMessages;
end;

var
globais
HintDB: array of string;
HintCusto: array of string;
HintPrecoVenda: array of string;
GOSTEI 0
POSTAR