Ir para conteúdo
  • Cadastre-se

dev botao

Dúvida rotina exemplo Distribuição DFe


Ver Solução Respondido por Juliomar Marchetti,
  • Este tópico foi criado há 545 dias atrás.
  • Talvez seja melhor você criar um NOVO TÓPICO do que postar uma resposta aqui.

Recommended Posts

  • Membros Pro

No exemplo do Curso de Distribuição DFe vocês trataram para pegar o XML Resumido dentre outros, mas por que dentro da mesma rotina não foi adicionado também a opção do XML Completo? Ou seja, por que aqui na rotina abaixo também não foi adicionado a seguinte condição:
 

    if (Trim(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip[I].procNfe.chDFe) <> '') then  //XMLCompleto

Teria algum problema adicionar a condição acima no código abaixo do exemplo de vocês?

lCStat := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.cStat;
  case lCStat of
    137 : result:= False;  //Nenhum Documento Localizado - Consulta deve ser interrompida por 1 hora
    138 : begin //Documentos Encontrados
            FultNSU := StrToIntDef(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.ultNSU,0);
            FmaxNSU := StrToIntDef(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.maxNSU,0);

            for I := 0 to FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Count - 1 do
            begin
              if Terminated then
                Break;
              try
                FRetornoNSU:= TDFeRetornoNSU.Create();
                FRetornoNSU.NSU := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].NSU;
                FRetornoNSU.schema := SchemaDFeToStr( FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].schema );
                FRetornoNSU.XML := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].XML;
                FRetornoNSU.arquivo := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].NomeArq;
                FRetornoNSU.UltNSU := IntToStr(FUltNSU);

                if (Trim(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip[I].resDFe.chDFe) <> '') then  //ResumoDFe
                begin
                  FRetornoNSU.chDFe := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.chDFe;
                  FRetornoNSU.CNPJCPF := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.CNPJCPF;
                  FRetornoNSU.xNome := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.xNome;
                  FRetornoNSU.IE := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.IE;
                  FRetornoNSU.dhEmi := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.dhEmi;
                  FRetornoNSU.tpNF := tpNFToStr(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.tpNF);
                  FRetornoNSU.vNF := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.vNF;
                  FRetornoNSU.digVal := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.digVal;
                  FRetornoNSU.dhRecbto := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.dhRecbto;
                  FRetornoNSU.cSitNFe := SituacaoDFeToStr( FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.cSitDFe );
                  FRetornoNSU.nProt := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resDFe.nProt;
                end;

                if (Trim(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip[I].resEvento.chDFe) <> '') then  //ResumoEvento
                begin
                  FRetornoNSU.chDFe := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.chDFe;
                  FRetornoNSU.CNPJCPF := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.CNPJCPF;
                  FRetornoNSU.dhEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.dhEvento;
                  FRetornoNSU.tpEvento := tpEventoToStr(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.tpEvento);
                  FRetornoNSU.xEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.xEvento;
                  FRetornoNSU.nSeqEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.nSeqEvento;
                  FRetornoNSU.dhRecbto := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.dhRecbto;
                  FRetornoNSU.cOrgao := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.cOrgao;
                  FRetornoNSU.nProt := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].resEvento.nProt;

                end;

                if (Trim(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip[I].procEvento.detEvento.versao) <> '' ) then //DetalhamentoEventos
                begin
                  FRetornoNSU.chDFe := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.chDFe;
                  FRetornoNSU.CNPJ := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.CNPJ;
                  FRetornoNSU.dhEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.dhEvento;
                  FRetornoNSU.tpEvento := tpEventoToStr(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.tpEvento);
                  FRetornoNSU.verEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.verEvento;
                  FRetornoNSU.nSeqEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.nSeqEvento;
                  FRetornoNSU.Id := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.Id;
                  FRetornoNSU.cOrgao := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.cOrgao;
                  FRetornoNSU.descEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.descEvento;
                  FRetornoNSU.xJust := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.xJust;
                  FRetornoNSU.xMotivo := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.xCorrecao;
                  FRetornoNSU.EmiCNPJ := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.emit.CNPJ;
                  FRetornoNSU.EmiIE := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.emit.IE;
                  FRetornoNSU.EmixNome := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.emit.xNome;
                  FRetornoNSU.cteNProt := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.CTe.nProt;
                  FRetornoNSU.cteChvCte := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.CTe.chCTe;
                  FRetornoNSU.cteDhemi := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.CTe.dhEmi;
                  FRetornoNSU.cteModal := tpModalToStr(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.CTe.modal);
                  FRetornoNSU.cteDhRebcto := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.detEvento.CTe.dhRecbto;

                end;

                if (Trim(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip[I].procEvento.RetinfEvento.Id) <> '' ) then  //InfEvento
                begin
                  FRetornoNSU.Id := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.Id;
                  FRetornoNSU.VerAplic := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.verAplic;
                  FRetornoNSU.tpAmb := TpAmbToStr(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.tpAmb);
                  FRetornoNSU.chDFe := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.chDFe;
                  FRetornoNSU.CStat := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.cStat;
                  FRetornoNSU.CNPJDest := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.CNPJDest;
                  FRetornoNSU.cOrgaoAutor := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.cOrgaoAutor;
                  FRetornoNSU.dhRegEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.dhRegEvento;
                  FRetornoNSU.tpEvento := tpEventoToStr(FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.tpEvento);
                  FRetornoNSU.nSeqEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.nSeqEvento;
                  FRetornoNSU.xEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.xEvento;
                  FRetornoNSU.xMotivo := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.xMotivo;
                  FRetornoNSU.dhRegEvento := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.dhRegEvento;
                  FRetornoNSU.emailDest := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.emailDest;
                  FRetornoNSU.nProt := FACBrNFe.WebServices.DistribuicaoDFe.retDistDFeInt.docZip.Items[I].procEvento.RetinfEvento.nProt;

                end;

              finally
                if not Terminated then
                  Synchronize(DoDFeRetornoNSU);
                FRetornoNSU.Free;
              end;

            end;


 

Editado por Datacaixa
Link para o comentário
Compartilhar em outros sites

  • Moderadores
  • Solution

a visão do exemplo é mais para mostrar. como pode ser usado. creio que tu pode fazer as devidas modificações conforme desejado

Consultor SAC ACBr Juliomar Marchetti
 

Projeto ACBr

skype: juliomar
telegram: juliomar
e-mail: [email protected]
http://www.juliomarmarchetti.com.br
MVP_NewLogo_100x100_Black-02.png
 

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...

Informação Importante

Colocamos cookies em seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies, caso contrário, assumiremos que você está bem para continuar.