Oi pessoal
Já pesquisei muito mesmo sobre esse "simples" probleminha, mas não consegui resolvê-lo.
É o seguinte, ao enviar a carta de correção, eventualmente ocorre da Sefaz não retornar positivamente a resposta da transmissão, no entanto, se eu consultar no site da Sefaz ou Receita Federal, o evento da correção foi efetivada. Observando os exemplos do Acbr, implementei no meu sistema uma rotina para capturar o protocolo de autorizaçao da CC-e para poder imprimí-la, só que o arquivo xml [chave de acesso-ProcEventoNFe.xml] não foi gerado por causa do timeout da sefaz, e não consegui fazer gerar na rotina onde capturo as informações dos eventos.
Estou fazendo assim para pegar as informações dos eventos gerados da nf-e:
NFe.WebServices.Consulta.NFeChave := CHAVE_ACESSO;
NFe.WebServices.Consulta.Executar;
Log.Lines.Text := UTF8Encode(NFe.WebServices.Consulta.RetWS); //Aqui carrega o xml da nf-e
Log.Lines.Add('cStat '+IntToStr(NFe.WebServices.Consulta.cStat));
Log.Lines.Add('Motivo '+String(NFe.WebServices.Consulta.Msg));
Log.Lines.Add('Protocolo '+NFe.WebServices.Consulta.protNFe.nProt);
Log.Lines.Add('Dt.Hr.Recto. '+FormatDateTime('dd/mm/yyyy hh:nn:ss',NFe.WebServices.Consulta.protNFe.dhRecbto));
Log.Lines.Add('Prot.Canc.'+NFe.WebServices.Consulta.retCancNFe.nProt);
Log.Lines.Add('Dt.Hr.Rec.Canc.'+FormatDateTime('dd/mm/yyyy hh:nn:ss',NFe.WebServices.Consulta.retCancNFe.dhRecbto));
for I := 0 to NFe.WebServices.Consulta.procEventoNFe.Count-1 do
begin
if NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.InfEvento.tpEvento = teCancelamento then
begin
if NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Count > 0 then
begin
Log.Lines.Add('Prot.Evento '+NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nProt);
Log.Lines.Add('Dt.Hr.Evento '+FormatDateTime('dd/mm/yyyy hh:nn:ss',
NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.dhRegEvento));
end;
end;
if NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.InfEvento.tpEvento = teCCe then
begin
if NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Count > 0 then
begin
Log.Lines.Add('cSta '+IntToStr(NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.cStat));
Log.Lines.Add('Seq. '+IntToStr(NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nSeqEvento));
Log.Lines.Add('Prot.CCe '+NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nProt);
Log.Lines.Add('Dt.Hr.CCe '+FormatDateTime('dd/mm/yyyy hh:nn:ss',
NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.dhRegEvento));
if (NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.cStat) = 135 then
Begin
Log.Lines.Add('Gravando protocolo...');
Dm.IbqM.SQL.Clear;
Dm.IbqM.SQL.Add('UPDATE TBNF_CORRECAO SET');
Dm.IbqM.SQL.Add('DataHora_Fim = ' + QuotedStr(FormatDateTime('mm/dd/yyyy hh:nn:ss',
NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.dhRegEvento)));
Dm.IbqM.SQL.Add(',Protocolo = ' + QuotedStr(NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nProt));
Dm.IbqM.SQL.Add('Where Estabelecimento_Id = ' +QrNfsESTABELECIMENTO_CODIGO.AsString);
Dm.IbqM.SQL.Add(' and Nfs_Id = ' + QrNfsCONTROLE.AsString);
Dm.IbqM.SQL.Add(' and Sequencial = ' + IntToStr(NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.nSeqEvento));
ExecutarSql;
End;
end;
end;
end;
Mas não sei como "re"gerar o xml da cc-e. Meu componente já está atualizado. Tentei assim, mas não funcionou:
NFe.WebServices.Consulta.procEventoNFe.Items.RetEventoNFe.retEvento.Items[0].RetInfEvento.Xml));