Ao enviar um CTe de substituição é reportado o seguinte erro:
TAG: ID:#352/refCte(Chave do CTe) - Nenhum valor informado.
'' violates pattern constraint of '[0-9]{44}'.
Este mesmo erro é reportado aqui no forum no link:
Trecho XML:
<infCteSub>
<chCte>23130900435179000100570010000173451153356992</chCte>
<tomaICMS>
<refCte>23130900435179000100570010000173451153356992</refCte>
</tomaICMS>
</infCteSub>
Notem quem o chCte e tomaICMS estão no mesmo nível, e refCte dento de tormaICMS.
No código abaixo depois de extrair o tomaICMS, lê-se a tag refNFe e em seguida extrai a tag refNF, porém, como mostra o exemplo acima não há refNF. (Maiores informações no manual)
Quando lê a refCte nada é encontrado pois está no contexto da refNF.
Trecho do arquivo pcteCTeR_V104.inc iniciado na linha 909
if Leitor.rExtrai(2, 'infCteSub') <> '' then
begin
CTe.infCTeSub.chCte := Leitor.rCampo(tcStr, 'chCte');
if Leitor.rExtrai(3, 'tomaICMS') <> '' then
begin
CTe.infCTeSub.tomaICMS.refNFe := Leitor.rCampo(tcStr, 'refNFe');
if Leitor.rExtrai(4, 'refNF') <> '' then
begin
CTe.infCTeSub.tomaICMS.refNF.CNPJ := Leitor.rCampo(tcStr, 'CNPJ');
CTe.infCTeSub.tomaICMS.refNF.modelo := Leitor.rCampo(tcStr, 'mod');
CTe.infCTeSub.tomaICMS.refNF.serie := Leitor.rCampo(tcInt, 'serie');
CTe.infCTeSub.tomaICMS.refNF.subserie := Leitor.rCampo(tcInt, 'subserie');
CTe.infCTeSub.tomaICMS.refNF.nro := Leitor.rCampo(tcInt, 'nro');
CTe.infCTeSub.tomaICMS.refNF.valor := Leitor.rCampo(tcDe2, 'valor');
CTe.infCTeSub.tomaICMS.refNF.dEmi := Leitor.rCampo(tcDat, 'dEmi');
end;
CTe.infCTeSub.tomaICMS.refCte := Leitor.rCampo(tcStr, 'refCte');
end;
if Leitor.rExtrai(3, 'tomaNaoICMS') <> '' then
begin
CTe.infCTeSub.tomaNaoICMS.refCteAnu := Leitor.rCampo(tcStr, 'refCteAnu');
end;
end;
Solução:
if Leitor.rExtrai(2, 'infCteSub') <> '' then
begin
CTe.infCTeSub.chCte := Leitor.rCampo(tcStr, 'chCte');
if Leitor.rExtrai(3, 'tomaICMS') <> '' then
begin
CTe.infCTeSub.tomaICMS.refCte := Leitor.rCampo(tcStr, 'refCte');
CTe.infCTeSub.tomaICMS.refNFe := Leitor.rCampo(tcStr, 'refNFe');
if Leitor.rExtrai(4, 'refNF') <> '' then
begin
CTe.infCTeSub.tomaICMS.refNF.CNPJ := Leitor.rCampo(tcStr, 'CNPJ');
CTe.infCTeSub.tomaICMS.refNF.modelo := Leitor.rCampo(tcStr, 'mod');
CTe.infCTeSub.tomaICMS.refNF.serie := Leitor.rCampo(tcInt, 'serie');
CTe.infCTeSub.tomaICMS.refNF.subserie := Leitor.rCampo(tcInt, 'subserie');
CTe.infCTeSub.tomaICMS.refNF.nro := Leitor.rCampo(tcInt, 'nro');
CTe.infCTeSub.tomaICMS.refNF.valor := Leitor.rCampo(tcDe2, 'valor');
CTe.infCTeSub.tomaICMS.refNF.dEmi := Leitor.rCampo(tcDat, 'dEmi');
end;
end;
if Leitor.rExtrai(3, 'tomaNaoICMS') <> '' then
begin
CTe.infCTeSub.tomaNaoICMS.refCteAnu := Leitor.rCampo(tcStr, 'refCteAnu');
end;
end;
Fiz vários testes e agora funciona perfeitamente.
Gostaria de solicitar a inclusão no fonte oficial do projeto.