PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 24 → WX - Exemplo de Leitura de um Xml de uma Nota Fiscal
WX - Exemplo de Leitura de um Xml de uma Nota Fiscal
Iniciado por BOLLER, jun., 13 2019 9:17 PM - 8 respostas
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 13 2019 - 9:17 PM
Arquivo em questao usado nesse exemplo
https://www.webdanfe.com.br/danfe/exemplos/NFe_assinada.html

Tela desenvolvida:





Código do botão

//LEITURA DE NFE

RESULTADO is xmlDocument <Description="XMLEXEMPLO"> = XMLOpen(EDT_xml,fromFile)

//TOTAL DE ITENS
BufResultado is Buffer = fLoadText(EDT_xml)
nPosIni is int = PositionOccurrence(BufResultado,"<det nItem=",lastRank,FromBeginning) + 12
nPosFim is int = PositionOccurrence(BufResultado,"<prod>",lastRank,FromBeginning) -4
nTOTAL_ITENS is int = Val( Middle(BufResultado,nPosIni,nPosFim-nPosIni) )

EDT_Result = CR+CR+"//ID"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe:Id
EDT_Result += CR+CR+"//IDE"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.cUF
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.cNF
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.natOp
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.indPag
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.mod
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.serie
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.nNF
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.dEmi
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.dSaiEnt
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.cMunFG
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.tpImp
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.tpEmis
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.cDV
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.tpAmb
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.finNFe
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.procEmi
EDT_Result += CR+RESULTADO.NFe.infNFe.ide.verProc
EDT_Result += CR+CR+"//EMITENTE"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.CNPJ
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.xNome
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.IE
EDT_Result += CR+CR+"//ENDERECO EMITENTE"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.xLgr
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.nro
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.xCpl
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.xBairro
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.cMun
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.xMun
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.UF
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.CEP
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.cPais
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.xPais
EDT_Result += CR+RESULTADO.NFe.infNFe.emit.enderEmit.fone
EDT_Result += CR+CR+"//DESTINO"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.CNPJ
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.xNome
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.IE
EDT_Result += CR+CR+"//ENDERECO DESTINO"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.xLgr
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.nro
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.xCpl
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.xBairro
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.cMun
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.xMun
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.UF
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.CEP
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.cPais
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.xPais
EDT_Result += CR+RESULTADO.NFe.infNFe.dest.enderDest.fone
EDT_Result += CR+CR+"//RETIRADA"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.CNPJ
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.xLgr
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.nro
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.xCpl
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.xBairro
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.cMun
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.xMun
EDT_Result += CR+RESULTADO.NFe.infNFe.retirada.UF
EDT_Result += CR+CR+"//ENTREGA"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.CNPJ
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.xLgr
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.nro
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.xCpl
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.xBairro
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.cMun
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.xMun
EDT_Result += CR+RESULTADO.NFe.infNFe.entrega.UF
//ITENS PRODUTOS E SERVIÇOS
//========================================================
//========================================================

x is int = 0
LOOP(nTOTAL_ITENS)
x++
EDT_Result += CR+CR+"//ITEM PRODUTO OU SERVIÇO - INICIO//"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x]:nItem
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.cProd
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.cEAN
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.xProd
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.CFOP
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.uCom
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.qCom
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.vUnCom
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.vProd
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.cEANTrib
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.uTrib
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.qTrib
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].prod.vUnTrib
//ICMS
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.orig
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.CST
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.modBC
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vBC
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.pICMS
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vICMS
//PIS
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.CST
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vBC
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.pPIS
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vPIS
//COFINS
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.CST
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vBC
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.pCOFINS
EDT_Result += CR+RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vCOFINS
EDT_Result += CR+CR+"//ITENS PRODUTOS E SERVIÇOS - FIM//"+CR+CR
END

//========================================================
//========================================================
EDT_Result += CR+CR+"//TOTAL"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vBC
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vICMS
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vBCST
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vST
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vProd
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vFrete
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vSeg
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vDesc
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vII
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vIPI
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vPIS
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vCOFINS
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vOutro
EDT_Result += CR+RESULTADO.NFe.infNFe.total.ICMSTot.vNF
EDT_Result += CR+CR+"//TRANSPORTADORA"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.modFrete
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.transporta.CNPJ
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.transporta.xNome
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.transporta.IE
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.transporta.xEnder
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.transporta.xMun
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.transporta.UF
EDT_Result += CR+CR+"//VEICULO"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.veicTransp.placa
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.veicTransp.UF
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.veicTransp.RNTC
EDT_Result += CR+CR+"//VEICULO REBOQUE"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.reboque.placa
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.reboque.UF
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.reboque.RNTC
EDT_Result += CR+CR+"//VOLUMES"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.qVol
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.esp
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.marca
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.nVol
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.pesoL
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.pesoB
EDT_Result += CR+RESULTADO.NFe.infNFe.transp.vol.lacres.nLacre
EDT_Result += CR+CR+"//INFORMAÇÕES ADICIONAIS"+CR+CR
EDT_Result += CR+RESULTADO.NFe.infNFe.infAdic.infAdFisco
EDT_Result += CR+CR+"//CERTIFICADO"+CR+CR
EDT_Result += CR+RESULTADO.NFe.Signature.KeyInfo.X509Data.X509Certificate




//Exemplo nfe xml

//<infNFe Id="NFe35080599999090910270550010000000015180051273" versao="1.10">
//<ide>
//<cUF>35</cUF>
//<cNF>518005127</cNF>
//<natOp>Venda a vista</natOp>
//<indPag>0</indPag>
//<mod>55</mod>
//<serie>1</serie>
//<nNF>1</nNF>
//<dEmi>2008-05-06</dEmi>
//<dSaiEnt>2008-05-06</dSaiEnt>
//<tpNF>0</tpNF>
//<cMunFG>3550308</cMunFG>
//<tpImp>1</tpImp>
//<tpEmis>1</tpEmis>
//<cDV>3</cDV>
//<tpAmb>2</tpAmb>
//<finNFe>1</finNFe>
//<procEmi>0</procEmi>
//<verProc>NF-eletronica.com</verProc>
//</ide>
//<emit>
//<CNPJ>99999090910270</CNPJ>
//<xNome>NF-e Associacao NF-e</xNome>
//<xFant>NF-e</xFant>
//<enderEmit>
//<xLgr>Rua Central</xLgr>
//<nro>100</nro>
//<xCpl>Fundos</xCpl>
//<xBairro>Distrito Industrial</xBairro>
//<cMun>3502200</cMun>
//<xMun>Angatuba</xMun>
//<UF>SP</UF>
//<CEP>17100171</CEP>
//<cPais>1058</cPais>
//<xPais>Brasil</xPais>
//<fone>1733021717</fone>
//</enderEmit>
//<IE>123456789012</IE>
//</emit>
//<dest>
//<CNPJ>00000000000191</CNPJ>
//<xNome>DISTRIBUIDORA DE AGUAS MINERAIS</xNome>
//<enderDest>
//<xLgr>AV DAS FONTES</xLgr>
//<nro>1777</nro>
//<xCpl>10 ANDAR</xCpl>
//<xBairro>PARQUE FONTES</xBairro>
//<cMun>5030801</cMun>
//<xMun>Sao Paulo</xMun>
//<UF>SP</UF>
//<CEP>13950000</CEP>
//<cPais>1058</cPais>
//<xPais>BRASIL</xPais>
//<fone>1932011234</fone>
//</enderDest>
//<IE> </IE>
//</dest>
//<retirada>
//<CNPJ>99171171000194</CNPJ>
//<xLgr>AV PAULISTA</xLgr>
//<nro>12345</nro>
//<xCpl>TERREO</xCpl>
//<xBairro>CERQUEIRA CESAR</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</retirada>
//<entrega>
//<CNPJ>99299299000194</CNPJ>
//<xLgr>AV FARIA LIMA</xLgr>
//<nro>1500</nro>
//<xCpl>15 ANDAR</xCpl>
//<xBairro>PINHEIROS</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</entrega>
//<det nItem="1">
//<prod>
//<cProd>00001</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>dz</uCom>
//<qCom>1000000.0000</qCom>
//<vUnCom>1</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>12000000.0000</qTrib>
//<vUnTrib>1</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//<det nItem="2">
//<prod>
//<cProd>00002</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>pack</uCom>
//<qCom>5000000.0000</qCom>
//<vUnCom>2</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>3000000.0000</qTrib>
//<vUnTrib>0.3333</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//<total>
//<ICMSTot>
//<vBC>20000000.00</vBC>
//<vICMS>18.00</vICMS>
//<vBCST>0</vBCST>
//<vST>0</vST>
//<vProd>20000000.00</vProd>
//<vFrete>0</vFrete>
//<vSeg>0</vSeg>
//<vDesc>0</vDesc>
//<vII>0</vII>
//<vIPI>0</vIPI>
//<vPIS>130000.00</vPIS>
//<vCOFINS>400000.00</vCOFINS>
//<vOutro>0</vOutro>
//<vNF>20000000.00</vNF>
//</ICMSTot>
//</total>
//<transp>
//<modFrete>0</modFrete>
//<transporta>
//<CNPJ>99171171000191</CNPJ>
//<xNome>Distribuidora de Bebidas Fazenda de SP Ltda.</xNome>
//<IE>171999999119</IE>
//<xEnder>Rua Central 100 - Fundos - Distrito Industrial</xEnder>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</transporta>
//<veicTransp>
//<placa>BXI1717</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</veicTransp>
//<reboque>
//<placa>BXI1818</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</reboque>
//<vol>
//<qVol>10000</qVol>
//<esp>CAIXA</esp>
//<marca>LINDOYA</marca>
//<nVol>500</nVol>
//<pesoL>1000000000.000</pesoL>
//<pesoB>1200000000.000</pesoB>
//<lacres>
//<nLacre>XYZ10231486</nLacre>
//</lacres>
//</vol>
//</transp>
//<infAdic>
//<infAdFisco>Nota Fiscal de exemplo NF-eletronica.com</infAdFisco>
//</infAdic>
//</infNFe>
//<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
// <SignedInfo>
// <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
// <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
// <Reference URI="#NFe35080599999090910270550010000000015180051273">
// <Transforms>
// <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
// <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></Transform>
// </Transforms>
// <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
// <DigestValue>xhTSDMH61e9uqe04lnoHT4ZzLSY=</DigestValue>
// </Reference>
// </SignedInfo>
// <SignatureValue>Iz5Z3PLQbzZt9jnBtr6xsmHZMOu/3plXG9xxfFjRCQYGnD1rjlhzBGrqt026Ca2VHHM/bHNepi6FuFkAi595GScKVuHREUotzifE2OIjgavvTOrMwbXG7+0LYgkwPFiPCao2S33UpZe7MneaxcmKQGKQZw1fP8fsWmaQ4cczZT8=</SignatureValue>
//<KeyInfo>
//<X509Data>
//<X509Certificate>MIIEuzCCA6OgAwIBAgIDMTMxMA0GCSqGSIb3DQEBBQUAMIGSMQswCQYDVQQGEwJCUjELMAkGA1UECBMCUlMxFTATBgNVBAcTDFBvcnRvIEFsZWdyZTEdMBsGA1UEChMUVGVzdGUgUHJvamV0byBORmUgUlMxHTAbBgNVBAsTFFRlc3RlIFByb2pldG8gTkZlIFJTMSEwHwYDVQQDExhORmUgLSBBQyBJbnRlcm1lZGlhcmlhIDEwHhcNMDgwNDI4MDkwMTAyWhcNMDkwNDMwMjM1OTU5WjCBnjELMAkGA1UECBMCUlMxHTAbBgNVBAsTFFRlc3RlIFByb2pldG8gTkZlIFJTMR0wGwYDVQQKExRUZXN0ZSBQcm9qZXRvIE5GZSBSUzEVMBMGA1UEBxMMUE9SVE8gQUxFR1JFMQswCQYDVQQGEwJCUjEtMCsGA1UEAxMkTkZlIC0gQXNzb2NpYWNhbyBORi1lOjk5OTk5MDkwOTEwMjcwMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDh6RRv0bj4RYX+tDQrZRb5opa77LBVVs+6LphIfSF3TSWPfnKh0+xLlBFdmnB5YGgbbW9Uon6pZQTfaC8jZhRhI5eFRRofY/Ugoeo0NGt6PcIQNZQd6lLQ/ASd1qWwjqJoEa7udriKjy3h351Mf1bng1VxS1urqC3Dn39ZWIEwQIDAQABo4IBjjCCAYowIgYDVR0jAQEABBgwFoAUPT5TqhNWAm+ZpcVsvB7malDBjEQwDwYDVR0TAQH/BAUwAwEBADAPBgNVHQ8BAf8EBQMDAOAAMAwGA1UdIAEBAAQCMAAwgbwGA1UdEQEBAASBsTCBrqA4BgVgTAEDBKAvBC0wNzA4MTk1MTE1MTk0NTMxMDg3MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDCgHQYFYEwBAwKgFAQSRmVybmFuZG8gQ2FudG8gQWx0oB
//kGBWBMAQMDoBAEDjk5OTk5MDkwOTEwMjcwoBcGBWBMAQMHoA4EDDAwMDAwMDAwMDAwMIEfZmVybmFuZG8tYWx0QHByb2NlcmdzLnJzLmdvdi5icjAgBgNVHSUBAf8EFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwUwYDVR0fAQEABEkwRzBFoEOgQYY/aHR0cDovL25mZWNlcnRpZmljYWRvLnNlZmF6LnJzLmdvdi5ici9MQ1IvQUNJbnRlcm1lZGlhcmlhMzguY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCNPpaZ3Byu3/70nObXE8NiM53j1ddIFXsb+v2ghCVd4ffExv3hYc+/a3lfgV8H/WfQsdSCTzS2cHrd4Aasr/eXfclVDmf2hcWz+R7iysOHuT6B6r+DvV3JcMdJJCDdynR5REa+zViMnVZo1G3KuceQ7/y5X3WFNVq4kwHvonJ9oExsWyw8rTwUK5bsjz0A2yEwXkmkJIngnF41sP31+9jCImiqkXcmsesFhxzX7iurAQAQCZOm7iwMWxQKcAjXCZrgSZWRQy6mU224sX3HTArHahmLJ9Iw+WYAua5qBJsiN6PC7v5tfhrEQFpcG39yMnOecxvkkPolDUyBa7d7xwgm</X509Certificate>
//</X509Data>
//</KeyInfo>
//</Signature>
//</NFe>


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 3:14 PM
//GRAVANDO NA BASE DE DADOS
//LEITURA DE NFE
nerros is int = 0

RESULTADO is xmlDocument <Description="XMLEXEMPLO"> = XMLOpen(EDT_xml,fromFile)

//TOTAL DE ITENS
BufResultado is Buffer = fLoadText(EDT_xml)
nPosIni is int = PositionOccurrence(BufResultado,"<det nItem=",lastRank,FromBeginning) + 12
nPosFim is int = PositionOccurrence(BufResultado,"<prod>",lastRank,FromBeginning) -4
nTOTAL_ITENS is int = Val( Middle(BufResultado,nPosIni,nPosFim-nPosIni) )

//EDT_Result += CR+CR+"//ID"+CR+CR
nCHAVE_N01, nCHAVE_N02, nCHAVE_N03, nCHAVE_N04, nCHAVE_N05 is 8-bytes int

//Cabeçalho
XML_01_infNFe.CHAVE_N01 = GET_SEQ("XML_01_infNFe")
XML_01_infNFe.Id = RESULTADO.NFe.infNFe:Id
IF HAdd(XML_01_infNFe) = True THEN
nCHAVE_N01 = XML_01_infNFe.CHAVE_N01

//EDT_Result += CR+CR+"//IDE"+CR+CR
XML_02_ide.CHAVE_N01= nCHAVE_N01
XML_02_ide.cUF = RESULTADO.NFe.infNFe.ide.cUF
XML_02_ide.cNF = RESULTADO.NFe.infNFe.ide.cNF
XML_02_ide.natOp = RESULTADO.NFe.infNFe.ide.natOp
XML_02_ide.indPag = RESULTADO.NFe.infNFe.ide.indPag
XML_02_ide.mod = RESULTADO.NFe.infNFe.ide.mod
XML_02_ide.serie = RESULTADO.NFe.infNFe.ide.serie
XML_02_ide.nNF = RESULTADO.NFe.infNFe.ide.nNF
XML_02_ide.dEmi = RESULTADO.NFe.infNFe.ide.dEmi
XML_02_ide.dSaiEnt = RESULTADO.NFe.infNFe.ide.dSaiEnt
XML_02_ide.tpNF = RESULTADO.NFe.infNFe.ide.tpNF
XML_02_ide.cMunFG = RESULTADO.NFe.infNFe.ide.cMunFG
XML_02_ide.tpImp = RESULTADO.NFe.infNFe.ide.tpImp
XML_02_ide.tpEmis = RESULTADO.NFe.infNFe.ide.tpEmis
XML_02_ide.cDV = RESULTADO.NFe.infNFe.ide.cDV
XML_02_ide.tpAmb = RESULTADO.NFe.infNFe.ide.tpAmb
XML_02_ide.finNFe = RESULTADO.NFe.infNFe.ide.finNFe
XML_02_ide.procEmi = RESULTADO.NFe.infNFe.ide.procEmi
XML_02_ide.verProc = RESULTADO.NFe.infNFe.ide.verProc
IF HAdd(XML_02_ide) = False THEN
nerros+=1
END

//EDT_Result += CR+CR+"//EMITENTE"+CR+CR
XML_03_emit.CHAVE_N02 = GET_SEQ("XML_03_emit")
XML_03_emit.CHAVE_N01 = nCHAVE_N01
XML_03_emit.CNPJ = RESULTADO.NFe.infNFe.emit.CNPJ
XML_03_emit.xNome = RESULTADO.NFe.infNFe.emit.xNome
XML_03_emit.xFant = RESULTADO.NFe.infNFe.emit.xFant
XML_03_emit.IE = RESULTADO.NFe.infNFe.emit.IE
IF HAdd(XML_03_emit) = True THEN
nCHAVE_N02 = XML_03_emit.CHAVE_N02
//EDT_Result += CR+CR+"//ENDERECO EMITENTE"+CR+CR
XML_04_enderEmit.CHAVE_N01 = nCHAVE_N01
XML_04_enderEmit.CHAVE_N02 = nCHAVE_N02
XML_04_enderEmit.xLgr = RESULTADO.NFe.infNFe.emit.enderEmit.xLgr
XML_04_enderEmit.nro = RESULTADO.NFe.infNFe.emit.enderEmit.nro
XML_04_enderEmit.xCpl = RESULTADO.NFe.infNFe.emit.enderEmit.xCpl
XML_04_enderEmit.xBairro = RESULTADO.NFe.infNFe.emit.enderEmit.xBairro
XML_04_enderEmit.cMun = RESULTADO.NFe.infNFe.emit.enderEmit.cMun
XML_04_enderEmit.xMun = RESULTADO.NFe.infNFe.emit.enderEmit.xMun
XML_04_enderEmit.UF = RESULTADO.NFe.infNFe.emit.enderEmit.UF
XML_04_enderEmit.CEP = RESULTADO.NFe.infNFe.emit.enderEmit.CEP
XML_04_enderEmit.cPais = RESULTADO.NFe.infNFe.emit.enderEmit.cPais
XML_04_enderEmit.xPais = RESULTADO.NFe.infNFe.emit.enderEmit.xPais
XML_04_enderEmit.fone = RESULTADO.NFe.infNFe.emit.enderEmit.fone
IF HAdd(XML_04_enderEmit) = False THEN
nerros+=1
END
ELSE
nerros+=1
END


//EDT_Result += CR+CR+"//DESTINO"+CR+CR
XML_05_dest.CHAVE_N01 = nCHAVE_N01
XML_05_dest.CHAVE_N03 = GET_SEQ("XML_05_dest")
XML_05_dest.CNPJ = RESULTADO.NFe.infNFe.dest.CNPJ
XML_05_dest.xNome = RESULTADO.NFe.infNFe.dest.xNome
XML_05_dest.IE = RESULTADO.NFe.infNFe.dest.IE
IF HAdd(XML_05_dest) = False THEN
nerros+=1
ELSE
nCHAVE_N03 = XML_05_dest.CHAVE_N03
//EDT_Result += CR+CR+"//ENDERECO DESTINO"+CR+CR
XML_06_enderDest.CHAVE_N01 = nCHAVE_N01
XML_06_enderDest.CHAVE_N03 = nCHAVE_N03
XML_06_enderDest.xLgr = RESULTADO.NFe.infNFe.dest.enderDest.xLgr
XML_06_enderDest.nro = RESULTADO.NFe.infNFe.dest.enderDest.nro
XML_06_enderDest.xCpl = RESULTADO.NFe.infNFe.dest.enderDest.xCpl
XML_06_enderDest.xBairro = RESULTADO.NFe.infNFe.dest.enderDest.xBairro
XML_06_enderDest.cMun = RESULTADO.NFe.infNFe.dest.enderDest.cMun
XML_06_enderDest.xMun = RESULTADO.NFe.infNFe.dest.enderDest.xMun
XML_06_enderDest.UF = RESULTADO.NFe.infNFe.dest.enderDest.UF
XML_06_enderDest.CEP = RESULTADO.NFe.infNFe.dest.enderDest.CEP
XML_06_enderDest.cPais = RESULTADO.NFe.infNFe.dest.enderDest.cPais
XML_06_enderDest.xPais = RESULTADO.NFe.infNFe.dest.enderDest.xPais
XML_06_enderDest.fone = RESULTADO.NFe.infNFe.dest.enderDest.fone
IF HAdd(XML_06_enderDest) = False THEN
nerros+=1
END
END


//EDT_Result += CR+CR+"//RETIRADA"+CR+CR

XML_07_retirada.CHAVE_N01 = nCHAVE_N01
XML_07_retirada.CNPJ = RESULTADO.NFe.infNFe.retirada.CNPJ
XML_07_retirada.xLgr = RESULTADO.NFe.infNFe.retirada.xLgr
XML_07_retirada.nro = RESULTADO.NFe.infNFe.retirada.nro
XML_07_retirada.xCpl = RESULTADO.NFe.infNFe.retirada.xCpl
XML_07_retirada.xBairro = RESULTADO.NFe.infNFe.retirada.xBairro
XML_07_retirada.cMun = RESULTADO.NFe.infNFe.retirada.cMun
XML_07_retirada.xMun = RESULTADO.NFe.infNFe.retirada.xMun
XML_07_retirada.UF = RESULTADO.NFe.infNFe.retirada.UF
IF HAdd(XML_07_retirada) = False THEN
nerros+=1
END

//EDT_Result += CR+CR+"//ENTREGA"+CR+CR

XML_08_entrega.CHAVE_N01 = nCHAVE_N01
XML_08_entrega.CNPJ = RESULTADO.NFe.infNFe.entrega.CNPJ
XML_08_entrega.xLgr = RESULTADO.NFe.infNFe.entrega.xLgr
XML_08_entrega.nro = RESULTADO.NFe.infNFe.entrega.nro
XML_08_entrega.xCpl = RESULTADO.NFe.infNFe.entrega.xCpl
XML_08_entrega.xBairro = RESULTADO.NFe.infNFe.entrega.xBairro
XML_08_entrega.cMun = RESULTADO.NFe.infNFe.entrega.cMun
XML_08_entrega.xMun = RESULTADO.NFe.infNFe.entrega.xMun
XML_08_entrega.UF = RESULTADO.NFe.infNFe.entrega.UF
IF HAdd(XML_08_entrega) = False THEN
nerros+=1
END

//ITENS PRODUTOS E SERVIÇOS
//========================================================
//========================================================

x is int = 0
LOOP(nTOTAL_ITENS)
x++

//EDT_Result += CR+CR+"//ITEM PRODUTO OU SERVIÇO - INICIO//"+CR+CR
XML_09_det.CHAVE_N04 = GET_SEQ("XML_09_det")
XML_09_det.CHAVE_N01 = nCHAVE_N01
XML_09_det.nItem = RESULTADO.NFe.infNFe.det[x]:nItem
IF HAdd(XML_09_det) = True THEN
nCHAVE_N04 = XML_09_det.CHAVE_N04
XML_10_prod.CHAVE_N01 = nCHAVE_N01
XML_10_prod.CHAVE_N04 = nCHAVE_N04
XML_10_prod.nItem = RESULTADO.NFe.infNFe.det[x]:nItem
XML_10_prod.cProd = RESULTADO.NFe.infNFe.det[x].prod.cProd
XML_10_prod.T096_CORRELACAO = 0
XML_10_prod.PROD_CODIGO_TISS = 0
XML_10_prod.cEAN = RESULTADO.NFe.infNFe.det[x].prod.cEAN
XML_10_prod.xProd = RESULTADO.NFe.infNFe.det[x].prod.xProd
XML_10_prod.CFOP = RESULTADO.NFe.infNFe.det[x].prod.CFOP
XML_10_prod.uCom = RESULTADO.NFe.infNFe.det[x].prod.uCom
XML_10_prod.qCom = RESULTADO.NFe.infNFe.det[x].prod.qCom
XML_10_prod.vUnCom = RESULTADO.NFe.infNFe.det[x].prod.vUnCom
XML_10_prod.vProd = RESULTADO.NFe.infNFe.det[x].prod.vProd
XML_10_prod.cEANTrib = RESULTADO.NFe.infNFe.det[x].prod.cEANTrib
XML_10_prod.uTrib = RESULTADO.NFe.infNFe.det[x].prod.uTrib
XML_10_prod.qTrib = RESULTADO.NFe.infNFe.det[x].prod.qTrib
XML_10_prod.vUnTrib = RESULTADO.NFe.infNFe.det[x].prod.vUnTrib
IF HAdd(XML_10_prod) = False THEN
nerros+=1
END

//ICMS
XML_11_ICMS00.CHAVE_N01 = nCHAVE_N01
XML_11_ICMS00.CHAVE_N04 = nCHAVE_N04
XML_11_ICMS00.orig = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.orig
XML_11_ICMS00.CST = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.CST
XML_11_ICMS00.modBC = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.modBC
XML_11_ICMS00.vBC = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vBC
XML_11_ICMS00.pICMS = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.pICMS
XML_11_ICMS00.vICMS = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vICMS
IF HAdd(XML_11_ICMS00) = False THEN
nerros+=1
END

//PIS
XML_12_PISAliq.CHAVE_N01 = nCHAVE_N01
XML_12_PISAliq.CHAVE_N04 = nCHAVE_N04
XML_12_PISAliq.CST = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.CST
XML_12_PISAliq.vBC = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vBC
XML_12_PISAliq.pPIS = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.pPIS
XML_12_PISAliq.vPIS = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vPIS
IF HAdd(XML_12_PISAliq) = False THEN
nerros+=1
END

//COFINS
XML_13_COFINSAliq.CHAVE_N01 = nCHAVE_N01
XML_13_COFINSAliq.CHAVE_N04 = nCHAVE_N04
XML_13_COFINSAliq.CST = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.CST
XML_13_COFINSAliq.vBC = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vBC
XML_13_COFINSAliq.pCOFINS = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.pCOFINS
XML_13_COFINSAliq.vCOFINS = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vCOFINS
IF HAdd(XML_13_COFINSAliq) = False THEN
nerros+=1
END
ELSE
nerros+=1
END


//EDT_Result += CR+CR+"//ITENS PRODUTOS E SERVIÇOS - FIM//"+CR+CR
END

//========================================================
//========================================================

//EDT_Result += CR+CR+"//TOTAL"+CR+CR

XML_14_ICMSTot.CHAVE_N01 = nCHAVE_N01
XML_14_ICMSTot.vBC = RESULTADO.NFe.infNFe.total.ICMSTot.vBC
XML_14_ICMSTot.vICMS = RESULTADO.NFe.infNFe.total.ICMSTot.vICMS
XML_14_ICMSTot.vBCST = RESULTADO.NFe.infNFe.total.ICMSTot.vBCST
XML_14_ICMSTot.vST = RESULTADO.NFe.infNFe.total.ICMSTot.vST
XML_14_ICMSTot.vProd = RESULTADO.NFe.infNFe.total.ICMSTot.vProd
XML_14_ICMSTot.vFrete = RESULTADO.NFe.infNFe.total.ICMSTot.vFrete
XML_14_ICMSTot.vSeg = RESULTADO.NFe.infNFe.total.ICMSTot.vSeg
XML_14_ICMSTot.vDesc = RESULTADO.NFe.infNFe.total.ICMSTot.vDesc
XML_14_ICMSTot.vII = RESULTADO.NFe.infNFe.total.ICMSTot.vII
XML_14_ICMSTot.vIPI = RESULTADO.NFe.infNFe.total.ICMSTot.vIPI
XML_14_ICMSTot.vPIS = RESULTADO.NFe.infNFe.total.ICMSTot.vPIS
XML_14_ICMSTot.vCOFINS = RESULTADO.NFe.infNFe.total.ICMSTot.vCOFINS
XML_14_ICMSTot.vOutro = RESULTADO.NFe.infNFe.total.ICMSTot.vOutro
XML_14_ICMSTot.vNF = RESULTADO.NFe.infNFe.total.ICMSTot.vNF
IF HAdd(XML_14_ICMSTot) = False THEN
nerros+=1
END

//EDT_Result += CR+CR+"//TRANSPORTADORA"+CR+CR

XML_15_transp.CHAVE_N01 = nCHAVE_N01
XML_15_transp.CHAVE_N05 = GET_SEQ("XML_15_transp")
XML_15_transp.modFrete = RESULTADO.NFe.infNFe.transp.modFrete
IF HAdd(XML_15_transp) = False THEN
nerros+=1
ELSE
nCHAVE_N05 = XML_15_transp.CHAVE_N05
XML_16_transporta.CHAVE_N01 = nCHAVE_N01
XML_16_transporta.CHAVE_N05 = nCHAVE_N05
XML_16_transporta.modFrete = RESULTADO.NFe.infNFe.transp.modFrete
XML_16_transporta.CNPJ = RESULTADO.NFe.infNFe.transp.transporta.CNPJ
XML_16_transporta.xNome = RESULTADO.NFe.infNFe.transp.transporta.xNome
XML_16_transporta.IE = RESULTADO.NFe.infNFe.transp.transporta.IE
XML_16_transporta.xEnder = RESULTADO.NFe.infNFe.transp.transporta.xEnder
XML_16_transporta.xMun = RESULTADO.NFe.infNFe.transp.transporta.xMun
XML_16_transporta.UF = RESULTADO.NFe.infNFe.transp.transporta.UF
IF HAdd(XML_16_transporta) = False THEN
nerros+=1
END

//EDT_Result += CR+CR+"//VEICULO"+CR+CR
XML_17_veicTransp.CHAVE_N01 = nCHAVE_N01
XML_17_veicTransp.CHAVE_N05 = nCHAVE_N05
XML_17_veicTransp.placa = RESULTADO.NFe.infNFe.transp.veicTransp.placa
XML_17_veicTransp.UF = RESULTADO.NFe.infNFe.transp.veicTransp.UF
XML_17_veicTransp.RNTC = RESULTADO.NFe.infNFe.transp.veicTransp.RNTC
IF HAdd(XML_17_veicTransp) = False THEN
nerros+=1
END

//EDT_Result += CR+CR+"//VEICULO REBOQUE"+CR+CR

XML_18_reboque.CHAVE_N01 = nCHAVE_N01
XML_18_reboque.CHAVE_N05 = nCHAVE_N05
XML_18_reboque.placa = RESULTADO.NFe.infNFe.transp.reboque.placa
XML_18_reboque.UF = RESULTADO.NFe.infNFe.transp.reboque.UF
XML_18_reboque.RNTC = RESULTADO.NFe.infNFe.transp.reboque.RNTC
IF HAdd(XML_18_reboque) = False THEN
nerros+=1
END

//EDT_Result += CR+CR+"//VOLUMES"+CR+CR


XML_19_vol.CHAVE_N01 = nCHAVE_N01
XML_19_vol.CHAVE_N05 = nCHAVE_N05
XML_19_vol.qVol = RESULTADO.NFe.infNFe.transp.vol.qVol
XML_19_vol.esp = RESULTADO.NFe.infNFe.transp.vol.esp
XML_19_vol.marca = RESULTADO.NFe.infNFe.transp.vol.marca
XML_19_vol.nVol = RESULTADO.NFe.infNFe.transp.vol.nVol
XML_19_vol.pesoL = RESULTADO.NFe.infNFe.transp.vol.pesoL
XML_19_vol.pesoB = RESULTADO.NFe.infNFe.transp.vol.pesoB
XML_19_vol.nLacre = RESULTADO.NFe.infNFe.transp.vol.lacres.nLacre
IF HAdd(XML_19_vol) = False THEN
nerros+=1
END

END


//EDT_Result += CR+CR+"//INFORMAÇÕES ADICIONAIS"+CR+CR
XML_20_infAdic.CHAVE_N01 = nCHAVE_N01
XML_20_infAdic.infAdFisco = RESULTADO.NFe.infNFe.infAdic.infAdFisco
XML_20_infAdic.CERTIFICADO = RESULTADO.NFe.Signature.KeyInfo.X509Data.X509Certificate
IF HAdd(XML_20_infAdic) = False THEN
nerros += 1
END

ELSE
nerros += 1
END



//<infNFe Id="NFe35080599999090910270550010000000015180051273" versao="1.10">
//<ide>
//<cUF>35</cUF>
//<cNF>518005127</cNF>
//<natOp>Venda a vista</natOp>
//<indPag>0</indPag>
//<mod>55</mod>
//<serie>1</serie>
//<nNF>1</nNF>
//<dEmi>2008-05-06</dEmi>
//<dSaiEnt>2008-05-06</dSaiEnt>
//<tpNF>0</tpNF>
//<cMunFG>3550308</cMunFG>
//<tpImp>1</tpImp>
//<tpEmis>1</tpEmis>
//<cDV>3</cDV>
//<tpAmb>2</tpAmb>
//<finNFe>1</finNFe>
//<procEmi>0</procEmi>
//<verProc>NF-eletronica.com</verProc>
//</ide>
//<emit>
//<CNPJ>99999090910270</CNPJ>
//<xNome>NF-e Associacao NF-e</xNome>
//<xFant>NF-e</xFant>
//<enderEmit>
//<xLgr>Rua Central</xLgr>
//<nro>100</nro>
//<xCpl>Fundos</xCpl>
//<xBairro>Distrito Industrial</xBairro>
//<cMun>3502200</cMun>
//<xMun>Angatuba</xMun>
//<UF>SP</UF>
//<CEP>17100171</CEP>
//<cPais>1058</cPais>
//<xPais>Brasil</xPais>
//<fone>1733021717</fone>
//</enderEmit>
//<IE>123456789012</IE>
//</emit>
//<dest> -----------------------
//<CNPJ>00000000000191</CNPJ>
//<xNome>DISTRIBUIDORA DE AGUAS MINERAIS</xNome>
//<enderDest>
//<xLgr>AV DAS FONTES</xLgr>
//<nro>1777</nro>
//<xCpl>10 ANDAR</xCpl>
//<xBairro>PARQUE FONTES</xBairro>
//<cMun>5030801</cMun>
//<xMun>Sao Paulo</xMun>
//<UF>SP</UF>
//<CEP>13950000</CEP>
//<cPais>1058</cPais>
//<xPais>BRASIL</xPais>
//<fone>1932011234</fone>
//</enderDest>
//<IE> </IE>
//</dest>------------------------
//<retirada>
//<CNPJ>99171171000194</CNPJ>
//<xLgr>AV PAULISTA</xLgr>
//<nro>12345</nro>
//<xCpl>TERREO</xCpl>
//<xBairro>CERQUEIRA CESAR</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</retirada>------------------
//<entrega>
//<CNPJ>99299299000194</CNPJ>
//<xLgr>AV FARIA LIMA</xLgr>
//<nro>1500</nro>
//<xCpl>15 ANDAR</xCpl>
//<xBairro>PINHEIROS</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</entrega>---------------------
//<det nItem="1">
//<prod>
//<cProd>00001</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>dz</uCom>
//<qCom>1000000.0000</qCom>
//<vUnCom>1</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>12000000.0000</qTrib>
//<vUnTrib>1</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//<det nItem="2">
//<prod>
//<cProd>00002</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>pack</uCom>
//<qCom>5000000.0000</qCom>
//<vUnCom>2</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>3000000.0000</qTrib>
//<vUnTrib>0.3333</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//----------------------------
//<total>
//<ICMSTot>
//<vBC>20000000.00</vBC>
//<vICMS>18.00</vICMS>
//<vBCST>0</vBCST>
//<vST>0</vST>
//<vProd>20000000.00</vProd>
//<vFrete>0</vFrete>
//<vSeg>0</vSeg>
//<vDesc>0</vDesc>
//<vII>0</vII>
//<vIPI>0</vIPI>
//<vPIS>130000.00</vPIS>
//<vCOFINS>400000.00</vCOFINS>
//<vOutro>0</vOutro>
//<vNF>20000000.00</vNF>
//</ICMSTot>
//</total>
//<transp>
//<modFrete>0</modFrete>
//<transporta>
//<CNPJ>99171171000191</CNPJ>
//<xNome>Distribuidora de Bebidas Fazenda de SP Ltda.</xNome>
//<IE>171999999119</IE>
//<xEnder>Rua Central 100 - Fundos - Distrito Industrial</xEnder>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</transporta>
//<veicTransp>
//<placa>BXI1717</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</veicTransp>
//<reboque>
//<placa>BXI1818</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</reboque>
//<vol>
//<qVol>10000</qVol>
//<esp>CAIXA</esp>
//<marca>LINDOYA</marca>
//<nVol>500</nVol>
//<pesoL>1000000000.000</pesoL>
//<pesoB>1200000000.000</pesoB>
//<lacres>
//<nLacre>XYZ10231486</nLacre>
//</lacres>
//</vol>
//</transp>
//<infAdic>
//<infAdFisco>Nota Fiscal de exemplo NF-eletronica.com</infAdFisco>
//</infAdic>
//</infNFe>
//<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
// <SignedInfo>
// <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
// <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
// <Reference URI="#NFe35080599999090910270550010000000015180051273">
// <Transforms>
// <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
// <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></Transform>
// </Transforms>
// <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
// <DigestValue>xhTSDMH61e9uqe04lnoHT4ZzLSY=</DigestValue>
// </Reference>
// </SignedInfo>
// <SignatureValue>Iz5Z3PLQbzZt9jnBtr6xsmHZMOu/3plXG9xxfFjRCQYGnD1rjlhzBGrqt026Ca2VHHM/bHNepi6FuFkAi595GScKVuHREUotzifE2OIjgavvTOrMwbXG7+0LYgkwPFiPCao2S33UpZe7MneaxcmKQGKQZw1fP8fsWmaQ4cczZT8=</SignatureValue>
//<KeyInfo>
//<X509Data>
//<X509Certificate>MIIEuzCCA6OgAwIBAgIDMTMxMA0GCSqGSIb3DQEBBQUAMIGSMQswCQYDVQQGEwJCUjELMAkGA1UECBMCUlMxFTATBgNVBAcTDFBvcnRvIEFsZWdyZTEdMBsGA1UEChMUVGVzdGUgUHJvamV0byBORmUgUlMxHTAbBgNVBAsTFFRlc3RlIFByb2pldG8gTkZlIFJTMSEwHwYDVQQDExhORmUgLSBBQyBJbnRlcm1lZGlhcmlhIDEwHhcNMDgwNDI4MDkwMTAyWhcNMDkwNDMwMjM1OTU5WjCBnjELMAkGA1UECBMCUlMxHTAbBgNVBAsTFFRlc3RlIFByb2pldG8gTkZlIFJTMR0wGwYDVQQKExRUZXN0ZSBQcm9qZXRvIE5GZSBSUzEVMBMGA1UEBxMMUE9SVE8gQUxFR1JFMQswCQYDVQQGEwJCUjEtMCsGA1UEAxMkTkZlIC0gQXNzb2NpYWNhbyBORi1lOjk5OTk5MDkwOTEwMjcwMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDh6RRv0bj4RYX+tDQrZRb5opa77LBVVs+6LphIfSF3TSWPfnKh0+xLlBFdmnB5YGgbbW9Uon6pZQTfaC8jZhRhI5eFRRofY/Ugoeo0NGt6PcIQNZQd6lLQ/ASd1qWwjqJoEa7udriKjy3h351Mf1bng1VxS1urqC3Dn39ZWIEwQIDAQABo4IBjjCCAYowIgYDVR0jAQEABBgwFoAUPT5TqhNWAm+ZpcVsvB7malDBjEQwDwYDVR0TAQH/BAUwAwEBADAPBgNVHQ8BAf8EBQMDAOAAMAwGA1UdIAEBAAQCMAAwgbwGA1UdEQEBAASBsTCBrqA4BgVgTAEDBKAvBC0wNzA4MTk1MTE1MTk0NTMxMDg3MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDCgHQYFYEwBAwKgFAQSRmVybmFuZG8gQ2FudG8gQWx0oB
//kGBWBMAQMDoBAEDjk5OTk5MDkwOTEwMjcwoBcGBWBMAQMHoA4EDDAwMDAwMDAwMDAwMIEfZmVybmFuZG8tYWx0QHByb2NlcmdzLnJzLmdvdi5icjAgBgNVHSUBAf8EFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwUwYDVR0fAQEABEkwRzBFoEOgQYY/aHR0cDovL25mZWNlcnRpZmljYWRvLnNlZmF6LnJzLmdvdi5ici9MQ1IvQUNJbnRlcm1lZGlhcmlhMzguY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCNPpaZ3Byu3/70nObXE8NiM53j1ddIFXsb+v2ghCVd4ffExv3hYc+/a3lfgV8H/WfQsdSCTzS2cHrd4Aasr/eXfclVDmf2hcWz+R7iysOHuT6B6r+DvV3JcMdJJCDdynR5REa+zViMnVZo1G3KuceQ7/y5X3WFNVq4kwHvonJ9oExsWyw8rTwUK5bsjz0A2yEwXkmkJIngnF41sP31+9jCImiqkXcmsesFhxzX7iurAQAQCZOm7iwMWxQKcAjXCZrgSZWRQy6mU224sX3HTArHahmLJ9Iw+WYAua5qBJsiN6PC7v5tfhrEQFpcG39yMnOecxvkkPolDUyBa7d7xwgm</X509Certificate>
//</X509Data>
//</KeyInfo>
//</Signature>
//</NFe>


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 3:43 PM
COM TRANSACTION

//GRAVANDO A NFE

nErros is int = 0

IF fDirectoryExist("C:\Temp\") = False
fMakeDir("C:\Temp\")
END

IF HTransactionStart("C:\Temp\Transaction.trs","XML_01_infNFe,XML_02_ide,XML_03_emit,XML_04_enderEmit,XML_05_dest,XML_06_enderDest,XML_07_retirada,XML_08_entrega,XML_09_det,XML_10_prod,XML_11_ICMS00,XML_12_PISAliq,XML_13_COFINSAliq,XML_14_ICMSTot,XML_15_transp,XML_16_transporta,XML_17_veicTransp,XML_18_reboque,XML_19_vol,XML_20_infAdic") = True

WHEN EXCEPTION IN

RESULTADO is xmlDocument <Description="XMLEXEMPLO"> = XMLOpen(EDT_xml,fromFile)

//TOTAL DE ITENS
BufResultado is Buffer = fLoadText(EDT_xml)
nPosIni is int = PositionOccurrence(BufResultado,"<det nItem=",lastRank,FromBeginning) + 12
nPosFim is int = PositionOccurrence(BufResultado,"<prod>",lastRank,FromBeginning) -4
nTOTAL_ITENS is int = Val( Middle(BufResultado,nPosIni,nPosFim-nPosIni) )

//EDT_Result += CR+CR+"//ID"+CR+CR
nCHAVE_N01, nCHAVE_N02, nCHAVE_N03, nCHAVE_N04, nCHAVE_N05 is 8-bytes int

//Cabeçalho
XML_01_infNFe.CHAVE_N01 = GET_SEQ("XML_01_infNFe")
XML_01_infNFe.Id = RESULTADO.NFe.infNFe:Id
IF HAdd(XML_01_infNFe) = True THEN
nCHAVE_N01 = XML_01_infNFe.CHAVE_N01

//EDT_Result += CR+CR+"//IDE"+CR+CR
XML_02_ide.CHAVE_N01= nCHAVE_N01
XML_02_ide.cUF = RESULTADO.NFe.infNFe.ide.cUF
XML_02_ide.cNF = RESULTADO.NFe.infNFe.ide.cNF
XML_02_ide.natOp = RESULTADO.NFe.infNFe.ide.natOp
XML_02_ide.indPag = RESULTADO.NFe.infNFe.ide.indPag
XML_02_ide.mod = RESULTADO.NFe.infNFe.ide.mod
XML_02_ide.serie = RESULTADO.NFe.infNFe.ide.serie
XML_02_ide.nNF = RESULTADO.NFe.infNFe.ide.nNF
XML_02_ide.dEmi = RESULTADO.NFe.infNFe.ide.dEmi
XML_02_ide.dSaiEnt = RESULTADO.NFe.infNFe.ide.dSaiEnt
XML_02_ide.tpNF = RESULTADO.NFe.infNFe.ide.tpNF
XML_02_ide.cMunFG = RESULTADO.NFe.infNFe.ide.cMunFG
XML_02_ide.tpImp = RESULTADO.NFe.infNFe.ide.tpImp
XML_02_ide.tpEmis = RESULTADO.NFe.infNFe.ide.tpEmis
XML_02_ide.cDV = RESULTADO.NFe.infNFe.ide.cDV
XML_02_ide.tpAmb = RESULTADO.NFe.infNFe.ide.tpAmb
XML_02_ide.finNFe = RESULTADO.NFe.infNFe.ide.finNFe
XML_02_ide.procEmi = RESULTADO.NFe.infNFe.ide.procEmi
XML_02_ide.verProc = RESULTADO.NFe.infNFe.ide.verProc
IF HAdd(XML_02_ide) = False THEN
nErros+=1
END

//EDT_Result += CR+CR+"//EMITENTE"+CR+CR
XML_03_emit.CHAVE_N02 = GET_SEQ("XML_03_emit")
XML_03_emit.CHAVE_N01 = nCHAVE_N01
XML_03_emit.CNPJ = RESULTADO.NFe.infNFe.emit.CNPJ
XML_03_emit.xNome = RESULTADO.NFe.infNFe.emit.xNome
XML_03_emit.xFant = RESULTADO.NFe.infNFe.emit.xFant
XML_03_emit.IE = RESULTADO.NFe.infNFe.emit.IE
IF HAdd(XML_03_emit) = True THEN
nCHAVE_N02 = XML_03_emit.CHAVE_N02
//EDT_Result += CR+CR+"//ENDERECO EMITENTE"+CR+CR
XML_04_enderEmit.CHAVE_N01 = nCHAVE_N01
XML_04_enderEmit.CHAVE_N02 = nCHAVE_N02
XML_04_enderEmit.xLgr = RESULTADO.NFe.infNFe.emit.enderEmit.xLgr
XML_04_enderEmit.nro = RESULTADO.NFe.infNFe.emit.enderEmit.nro
XML_04_enderEmit.xCpl = RESULTADO.NFe.infNFe.emit.enderEmit.xCpl
XML_04_enderEmit.xBairro = RESULTADO.NFe.infNFe.emit.enderEmit.xBairro
XML_04_enderEmit.cMun = RESULTADO.NFe.infNFe.emit.enderEmit.cMun
XML_04_enderEmit.xMun = RESULTADO.NFe.infNFe.emit.enderEmit.xMun
XML_04_enderEmit.UF = RESULTADO.NFe.infNFe.emit.enderEmit.UF
XML_04_enderEmit.CEP = RESULTADO.NFe.infNFe.emit.enderEmit.CEP
XML_04_enderEmit.cPais = RESULTADO.NFe.infNFe.emit.enderEmit.cPais
XML_04_enderEmit.xPais = RESULTADO.NFe.infNFe.emit.enderEmit.xPais
XML_04_enderEmit.fone = RESULTADO.NFe.infNFe.emit.enderEmit.fone
IF HAdd(XML_04_enderEmit) = False THEN
nErros+=1
END
ELSE
nErros+=1
END


//EDT_Result += CR+CR+"//DESTINO"+CR+CR
XML_05_dest.CHAVE_N01 = nCHAVE_N01
XML_05_dest.CHAVE_N03 = GET_SEQ("XML_05_dest")
XML_05_dest.CNPJ = RESULTADO.NFe.infNFe.dest.CNPJ
XML_05_dest.xNome = RESULTADO.NFe.infNFe.dest.xNome
XML_05_dest.IE = RESULTADO.NFe.infNFe.dest.IE
IF HAdd(XML_05_dest) = False THEN
nErros+=1
ELSE
nCHAVE_N03 = XML_05_dest.CHAVE_N03
//EDT_Result += CR+CR+"//ENDERECO DESTINO"+CR+CR
XML_06_enderDest.CHAVE_N01 = nCHAVE_N01
XML_06_enderDest.CHAVE_N03 = nCHAVE_N03
XML_06_enderDest.xLgr = RESULTADO.NFe.infNFe.dest.enderDest.xLgr
XML_06_enderDest.nro = RESULTADO.NFe.infNFe.dest.enderDest.nro
XML_06_enderDest.xCpl = RESULTADO.NFe.infNFe.dest.enderDest.xCpl
XML_06_enderDest.xBairro = RESULTADO.NFe.infNFe.dest.enderDest.xBairro
XML_06_enderDest.cMun = RESULTADO.NFe.infNFe.dest.enderDest.cMun
XML_06_enderDest.xMun = RESULTADO.NFe.infNFe.dest.enderDest.xMun
XML_06_enderDest.UF = RESULTADO.NFe.infNFe.dest.enderDest.UF
XML_06_enderDest.CEP = RESULTADO.NFe.infNFe.dest.enderDest.CEP
XML_06_enderDest.cPais = RESULTADO.NFe.infNFe.dest.enderDest.cPais
XML_06_enderDest.xPais = RESULTADO.NFe.infNFe.dest.enderDest.xPais
XML_06_enderDest.fone = RESULTADO.NFe.infNFe.dest.enderDest.fone
IF HAdd(XML_06_enderDest) = False THEN
nErros+=1
END
END


//EDT_Result += CR+CR+"//RETIRADA"+CR+CR

XML_07_retirada.CHAVE_N01 = nCHAVE_N01
XML_07_retirada.CNPJ = RESULTADO.NFe.infNFe.retirada.CNPJ
XML_07_retirada.xLgr = RESULTADO.NFe.infNFe.retirada.xLgr
XML_07_retirada.nro = RESULTADO.NFe.infNFe.retirada.nro
XML_07_retirada.xCpl = RESULTADO.NFe.infNFe.retirada.xCpl
XML_07_retirada.xBairro = RESULTADO.NFe.infNFe.retirada.xBairro
XML_07_retirada.cMun = RESULTADO.NFe.infNFe.retirada.cMun
XML_07_retirada.xMun = RESULTADO.NFe.infNFe.retirada.xMun
XML_07_retirada.UF = RESULTADO.NFe.infNFe.retirada.UF
IF HAdd(XML_07_retirada) = False THEN
nErros+=1
END

//EDT_Result += CR+CR+"//ENTREGA"+CR+CR

XML_08_entrega.CHAVE_N01 = nCHAVE_N01
XML_08_entrega.CNPJ = RESULTADO.NFe.infNFe.entrega.CNPJ
XML_08_entrega.xLgr = RESULTADO.NFe.infNFe.entrega.xLgr
XML_08_entrega.nro = RESULTADO.NFe.infNFe.entrega.nro
XML_08_entrega.xCpl = RESULTADO.NFe.infNFe.entrega.xCpl
XML_08_entrega.xBairro = RESULTADO.NFe.infNFe.entrega.xBairro
XML_08_entrega.cMun = RESULTADO.NFe.infNFe.entrega.cMun
XML_08_entrega.xMun = RESULTADO.NFe.infNFe.entrega.xMun
XML_08_entrega.UF = RESULTADO.NFe.infNFe.entrega.UF
IF HAdd(XML_08_entrega) = False THEN
nErros+=1
END

//ITENS PRODUTOS E SERVIÇOS
//========================================================
//========================================================

x is int = 0
LOOP(nTOTAL_ITENS)
x++

//EDT_Result += CR+CR+"//ITEM PRODUTO OU SERVIÇO - INICIO//"+CR+CR
XML_09_det.CHAVE_N04 = GET_SEQ("XML_09_det")
XML_09_det.CHAVE_N01 = nCHAVE_N01
XML_09_det.nItem = RESULTADO.NFe.infNFe.det[x]:nItem
IF HAdd(XML_09_det) = True THEN
nCHAVE_N04 = XML_09_det.CHAVE_N04
XML_10_prod.CHAVE_N01 = nCHAVE_N01
XML_10_prod.CHAVE_N04 = nCHAVE_N04
XML_10_prod.nItem = RESULTADO.NFe.infNFe.det[x]:nItem
XML_10_prod.cProd = RESULTADO.NFe.infNFe.det[x].prod.cProd
XML_10_prod.T096_CORRELACAO = 0
XML_10_prod.PROD_CODIGO_TISS = 0
XML_10_prod.cEAN = RESULTADO.NFe.infNFe.det[x].prod.cEAN
XML_10_prod.xProd = RESULTADO.NFe.infNFe.det[x].prod.xProd
XML_10_prod.CFOP = RESULTADO.NFe.infNFe.det[x].prod.CFOP
XML_10_prod.uCom = RESULTADO.NFe.infNFe.det[x].prod.uCom
XML_10_prod.qCom = RESULTADO.NFe.infNFe.det[x].prod.qCom
XML_10_prod.vUnCom = RESULTADO.NFe.infNFe.det[x].prod.vUnCom
XML_10_prod.vProd = RESULTADO.NFe.infNFe.det[x].prod.vProd
XML_10_prod.cEANTrib = RESULTADO.NFe.infNFe.det[x].prod.cEANTrib
XML_10_prod.uTrib = RESULTADO.NFe.infNFe.det[x].prod.uTrib
XML_10_prod.qTrib = RESULTADO.NFe.infNFe.det[x].prod.qTrib
XML_10_prod.vUnTrib = RESULTADO.NFe.infNFe.det[x].prod.vUnTrib
IF HAdd(XML_10_prod) = False THEN
nErros+=1
END

//ICMS
XML_11_ICMS00.CHAVE_N01 = nCHAVE_N01
XML_11_ICMS00.CHAVE_N04 = nCHAVE_N04
XML_11_ICMS00.orig = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.orig
XML_11_ICMS00.CST = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.CST
XML_11_ICMS00.modBC = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.modBC
XML_11_ICMS00.vBC = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vBC
XML_11_ICMS00.pICMS = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.pICMS
XML_11_ICMS00.vICMS = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vICMS
IF HAdd(XML_11_ICMS00) = False THEN
nErros+=1
END

//PIS
XML_12_PISAliq.CHAVE_N01 = nCHAVE_N01
XML_12_PISAliq.CHAVE_N04 = nCHAVE_N04
XML_12_PISAliq.CST = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.CST
XML_12_PISAliq.vBC = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vBC
XML_12_PISAliq.pPIS = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.pPIS
XML_12_PISAliq.vPIS = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vPIS
IF HAdd(XML_12_PISAliq) = False THEN
nErros+=1
END

//COFINS
XML_13_COFINSAliq.CHAVE_N01 = nCHAVE_N01
XML_13_COFINSAliq.CHAVE_N04 = nCHAVE_N04
XML_13_COFINSAliq.CST = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.CST
XML_13_COFINSAliq.vBC = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vBC
XML_13_COFINSAliq.pCOFINS = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.pCOFINS
XML_13_COFINSAliq.vCOFINS = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vCOFINS
IF HAdd(XML_13_COFINSAliq) = False THEN
nErros+=1
END
ELSE
nErros+=1
END


//EDT_Result += CR+CR+"//ITENS PRODUTOS E SERVIÇOS - FIM//"+CR+CR
END

//========================================================
//========================================================

//EDT_Result += CR+CR+"//TOTAL"+CR+CR

XML_14_ICMSTot.CHAVE_N01 = nCHAVE_N01
XML_14_ICMSTot.vBC = RESULTADO.NFe.infNFe.total.ICMSTot.vBC
XML_14_ICMSTot.vICMS = RESULTADO.NFe.infNFe.total.ICMSTot.vICMS
XML_14_ICMSTot.vBCST = RESULTADO.NFe.infNFe.total.ICMSTot.vBCST
XML_14_ICMSTot.vST = RESULTADO.NFe.infNFe.total.ICMSTot.vST
XML_14_ICMSTot.vProd = RESULTADO.NFe.infNFe.total.ICMSTot.vProd
XML_14_ICMSTot.vFrete = RESULTADO.NFe.infNFe.total.ICMSTot.vFrete
XML_14_ICMSTot.vSeg = RESULTADO.NFe.infNFe.total.ICMSTot.vSeg
XML_14_ICMSTot.vDesc = RESULTADO.NFe.infNFe.total.ICMSTot.vDesc
XML_14_ICMSTot.vII = RESULTADO.NFe.infNFe.total.ICMSTot.vII
XML_14_ICMSTot.vIPI = RESULTADO.NFe.infNFe.total.ICMSTot.vIPI
XML_14_ICMSTot.vPIS = RESULTADO.NFe.infNFe.total.ICMSTot.vPIS
XML_14_ICMSTot.vCOFINS = RESULTADO.NFe.infNFe.total.ICMSTot.vCOFINS
XML_14_ICMSTot.vOutro = RESULTADO.NFe.infNFe.total.ICMSTot.vOutro
XML_14_ICMSTot.vNF = RESULTADO.NFe.infNFe.total.ICMSTot.vNF
IF HAdd(XML_14_ICMSTot) = False THEN
nErros+=1
END

//EDT_Result += CR+CR+"//TRANSPORTADORA"+CR+CR

XML_15_transp.CHAVE_N01 = nCHAVE_N01
XML_15_transp.CHAVE_N05 = GET_SEQ("XML_15_transp")
XML_15_transp.modFrete = RESULTADO.NFe.infNFe.transp.modFrete
IF HAdd(XML_15_transp) = False THEN
nErros+=1
ELSE
nCHAVE_N05 = XML_15_transp.CHAVE_N05
XML_16_transporta.CHAVE_N01 = nCHAVE_N01
XML_16_transporta.CHAVE_N05 = nCHAVE_N05
XML_16_transporta.modFrete = RESULTADO.NFe.infNFe.transp.modFrete
XML_16_transporta.CNPJ = RESULTADO.NFe.infNFe.transp.transporta.CNPJ
XML_16_transporta.xNome = RESULTADO.NFe.infNFe.transp.transporta.xNome
XML_16_transporta.IE = RESULTADO.NFe.infNFe.transp.transporta.IE
XML_16_transporta.xEnder = RESULTADO.NFe.infNFe.transp.transporta.xEnder
XML_16_transporta.xMun = RESULTADO.NFe.infNFe.transp.transporta.xMun
XML_16_transporta.UF = RESULTADO.NFe.infNFe.transp.transporta.UF
IF HAdd(XML_16_transporta) = False THEN
nErros+=1
END

//EDT_Result += CR+CR+"//VEICULO"+CR+CR
XML_17_veicTransp.CHAVE_N01 = nCHAVE_N01
XML_17_veicTransp.CHAVE_N05 = nCHAVE_N05
XML_17_veicTransp.placa = RESULTADO.NFe.infNFe.transp.veicTransp.placa
XML_17_veicTransp.UF = RESULTADO.NFe.infNFe.transp.veicTransp.UF
XML_17_veicTransp.RNTC = RESULTADO.NFe.infNFe.transp.veicTransp.RNTC
IF HAdd(XML_17_veicTransp) = False THEN
nErros+=1
END

//EDT_Result += CR+CR+"//VEICULO REBOQUE"+CR+CR

XML_18_reboque.CHAVE_N01 = nCHAVE_N01
XML_18_reboque.CHAVE_N05 = nCHAVE_N05
XML_18_reboque.placa = RESULTADO.NFe.infNFe.transp.reboque.placa
XML_18_reboque.UF = RESULTADO.NFe.infNFe.transp.reboque.UF
XML_18_reboque.RNTC = RESULTADO.NFe.infNFe.transp.reboque.RNTC
IF HAdd(XML_18_reboque) = False THEN
nErros+=1
END

//EDT_Result += CR+CR+"//VOLUMES"+CR+CR


XML_19_vol.CHAVE_N01 = nCHAVE_N01
XML_19_vol.CHAVE_N05 = nCHAVE_N05
XML_19_vol.qVol = RESULTADO.NFe.infNFe.transp.vol.qVol
XML_19_vol.esp = RESULTADO.NFe.infNFe.transp.vol.esp
XML_19_vol.marca = RESULTADO.NFe.infNFe.transp.vol.marca
XML_19_vol.nVol = RESULTADO.NFe.infNFe.transp.vol.nVol
XML_19_vol.pesoL = RESULTADO.NFe.infNFe.transp.vol.pesoL
XML_19_vol.pesoB = RESULTADO.NFe.infNFe.transp.vol.pesoB
XML_19_vol.nLacre = RESULTADO.NFe.infNFe.transp.vol.lacres.nLacre
IF HAdd(XML_19_vol) = False THEN
nErros+=1
END

END


//EDT_Result += CR+CR+"//INFORMAÇÕES ADICIONAIS"+CR+CR
XML_20_infAdic.CHAVE_N01 = nCHAVE_N01
XML_20_infAdic.infAdFisco = RESULTADO.NFe.infNFe.infAdic.infAdFisco
XML_20_infAdic.CERTIFICADO = RESULTADO.NFe.Signature.KeyInfo.X509Data.X509Certificate
IF HAdd(XML_20_infAdic) = False THEN
nErros += 1
END

ELSE
nErros += 1
END


// Validate the addition
IF nErros = 0 AND HError() = 0
IF HTransactionEnd() = True THEN
ToastDisplay("Gravou com sucesso!",toastLong,vaMiddle,haCenter)
ELSE
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

ELSE IF nErros = 0 OR HError() <> 0
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

DO
// Delete the order lines
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

ELSE
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

//<infNFe Id="NFe35080599999090910270550010000000015180051273" versao="1.10">
//<ide>
//<cUF>35</cUF>
//<cNF>518005127</cNF>
//<natOp>Venda a vista</natOp>
//<indPag>0</indPag>
//<mod>55</mod>
//<serie>1</serie>
//<nNF>1</nNF>
//<dEmi>2008-05-06</dEmi>
//<dSaiEnt>2008-05-06</dSaiEnt>
//<tpNF>0</tpNF>
//<cMunFG>3550308</cMunFG>
//<tpImp>1</tpImp>
//<tpEmis>1</tpEmis>
//<cDV>3</cDV>
//<tpAmb>2</tpAmb>
//<finNFe>1</finNFe>
//<procEmi>0</procEmi>
//<verProc>NF-eletronica.com</verProc>
//</ide>
//<emit>
//<CNPJ>99999090910270</CNPJ>
//<xNome>NF-e Associacao NF-e</xNome>
//<xFant>NF-e</xFant>
//<enderEmit>
//<xLgr>Rua Central</xLgr>
//<nro>100</nro>
//<xCpl>Fundos</xCpl>
//<xBairro>Distrito Industrial</xBairro>
//<cMun>3502200</cMun>
//<xMun>Angatuba</xMun>
//<UF>SP</UF>
//<CEP>17100171</CEP>
//<cPais>1058</cPais>
//<xPais>Brasil</xPais>
//<fone>1733021717</fone>
//</enderEmit>
//<IE>123456789012</IE>
//</emit>
//<dest> -----------------------
//<CNPJ>00000000000191</CNPJ>
//<xNome>DISTRIBUIDORA DE AGUAS MINERAIS</xNome>
//<enderDest>
//<xLgr>AV DAS FONTES</xLgr>
//<nro>1777</nro>
//<xCpl>10 ANDAR</xCpl>
//<xBairro>PARQUE FONTES</xBairro>
//<cMun>5030801</cMun>
//<xMun>Sao Paulo</xMun>
//<UF>SP</UF>
//<CEP>13950000</CEP>
//<cPais>1058</cPais>
//<xPais>BRASIL</xPais>
//<fone>1932011234</fone>
//</enderDest>
//<IE> </IE>
//</dest>------------------------
//<retirada>
//<CNPJ>99171171000194</CNPJ>
//<xLgr>AV PAULISTA</xLgr>
//<nro>12345</nro>
//<xCpl>TERREO</xCpl>
//<xBairro>CERQUEIRA CESAR</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</retirada>------------------
//<entrega>
//<CNPJ>99299299000194</CNPJ>
//<xLgr>AV FARIA LIMA</xLgr>
//<nro>1500</nro>
//<xCpl>15 ANDAR</xCpl>
//<xBairro>PINHEIROS</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</entrega>---------------------
//<det nItem="1">
//<prod>
//<cProd>00001</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>dz</uCom>
//<qCom>1000000.0000</qCom>
//<vUnCom>1</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>12000000.0000</qTrib>
//<vUnTrib>1</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//<det nItem="2">
//<prod>
//<cProd>00002</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>pack</uCom>
//<qCom>5000000.0000</qCom>
//<vUnCom>2</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>3000000.0000</qTrib>
//<vUnTrib>0.3333</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//----------------------------
//<total>
//<ICMSTot>
//<vBC>20000000.00</vBC>
//<vICMS>18.00</vICMS>
//<vBCST>0</vBCST>
//<vST>0</vST>
//<vProd>20000000.00</vProd>
//<vFrete>0</vFrete>
//<vSeg>0</vSeg>
//<vDesc>0</vDesc>
//<vII>0</vII>
//<vIPI>0</vIPI>
//<vPIS>130000.00</vPIS>
//<vCOFINS>400000.00</vCOFINS>
//<vOutro>0</vOutro>
//<vNF>20000000.00</vNF>
//</ICMSTot>
//</total>
//<transp>
//<modFrete>0</modFrete>
//<transporta>
//<CNPJ>99171171000191</CNPJ>
//<xNome>Distribuidora de Bebidas Fazenda de SP Ltda.</xNome>
//<IE>171999999119</IE>
//<xEnder>Rua Central 100 - Fundos - Distrito Industrial</xEnder>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</transporta>
//<veicTransp>
//<placa>BXI1717</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</veicTransp>
//<reboque>
//<placa>BXI1818</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</reboque>
//<vol>
//<qVol>10000</qVol>
//<esp>CAIXA</esp>
//<marca>LINDOYA</marca>
//<nVol>500</nVol>
//<pesoL>1000000000.000</pesoL>
//<pesoB>1200000000.000</pesoB>
//<lacres>
//<nLacre>XYZ10231486</nLacre>
//</lacres>
//</vol>
//</transp>
//<infAdic>
//<infAdFisco>Nota Fiscal de exemplo NF-eletronica.com</infAdFisco>
//</infAdic>
//</infNFe>
//<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
// <SignedInfo>
// <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
// <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
// <Reference URI="#NFe35080599999090910270550010000000015180051273">
// <Transforms>
// <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
// <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></Transform>
// </Transforms>
// <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
// <DigestValue>xhTSDMH61e9uqe04lnoHT4ZzLSY=</DigestValue>
// </Reference>
// </SignedInfo>
// <SignatureValue>Iz5Z3PLQbzZt9jnBtr6xsmHZMOu/3plXG9xxfFjRCQYGnD1rjlhzBGrqt026Ca2VHHM/bHNepi6FuFkAi595GScKVuHREUotzifE2OIjgavvTOrMwbXG7+0LYgkwPFiPCao2S33UpZe7MneaxcmKQGKQZw1fP8fsWmaQ4cczZT8=</SignatureValue>
//<KeyInfo>
//<X509Data>
//<X509Certificate>MIIEuzCCA6OgAwIBAgIDMTMxMA0GCSqGSIb3DQEBBQUAMIGSMQswCQYDVQQGEwJCUjELMAkGA1UECBMCUlMxFTATBgNVBAcTDFBvcnRvIEFsZWdyZTEdMBsGA1UEChMUVGVzdGUgUHJvamV0byBORmUgUlMxHTAbBgNVBAsTFFRlc3RlIFByb2pldG8gTkZlIFJTMSEwHwYDVQQDExhORmUgLSBBQyBJbnRlcm1lZGlhcmlhIDEwHhcNMDgwNDI4MDkwMTAyWhcNMDkwNDMwMjM1OTU5WjCBnjELMAkGA1UECBMCUlMxHTAbBgNVBAsTFFRlc3RlIFByb2pldG8gTkZlIFJTMR0wGwYDVQQKExRUZXN0ZSBQcm9qZXRvIE5GZSBSUzEVMBMGA1UEBxMMUE9SVE8gQUxFR1JFMQswCQYDVQQGEwJCUjEtMCsGA1UEAxMkTkZlIC0gQXNzb2NpYWNhbyBORi1lOjk5OTk5MDkwOTEwMjcwMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDh6RRv0bj4RYX+tDQrZRb5opa77LBVVs+6LphIfSF3TSWPfnKh0+xLlBFdmnB5YGgbbW9Uon6pZQTfaC8jZhRhI5eFRRofY/Ugoeo0NGt6PcIQNZQd6lLQ/ASd1qWwjqJoEa7udriKjy3h351Mf1bng1VxS1urqC3Dn39ZWIEwQIDAQABo4IBjjCCAYowIgYDVR0jAQEABBgwFoAUPT5TqhNWAm+ZpcVsvB7malDBjEQwDwYDVR0TAQH/BAUwAwEBADAPBgNVHQ8BAf8EBQMDAOAAMAwGA1UdIAEBAAQCMAAwgbwGA1UdEQEBAASBsTCBrqA4BgVgTAEDBKAvBC0wNzA4MTk1MTE1MTk0NTMxMDg3MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDCgHQYFYEwBAwKgFAQSRmVybmFuZG8gQ2FudG8gQWx0oB
//kGBWBMAQMDoBAEDjk5OTk5MDkwOTEwMjcwoBcGBWBMAQMHoA4EDDAwMDAwMDAwMDAwMIEfZmVybmFuZG8tYWx0QHByb2NlcmdzLnJzLmdvdi5icjAgBgNVHSUBAf8EFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwUwYDVR0fAQEABEkwRzBFoEOgQYY/aHR0cDovL25mZWNlcnRpZmljYWRvLnNlZmF6LnJzLmdvdi5ici9MQ1IvQUNJbnRlcm1lZGlhcmlhMzguY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCNPpaZ3Byu3/70nObXE8NiM53j1ddIFXsb+v2ghCVd4ffExv3hYc+/a3lfgV8H/WfQsdSCTzS2cHrd4Aasr/eXfclVDmf2hcWz+R7iysOHuT6B6r+DvV3JcMdJJCDdynR5REa+zViMnVZo1G3KuceQ7/y5X3WFNVq4kwHvonJ9oExsWyw8rTwUK5bsjz0A2yEwXkmkJIngnF41sP31+9jCImiqkXcmsesFhxzX7iurAQAQCZOm7iwMWxQKcAjXCZrgSZWRQy6mU224sX3HTArHahmLJ9Iw+WYAua5qBJsiN6PC7v5tfhrEQFpcG39yMnOecxvkkPolDUyBa7d7xwgm</X509Certificate>
//</X509Data>
//</KeyInfo>
//</Signature>
//</NFe>


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 4:01 PM
Estrutura de Tabelas
-- Script generated by WINDEV on 14/06/2019 11:00:29
-- Tables of SIIS_ANA.wda analysis
-- for Oracle

-- Deleting the XML_01_infNFe table
DROP TABLE XML_01_infNFe CASCADE CONSTRAINTS ;
-- Creating the XML_01_infNFe table
CREATE TABLE XML_01_infNFe (
Id NVARCHAR2 (255) Default Null,
versao NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) NOT Null UNIQUE );

-- Deleting the XML_02_ide table
DROP TABLE XML_02_ide CASCADE CONSTRAINTS ;
-- Creating the XML_02_ide table
CREATE TABLE XML_02_ide (
cUF NVARCHAR2 (255) Default Null,
cNF NVARCHAR2 (255) Default Null,
natOp NVARCHAR2 (255) Default Null,
indPag NVARCHAR2 (255) Default Null,
mod NVARCHAR2 (255) Default Null,
serie NVARCHAR2 (255) Default Null,
nNF NVARCHAR2 (255) Default Null,
dEmi NVARCHAR2 (255) Default Null,
dSaiEnt NVARCHAR2 (255) Default Null,
tpNF NVARCHAR2 (255) Default Null,
cMunFG NVARCHAR2 (255) Default Null,
tpImp NVARCHAR2 (255) Default Null,
tpEmis NVARCHAR2 (255) Default Null,
cDV NVARCHAR2 (255) Default Null,
tpAmb NVARCHAR2 (255) Default Null,
finNFe NVARCHAR2 (255) Default Null,
procEmi NVARCHAR2 (255) Default Null,
verProc NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_02_ide_CHAVE_N01 ON XML_02_ide (CHAVE_N01);

-- Deleting the XML_03_emit table
DROP TABLE XML_03_emit CASCADE CONSTRAINTS ;
-- Creating the XML_03_emit table
CREATE TABLE XML_03_emit (
CNPJ NVARCHAR2 (255) Default Null,
xNome NVARCHAR2 (255) Default Null,
xFant NVARCHAR2 (255) Default Null,
IE NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N02 NUMERIC(19,0) Default 0 NOT Null UNIQUE );
CREATE INDEX WDIDX_XML_03_emit_CHAVE_N01 ON XML_03_emit (CHAVE_N01);

-- Deleting the XML_04_enderEmit table
DROP TABLE XML_04_enderEmit CASCADE CONSTRAINTS ;
-- Creating the XML_04_enderEmit table
CREATE TABLE XML_04_enderEmit (
xLgr NVARCHAR2 (255) Default Null,
nro NVARCHAR2 (255) Default Null,
xCpl NVARCHAR2 (255) Default Null,
xBairro NVARCHAR2 (255) Default Null,
cMun NVARCHAR2 (255) Default Null,
xMun NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CEP NVARCHAR2 (255) Default Null,
cPais NVARCHAR2 (255) Default Null,
xPais NVARCHAR2 (255) Default Null,
fone NVARCHAR2 (255) Default Null,
CHAVE_N02 NUMERIC(19,0) ,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_04_enderEmit_CH00000 ON XML_04_enderEmit (CHAVE_N02);
CREATE INDEX WDIDX_XML_04_enderEmit_CH00001 ON XML_04_enderEmit (CHAVE_N01);

-- Deleting the XML_05_dest table
DROP TABLE XML_05_dest CASCADE CONSTRAINTS ;
-- Creating the XML_05_dest table
CREATE TABLE XML_05_dest (
CNPJ NVARCHAR2 (255) Default Null,
xNome NVARCHAR2 (255) Default Null,
IE NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N03 NUMERIC(19,0) Default 0 NOT Null UNIQUE );
CREATE INDEX WDIDX_XML_05_dest_CHAVE_N01 ON XML_05_dest (CHAVE_N01);

-- Deleting the XML_06_enderDest table
DROP TABLE XML_06_enderDest CASCADE CONSTRAINTS ;
-- Creating the XML_06_enderDest table
CREATE TABLE XML_06_enderDest (
xLgr NVARCHAR2 (255) Default Null,
nro NVARCHAR2 (255) Default Null,
xCpl NVARCHAR2 (255) Default Null,
xBairro NVARCHAR2 (255) Default Null,
CHAVE_N03 NUMERIC(19,0) Default 0,
cMun NVARCHAR2 (255) Default Null,
xMun NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CEP NVARCHAR2 (255) Default Null,
cPais NVARCHAR2 (255) Default Null,
xPais NVARCHAR2 (255) Default Null,
fone NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_06_enderDest_CH00002 ON XML_06_enderDest (CHAVE_N03);
CREATE INDEX WDIDX_XML_06_enderDest_CH00003 ON XML_06_enderDest (CHAVE_N01);

-- Deleting the XML_07_retirada table
DROP TABLE XML_07_retirada CASCADE CONSTRAINTS ;
-- Creating the XML_07_retirada table
CREATE TABLE XML_07_retirada (
CNPJ NVARCHAR2 (255) Default Null,
xLgr NVARCHAR2 (255) Default Null,
nro NVARCHAR2 (255) Default Null,
xCpl NVARCHAR2 (255) Default Null,
xBairro NVARCHAR2 (255) Default Null,
cMun NVARCHAR2 (255) Default Null,
xMun NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_07_retirada_CHA00004 ON XML_07_retirada (CHAVE_N01);

-- Deleting the XML_08_entrega table
DROP TABLE XML_08_entrega CASCADE CONSTRAINTS ;
-- Creating the XML_08_entrega table
CREATE TABLE XML_08_entrega (
CNPJ NVARCHAR2 (255) Default Null,
xLgr NVARCHAR2 (255) Default Null,
nro NVARCHAR2 (255) Default Null,
xCpl NVARCHAR2 (255) Default Null,
xBairro NVARCHAR2 (255) Default Null,
cMun NVARCHAR2 (255) Default Null,
xMun NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_08_entrega_CHAVE_N01 ON XML_08_entrega (CHAVE_N01);

-- Deleting the XML_09_det table
DROP TABLE XML_09_det CASCADE CONSTRAINTS ;
-- Creating the XML_09_det table
CREATE TABLE XML_09_det (
nItem NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N04 NUMERIC(19,0) Default 0 NOT Null UNIQUE );
CREATE INDEX WDIDX_XML_09_det_CHAVE_N01 ON XML_09_det (CHAVE_N01);

-- Deleting the XML_10_prod table
DROP TABLE XML_10_prod CASCADE CONSTRAINTS ;
-- Creating the XML_10_prod table
CREATE TABLE XML_10_prod (
cProd NVARCHAR2 (255) Default Null,
PROD_CODIGO_TISS NUMERIC(19,0) Default 0,
CHAVE_N04 NUMERIC(19,0) Default 0 UNIQUE ,
cEAN NVARCHAR2 (255) Default Null,
xProd NVARCHAR2 (255) Default Null,
CFOP NVARCHAR2 (255) Default Null,
uCom NVARCHAR2 (255) Default Null,
qCom NVARCHAR2 (255) Default Null,
vUnCom NVARCHAR2 (255) Default Null,
vProd NVARCHAR2 (255) Default Null,
cEANTrib NVARCHAR2 (255) Default Null,
uTrib NVARCHAR2 (255) Default Null,
qTrib NVARCHAR2 (255) Default Null,
vUnTrib NVARCHAR2 (255) Default Null,
T096_CORRELACAO NUMERIC(19,0) ,
nItem NVARCHAR2 (255) ,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_10_prod_cProd ON XML_10_prod (cProd);
CREATE INDEX WDIDX_XML_10_prod_PROD_CO00005 ON XML_10_prod (PROD_CODIGO_TISS);
CREATE INDEX WDIDX_XML_10_prod_cEAN ON XML_10_prod (cEAN);
CREATE INDEX WDIDX_XML_10_prod_xProd ON XML_10_prod (xProd);
CREATE INDEX WDIDX_XML_10_prod_T096_CO00006 ON XML_10_prod (T096_CORRELACAO);
CREATE INDEX WDIDX_XML_10_prod_nItem ON XML_10_prod (nItem);
CREATE INDEX WDIDX_XML_10_prod_CHAVE_N01 ON XML_10_prod (CHAVE_N01);

-- Deleting the XML_11_ICMS00 table
DROP TABLE XML_11_ICMS00 CASCADE CONSTRAINTS ;
-- Creating the XML_11_ICMS00 table
CREATE TABLE XML_11_ICMS00 (
orig NVARCHAR2 (255) Default Null,
CST NVARCHAR2 (255) Default Null,
CHAVE_N04 NUMERIC(19,0) Default 0 UNIQUE ,
modBC NVARCHAR2 (255) Default Null,
vBC NVARCHAR2 (255) Default Null,
pICMS NVARCHAR2 (255) Default Null,
vICMS NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_11_ICMS00_CHAVE_N01 ON XML_11_ICMS00 (CHAVE_N01);

-- Deleting the XML_12_PISAliq table
DROP TABLE XML_12_PISAliq CASCADE CONSTRAINTS ;
-- Creating the XML_12_PISAliq table
CREATE TABLE XML_12_PISAliq (
CST NVARCHAR2 (255) Default Null,
vBC NVARCHAR2 (255) Default Null,
CHAVE_N04 NUMERIC(19,0) Default 0 UNIQUE ,
pPIS NVARCHAR2 (255) Default Null,
vPIS NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_12_PISAliq_CHAVE_N01 ON XML_12_PISAliq (CHAVE_N01);

-- Deleting the XML_13_COFINSAliq table
DROP TABLE XML_13_COFINSAliq CASCADE CONSTRAINTS ;
-- Creating the XML_13_COFINSAliq table
CREATE TABLE XML_13_COFINSAliq (
CST NVARCHAR2 (255) Default Null,
vBC NVARCHAR2 (255) Default Null,
CHAVE_N04 NUMERIC(19,0) Default 0 UNIQUE ,
pCOFINS NVARCHAR2 (255) Default Null,
vCOFINS NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_13_COFINSAliq_C00007 ON XML_13_COFINSAliq (CHAVE_N01);

-- Deleting the XML_14_ICMSTot table
DROP TABLE XML_14_ICMSTot CASCADE CONSTRAINTS ;
-- Creating the XML_14_ICMSTot table
CREATE TABLE XML_14_ICMSTot (
vBC NVARCHAR2 (255) Default Null,
vICMS NVARCHAR2 (255) Default Null,
vBCST NVARCHAR2 (255) Default Null,
vST NVARCHAR2 (255) Default Null,
vProd NVARCHAR2 (255) Default Null,
vFrete NVARCHAR2 (255) Default Null,
vSeg NVARCHAR2 (255) Default Null,
vDesc NVARCHAR2 (255) Default Null,
vII NVARCHAR2 (255) Default Null,
vIPI NVARCHAR2 (255) Default Null,
vPIS NVARCHAR2 (255) Default Null,
vCOFINS NVARCHAR2 (255) Default Null,
vOutro NVARCHAR2 (255) Default Null,
vNF NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_14_ICMSTot_CHAVE_N01 ON XML_14_ICMSTot (CHAVE_N01);

-- Deleting the XML_15_transp table
DROP TABLE XML_15_transp CASCADE CONSTRAINTS ;
-- Creating the XML_15_transp table
CREATE TABLE XML_15_transp (
modFrete NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N05 NUMERIC(19,0) Default 0 NOT Null UNIQUE );
CREATE INDEX WDIDX_XML_15_transp_CHAVE_N01 ON XML_15_transp (CHAVE_N01);

-- Deleting the XML_16_transporta table
DROP TABLE XML_16_transporta CASCADE CONSTRAINTS ;
-- Creating the XML_16_transporta table
CREATE TABLE XML_16_transporta (
CNPJ NVARCHAR2 (255) Default Null,
xNome NVARCHAR2 (255) Default Null,
CHAVE_N05 NUMERIC(19,0) Default 0 UNIQUE ,
IE NVARCHAR2 (255) Default Null,
xEnder NVARCHAR2 (255) Default Null,
xMun NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0,
modFrete NVARCHAR2 (255) );
CREATE INDEX WDIDX_XML_16_transporta_C00008 ON XML_16_transporta (CHAVE_N01);

-- Deleting the XML_17_veicTransp table
DROP TABLE XML_17_veicTransp CASCADE CONSTRAINTS ;
-- Creating the XML_17_veicTransp table
CREATE TABLE XML_17_veicTransp (
placa NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CHAVE_N05 NUMERIC(19,0) Default 0 UNIQUE ,
RNTC NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_17_veicTransp_C00009 ON XML_17_veicTransp (CHAVE_N01);

-- Deleting the XML_18_reboque table
DROP TABLE XML_18_reboque CASCADE CONSTRAINTS ;
-- Creating the XML_18_reboque table
CREATE TABLE XML_18_reboque (
placa NVARCHAR2 (255) Default Null,
UF NVARCHAR2 (255) Default Null,
CHAVE_N05 NUMERIC(19,0) Default 0 UNIQUE ,
RNTC NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0);
CREATE INDEX WDIDX_XML_18_reboque_CHAVE_N01 ON XML_18_reboque (CHAVE_N01);

-- Deleting the XML_19_vol table
DROP TABLE XML_19_vol CASCADE CONSTRAINTS ;
-- Creating the XML_19_vol table
CREATE TABLE XML_19_vol (
qVol NVARCHAR2 (255) Default Null,
ESP NVARCHAR2 (255) Default Null,
CHAVE_N05 NUMERIC(19,0) Default 0 UNIQUE ,
marca NVARCHAR2 (255) Default Null,
nVol NVARCHAR2 (255) Default Null,
pesoL NVARCHAR2 (255) Default Null,
pesoB NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0,
nLacre NVARCHAR2 (255) );
CREATE INDEX WDIDX_XML_19_vol_CHAVE_N01 ON XML_19_vol (CHAVE_N01);

-- Deleting the XML_20_infAdic table
DROP TABLE XML_20_infAdic CASCADE CONSTRAINTS ;
-- Creating the XML_20_infAdic table
CREATE TABLE XML_20_infAdic (
infAdFisco NVARCHAR2 (255) Default Null,
CHAVE_N01 NUMERIC(19,0) Default 0,
CERTIFICADO CLOB );
CREATE INDEX WDIDX_XML_20_infAdic_CHAVE_N01 ON XML_20_infAdic (CHAVE_N01);
-- Integrity constraints
ALTER TABLE XML_06_enderDest Add FOREIGN KEY (CHAVE_N03) REFERENCES XML_05_dest (CHAVE_N03);
ALTER TABLE XML_04_enderEmit Add FOREIGN KEY (CHAVE_N02) REFERENCES XML_03_emit (CHAVE_N02);
ALTER TABLE XML_20_infAdic Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_14_ICMSTot Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_09_det Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_08_entrega Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_07_retirada Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_03_emit Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_05_dest Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_15_transp Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_02_ide Add FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_10_prod Add FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_13_COFINSAliq Add FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_12_PISAliq Add FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_11_ICMS00 Add FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_16_transporta Add FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);
ALTER TABLE XML_17_veicTransp Add FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);
ALTER TABLE XML_18_reboque Add FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);
ALTER TABLE XML_19_vol Add FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 4:16 PM
CRIANDO O SEQ NO BANCO

-- Create sequence
create sequence SEQ_XML_01_INFNFE
start with 1;

create sequence SEQ_XML_03_EMIT
start with 1;

create sequence SEQ_XML_05_DEST
start with 1;

create sequence SEQ_XML_09_DET
start with 1;

create sequence SEQ_XML_15_TRANSP
start with 1;


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 4:19 PM
PROCEDURE WL

Procedure GET_SEQ(pSeqName)

//Programa..: F_GETSEQ
//Objetivo..: RETORNAR A NEXT SEQUENCE ESPECIFICA!
//Parâmetros:
//Entrada.: SEQNAME, > NOME DA SEQUENCE
//ret_val OUT INTEGER > NEXTSEQ
//Saída...: Mensagem de execução da função
//Algoritmo.: 1 - RETORNA A NEXT SEQUENCE ESPECIFICA

ds_query is Data Source
query is string = "SELECT F_GETSEQ('"+pSeqName+"') AS SEQ_VLR FROM DUAL"
nIsseq is 8-byte int

IF HExecuteSQLQuery(ds_query,CONN_INFOTST,hQueryDefault+hQueryWithoutCorrection,query) = True THEN

FOR EACH ds_query
nIsseq = ds_query.SEQ_VLR
END

END

RESULT nIsseq


FUNCTION BANCO ORACLE

create or replace function F_GETSEQ(tabName varchar2)

//Programa..: F_GETSEQ
//Objetivo..: RETORNAR A NEXT SEQUENCE ESPECIFICA!
//Parâmetros:
//Entrada.: SEQNAME, > NOME DA SEQUENCE
//ret_val OUT INTEGER > NEXTSEQ
//Saída...: Mensagem de execução da função
//Algoritmo.: 1 - RETORNA A NEXT SEQUENCE ESPECIFICA

return number
is

ret_val number :=0;

begin

execute immediate 'select SEQ_'||tabName||'.nextval as vlr_seq from dual' into ret_val;

return ret_val;

end;


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 4:30 PM




--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 14 2019 - 4:33 PM
BOTAO SELECIONAR XML

EDT_xml = fSelect("", "", "Selecione o XML", "Xml (*.*)" + TAB + "*.xml", "*.xml")


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membro registado
2.969 mensagems
Popularité : +89 (91 votes)
Publicado em junho, 18 2019 - 7:03 PM
Nova versao testada

// Summary: <specify the procedure action>
// Syntax:
// GravarNfe ()
//
// Parameters:
// None
// Return Value:
// None
//
// For instance:
// Indicate an example.
//
Procedure GravarNfe()

//GRAVANDO A NFE

bOk1, bOk2, bOk3, bOk4, bOk5, bOk6 is boolean = False

nErros is int = 0

IF EDT_xml <> "" AND fFileExist(EDT_xml) = True

IF fDirectoryExist("C:\Temp\") = False
fMakeDir("C:\Temp\")
END

IF HTransactionStart("C:\Temp\Transaction.trs","XML_01_infNFe,XML_02_ide,XML_03_emit,XML_04_enderEmit,XML_05_dest,XML_06_enderDest,XML_07_retirada,XML_08_entrega,XML_09_det,XML_10_prod,XML_11_ICMS00,XML_12_PISAliq,XML_13_COFINSAliq,XML_14_ICMSTot,XML_15_transp,XML_16_transporta,XML_17_veicTransp,XML_18_reboque,XML_19_vol,XML_20_infAdic") = True

WHEN EXCEPTION IN

RESULTADO is xmlDocument <Description="XMLEXEMPLO"> = XMLOpen(EDT_xml,fromFile)

Tipo is string = COMBO_Tipo..DisplayedValue

//TOTAL DE ITENS
BufResultado is Buffer = fLoadText(EDT_xml)
nPosIni is int = PositionOccurrence(BufResultado,"<det nItem=",lastRank,FromBeginning) + 12
nPosFim is int = PositionOccurrence(BufResultado,"<prod>",lastRank,FromBeginning) -4
nTOTAL_ITENS is int = Val( Middle(BufResultado,nPosIni,nPosFim-nPosIni) )

//EDT_Result += CR+CR+"//ID"+CR+CR
nCHAVE_N01, nCHAVE_N02, nCHAVE_N03, nCHAVE_N04, nCHAVE_N05 is 8-bytes int

//Cabeçalho
gsNfeID is string = RESULTADO.NFe.infNFe:Id
XML_01_infNFe.Id = RESULTADO.NFe.infNFe:Id
EDT_Nfe = RESULTADO.NFe.infNFe:Id
XML_01_infNFe.Tipo= Tipo

bAchou is boolean
IF HReadSeek(XML_01_infNFe,XML_01_infNFe.Id,gsNfeID,hIdentical) = True THEN
bAchou = True
nCHAVE_N01 = XML_01_infNFe.CHAVE_N01
bOk1 = HModify(XML_01_infNFe)
//reimportando e excluindo os itens e o total da nota
HReset(XML_14_ICMSTot)
IF HReadSeek(XML_14_ICMSTot,CHAVE_N01,nCHAVE_N01,hIdentical) = True THEN
HDelete(XML_14_ICMSTot)
END

HReset(XML_13_COFINSAliq)
IF HReadSeek(XML_13_COFINSAliq,CHAVE_N01,nCHAVE_N01,hIdentical) = True THEN
FOR EACH XML_13_COFINSAliq
IF XML_13_COFINSAliq.CHAVE_N01 = nCHAVE_N01
HDelete(XML_13_COFINSAliq)
END
END
END

HReset(XML_12_PISAliq)
IF HReadSeek(XML_12_PISAliq,CHAVE_N01,nCHAVE_N01,hIdentical) = True THEN
FOR EACH XML_12_PISAliq
IF XML_12_PISAliq.CHAVE_N01 = nCHAVE_N01
HDelete(XML_12_PISAliq)
END
END
END

HReset(XML_11_ICMS00)
IF HReadSeek(XML_11_ICMS00,CHAVE_N01,nCHAVE_N01,hIdentical) = True THEN
FOR EACH XML_11_ICMS00
IF XML_11_ICMS00.CHAVE_N01 = nCHAVE_N01
HDelete(XML_11_ICMS00)
END
END
END

HReset(XML_10_prod)
IF HReadSeek(XML_10_prod,gsNfeID,gsNfeID,hIdentical) = True THEN
FOR EACH XML_10_prod
IF XML_10_prod.gsNfeID = gsNfeID
HDelete(XML_10_prod)
END
END
END

HReset(XML_09_det)
IF HReadSeek(XML_09_det,CHAVE_N01,nCHAVE_N01,hIdentical) = True THEN
FOR EACH XML_09_det
IF XML_09_det.CHAVE_N01 = nCHAVE_N01
HDelete(XML_09_det)
END
END
END
ELSE
bAchou = False
XML_01_infNFe.CHAVE_N01 = GET_SEQ("XML_01_infNFe")
nCHAVE_N01 = XML_01_infNFe.CHAVE_N01
bOk1 = HAdd(XML_01_infNFe)
IF bOk1 = False THEN
nErros+=1
Info("xml_01")
END
END


IF bOk1 = True THEN

EDT_Chave = nCHAVE_N01
//EDT_Result += CR+CR+"//IDE"+CR+CR
XML_02_ide.CHAVE_N01= nCHAVE_N01
XML_02_ide.cUF = RESULTADO.NFe.infNFe.ide.cUF
XML_02_ide.cNF = RESULTADO.NFe.infNFe.ide.cNF
XML_02_ide.natOp = RESULTADO.NFe.infNFe.ide.natOp
XML_02_ide.indPag = RESULTADO.NFe.infNFe.ide.indPag
XML_02_ide.mod = RESULTADO.NFe.infNFe.ide.mod
XML_02_ide.serie = RESULTADO.NFe.infNFe.ide.serie
XML_02_ide.nNF = RESULTADO.NFe.infNFe.ide.nNF
XML_02_ide.dEmi = RESULTADO.NFe.infNFe.ide.dEmi
XML_02_ide.dSaiEnt = RESULTADO.NFe.infNFe.ide.dSaiEnt
XML_02_ide.tpNF = RESULTADO.NFe.infNFe.ide.tpNF
XML_02_ide.cMunFG = RESULTADO.NFe.infNFe.ide.cMunFG
XML_02_ide.tpImp = RESULTADO.NFe.infNFe.ide.tpImp
XML_02_ide.tpEmis = RESULTADO.NFe.infNFe.ide.tpEmis
XML_02_ide.cDV = RESULTADO.NFe.infNFe.ide.cDV
XML_02_ide.tpAmb = RESULTADO.NFe.infNFe.ide.tpAmb
XML_02_ide.finNFe = RESULTADO.NFe.infNFe.ide.finNFe
XML_02_ide.procEmi = RESULTADO.NFe.infNFe.ide.procEmi
XML_02_ide.verProc = RESULTADO.NFe.infNFe.ide.verProc

IF bAchou = False THEN

bOk2 = HAdd(XML_02_ide)

IF bOk2 = False THEN
nErros+=1
Info("XML_02")
END

END

//EDT_Result += CR+CR+"//EMITENTE"+CR+CR
XML_03_emit.CHAVE_N02 = GET_SEQ("XML_03_emit")
XML_03_emit.CHAVE_N01 = nCHAVE_N01
XML_03_emit.CNPJ = RESULTADO.NFe.infNFe.emit.CNPJ
XML_03_emit.xNome = RESULTADO.NFe.infNFe.emit.xNome
XML_03_emit.xFant = RESULTADO.NFe.infNFe.emit.xFant
XML_03_emit.IE = RESULTADO.NFe.infNFe.emit.IE

IF bAchou = False THEN
bOk3 = HAdd(XML_03_emit)
IF bOk3 = False
nErros += 1
Info("xml_03")
ELSE

nCHAVE_N02 = XML_03_emit.CHAVE_N02
//EDT_Result += CR+CR+"//ENDERECO EMITENTE"+CR+CR
XML_04_enderEmit.CHAVE_N01 = nCHAVE_N01
XML_04_enderEmit.CHAVE_N02 = nCHAVE_N02
XML_04_enderEmit.xLgr = RESULTADO.NFe.infNFe.emit.enderEmit.xLgr
XML_04_enderEmit.nro = RESULTADO.NFe.infNFe.emit.enderEmit.nro
XML_04_enderEmit.xCpl = RESULTADO.NFe.infNFe.emit.enderEmit.xCpl
XML_04_enderEmit.xBairro = RESULTADO.NFe.infNFe.emit.enderEmit.xBairro
XML_04_enderEmit.cMun = RESULTADO.NFe.infNFe.emit.enderEmit.cMun
XML_04_enderEmit.xMun = RESULTADO.NFe.infNFe.emit.enderEmit.xMun
XML_04_enderEmit.UF = RESULTADO.NFe.infNFe.emit.enderEmit.UF
XML_04_enderEmit.CEP = RESULTADO.NFe.infNFe.emit.enderEmit.CEP
XML_04_enderEmit.cPais = RESULTADO.NFe.infNFe.emit.enderEmit.cPais
XML_04_enderEmit.xPais = RESULTADO.NFe.infNFe.emit.enderEmit.xPais
XML_04_enderEmit.fone = RESULTADO.NFe.infNFe.emit.enderEmit.fone

IF HAdd(XML_04_enderEmit) = False THEN
nErros+=1
Info("xml_04")
ELSE
CadastrarFornecedor(XML_03_emit.CNPJ,XML_03_emit.xNome,XML_03_emit.IE,XML_04_enderEmit.fone)
END

END

ELSE
bOk3 = False
END


//EDT_Result += CR+CR+"//DESTINO"+CR+CR
XML_05_dest.CHAVE_N01 = nCHAVE_N01
XML_05_dest.CHAVE_N03 = GET_SEQ("XML_05_dest")
XML_05_dest.CNPJ = RESULTADO.NFe.infNFe.dest.CNPJ
XML_05_dest.xNome = RESULTADO.NFe.infNFe.dest.xNome
XML_05_dest.IE = RESULTADO.NFe.infNFe.dest.IE

IF bAchou = False THEN
bOk4 = HAdd(XML_05_dest)
IF bOk4 = False THEN
nErros+=1
Info("XML_05")
ELSE
nCHAVE_N03 = XML_05_dest.CHAVE_N03
//EDT_Result += CR+CR+"//ENDERECO DESTINO"+CR+CR
XML_06_enderDest.CHAVE_N01 = nCHAVE_N01
XML_06_enderDest.CHAVE_N03 = nCHAVE_N03
XML_06_enderDest.xLgr = RESULTADO.NFe.infNFe.dest.enderDest.xLgr
XML_06_enderDest.nro = RESULTADO.NFe.infNFe.dest.enderDest.nro
XML_06_enderDest.xCpl = RESULTADO.NFe.infNFe.dest.enderDest.xCpl
XML_06_enderDest.xBairro = RESULTADO.NFe.infNFe.dest.enderDest.xBairro
XML_06_enderDest.cMun = RESULTADO.NFe.infNFe.dest.enderDest.cMun
XML_06_enderDest.xMun = RESULTADO.NFe.infNFe.dest.enderDest.xMun
XML_06_enderDest.UF = RESULTADO.NFe.infNFe.dest.enderDest.UF
XML_06_enderDest.CEP = RESULTADO.NFe.infNFe.dest.enderDest.CEP
XML_06_enderDest.cPais = RESULTADO.NFe.infNFe.dest.enderDest.cPais
XML_06_enderDest.xPais = RESULTADO.NFe.infNFe.dest.enderDest.xPais
XML_06_enderDest.fone = RESULTADO.NFe.infNFe.dest.enderDest.fone
IF HAdd(XML_06_enderDest) = False THEN
nErros+=1
Info("XML_06")
END

END

END

//EDT_Result += CR+CR+"//RETIRADA"+CR+CR

XML_07_retirada.CHAVE_N01 = nCHAVE_N01
XML_07_retirada.CNPJ = RESULTADO.NFe.infNFe.retirada.CNPJ
XML_07_retirada.xLgr = RESULTADO.NFe.infNFe.retirada.xLgr
XML_07_retirada.nro = RESULTADO.NFe.infNFe.retirada.nro
XML_07_retirada.xCpl = RESULTADO.NFe.infNFe.retirada.xCpl
XML_07_retirada.xBairro = RESULTADO.NFe.infNFe.retirada.xBairro
XML_07_retirada.cMun = RESULTADO.NFe.infNFe.retirada.cMun
XML_07_retirada.xMun = RESULTADO.NFe.infNFe.retirada.xMun
XML_07_retirada.UF = RESULTADO.NFe.infNFe.retirada.UF

IF bAchou = False
IF HAdd(XML_07_retirada) = False THEN
nErros+=1
Info("XML_07")
END
END

//EDT_Result += CR+CR+"//ENTREGA"+CR+CR

XML_08_entrega.CHAVE_N01 = nCHAVE_N01
XML_08_entrega.CNPJ = RESULTADO.NFe.infNFe.entrega.CNPJ
XML_08_entrega.xLgr = RESULTADO.NFe.infNFe.entrega.xLgr
XML_08_entrega.nro = RESULTADO.NFe.infNFe.entrega.nro
XML_08_entrega.xCpl = RESULTADO.NFe.infNFe.entrega.xCpl
XML_08_entrega.xBairro = RESULTADO.NFe.infNFe.entrega.xBairro
XML_08_entrega.cMun = RESULTADO.NFe.infNFe.entrega.cMun
XML_08_entrega.xMun = RESULTADO.NFe.infNFe.entrega.xMun
XML_08_entrega.UF = RESULTADO.NFe.infNFe.entrega.UF

IF bAchou = False
IF HAdd(XML_08_entrega) = False THEN
nErros+=1
Info("XML_08")
END
END

//ITENS PRODUTOS E SERVIÇOS
//========================================================
//========================================================

x is int = 0
LOOP(nTOTAL_ITENS)
x++

XML_09_det.nItem = RESULTADO.NFe.infNFe.det[x]:nItem
XML_09_det.CHAVE_N01 = nCHAVE_N01
XML_09_det.CHAVE_N04 = GET_SEQ("XML_09_det")
nCHAVE_N04 = XML_09_det.CHAVE_N04
bOk4 = HAdd(XML_09_det)

IF bOk4 = True THEN

XML_10_prod.CHAVE_N01 = nCHAVE_N01
XML_10_prod.CHAVE_N04 = nCHAVE_N04
XML_10_prod.gsNfeID = gsNfeID
XML_10_prod.nItem = RESULTADO.NFe.infNFe.det[x]:nItem
XML_10_prod.cProd = RESULTADO.NFe.infNFe.det[x].prod.cProd
XML_10_prod.CORRELACAO_ID = 0
XML_10_prod.PROD_CODIGO_TISS = 0
XML_10_prod.cEAN = RESULTADO.NFe.infNFe.det[x].prod.cEAN
XML_10_prod.xProd = RESULTADO.NFe.infNFe.det[x].prod.xProd
XML_10_prod.CFOP = RESULTADO.NFe.infNFe.det[x].prod.CFOP
XML_10_prod.uCom = RESULTADO.NFe.infNFe.det[x].prod.uCom
XML_10_prod.qCom = RESULTADO.NFe.infNFe.det[x].prod.qCom
XML_10_prod.vUnCom = RESULTADO.NFe.infNFe.det[x].prod.vUnCom
XML_10_prod.vProd = RESULTADO.NFe.infNFe.det[x].prod.vProd
XML_10_prod.cEANTrib = RESULTADO.NFe.infNFe.det[x].prod.cEANTrib
XML_10_prod.uTrib = RESULTADO.NFe.infNFe.det[x].prod.uTrib
XML_10_prod.qTrib = RESULTADO.NFe.infNFe.det[x].prod.qTrib
XML_10_prod.vUnTrib = RESULTADO.NFe.infNFe.det[x].prod.vUnTrib
IF Tipo = "E"
XML_10_prod.EntradaEstoque = 1
XML_10_prod.SaidaEstoque = 0
XML_10_prod.TransfereEstoque = 0
ELSE IF Tipo = "S"
XML_10_prod.EntradaEstoque = 0
XML_10_prod.SaidaEstoque = 1
XML_10_prod.TransfereEstoque = 0
ELSE IF Tipo = "T"
XML_10_prod.EntradaEstoque = 0
XML_10_prod.SaidaEstoque = 0
XML_10_prod.TransfereEstoque = 1
END
XML_10_prod.Processado = 0
XML_10_prod.DataProcessamento= ""
XML_10_prod.AUDT_Data_Add = DateSys()+TimeSys()
XML_10_prod.AUDT_User_Add = GnUserID


IF HAdd(XML_10_prod) = False THEN
nErros+=1
Info("xml_10")
ELSE
IF HReadSeek(F006_APS_PRODUTOS,PROD_NOME,XML_10_prod.xProd,hIdentical) = False THEN
CadastrarProduto(XML_03_emit.CNPJ,XML_10_prod.cProd,XML_10_prod.cEAN,XML_10_prod.xProd,XML_10_prod.uCom)
END
END


//ICMS
XML_11_ICMS00.CHAVE_N01 = nCHAVE_N01
XML_11_ICMS00.CHAVE_N04 = nCHAVE_N04
XML_11_ICMS00.orig = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.orig
XML_11_ICMS00.CST = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.CST
XML_11_ICMS00.modBC = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.modBC
XML_11_ICMS00.vBC = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vBC
XML_11_ICMS00.pICMS = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.pICMS
XML_11_ICMS00.vICMS = RESULTADO.NFe.infNFe.det[x].imposto.ICMS.ICMS00.vICMS

IF HAdd(XML_11_ICMS00) = False THEN
nErros+=1
Info("xml_11")
END

//PIS
XML_12_PISAliq.CHAVE_N01 = nCHAVE_N01
XML_12_PISAliq.CHAVE_N04 = nCHAVE_N04
XML_12_PISAliq.CST = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.CST
XML_12_PISAliq.vBC = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vBC
XML_12_PISAliq.pPIS = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.pPIS
XML_12_PISAliq.vPIS = RESULTADO.NFe.infNFe.det[x].imposto.PIS.PISAliq.vPIS

IF HAdd(XML_12_PISAliq) = False THEN
nErros+=1
Info("xml_12")
END

//COFINS
XML_13_COFINSAliq.CHAVE_N01 = nCHAVE_N01
XML_13_COFINSAliq.CHAVE_N04 = nCHAVE_N04
XML_13_COFINSAliq.CST = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.CST
XML_13_COFINSAliq.vBC = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vBC
XML_13_COFINSAliq.pCOFINS = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.pCOFINS
XML_13_COFINSAliq.vCOFINS = RESULTADO.NFe.infNFe.det[x].imposto.COFINS.COFINSAliq.vCOFINS

IF HAdd(XML_13_COFINSAliq) = False THEN
nErros+=1
Info("xml_13")
END

ELSE
nErros+=1
Info("XML_09")
END


//EDT_Result += CR+CR+"//ITENS PRODUTOS E SERVIÇOS - FIM//"+CR+CR
END

//========================================================
//========================================================

//EDT_Result += CR+CR+"//TOTAL"+CR+CR

XML_14_ICMSTot.CHAVE_N01 = nCHAVE_N01
XML_14_ICMSTot.vBC = RESULTADO.NFe.infNFe.total.ICMSTot.vBC
XML_14_ICMSTot.vICMS = RESULTADO.NFe.infNFe.total.ICMSTot.vICMS
XML_14_ICMSTot.vBCST = RESULTADO.NFe.infNFe.total.ICMSTot.vBCST
XML_14_ICMSTot.vST = RESULTADO.NFe.infNFe.total.ICMSTot.vST
XML_14_ICMSTot.vProd = RESULTADO.NFe.infNFe.total.ICMSTot.vProd
XML_14_ICMSTot.vFrete = RESULTADO.NFe.infNFe.total.ICMSTot.vFrete
XML_14_ICMSTot.vSeg = RESULTADO.NFe.infNFe.total.ICMSTot.vSeg
XML_14_ICMSTot.vDesc = RESULTADO.NFe.infNFe.total.ICMSTot.vDesc
XML_14_ICMSTot.vII = RESULTADO.NFe.infNFe.total.ICMSTot.vII
XML_14_ICMSTot.vIPI = RESULTADO.NFe.infNFe.total.ICMSTot.vIPI
XML_14_ICMSTot.vPIS = RESULTADO.NFe.infNFe.total.ICMSTot.vPIS
XML_14_ICMSTot.vCOFINS = RESULTADO.NFe.infNFe.total.ICMSTot.vCOFINS
XML_14_ICMSTot.vOutro = RESULTADO.NFe.infNFe.total.ICMSTot.vOutro
XML_14_ICMSTot.vNF = RESULTADO.NFe.infNFe.total.ICMSTot.vNF

IF HAdd(XML_14_ICMSTot) = False THEN
nErros+=1
Info("xml_14")
END


//EDT_Result += CR+CR+"//TRANSPORTADORA"+CR+CR

XML_15_transp.CHAVE_N01 = nCHAVE_N01
XML_15_transp.CHAVE_N05 = GET_SEQ("XML_15_transp")
XML_15_transp.modFrete = RESULTADO.NFe.infNFe.transp.modFrete

IF bAchou = False THEN
bOk5 = HAdd(XML_15_transp)
IF bOk5 = False
nErros+=1
Info("xml_15")
ELSE

nCHAVE_N05 = XML_15_transp.CHAVE_N05
XML_16_transporta.CHAVE_N01 = nCHAVE_N01
XML_16_transporta.CHAVE_N05 = nCHAVE_N05
XML_16_transporta.modFrete = RESULTADO.NFe.infNFe.transp.modFrete
XML_16_transporta.CNPJ = RESULTADO.NFe.infNFe.transp.transporta.CNPJ
XML_16_transporta.xNome = RESULTADO.NFe.infNFe.transp.transporta.xNome
XML_16_transporta.IE = RESULTADO.NFe.infNFe.transp.transporta.IE
XML_16_transporta.xEnder = RESULTADO.NFe.infNFe.transp.transporta.xEnder
XML_16_transporta.xMun = RESULTADO.NFe.infNFe.transp.transporta.xMun
XML_16_transporta.UF = RESULTADO.NFe.infNFe.transp.transporta.UF

IF bAchou = False
IF HAdd(XML_16_transporta) = False THEN
nErros+=1
Info("xml_16")
END
END

//EDT_Result += CR+CR+"//VEICULO"+CR+CR
XML_17_veicTransp.CHAVE_N01 = nCHAVE_N01
XML_17_veicTransp.CHAVE_N05 = nCHAVE_N05
XML_17_veicTransp.placa = RESULTADO.NFe.infNFe.transp.veicTransp.placa
XML_17_veicTransp.UF = RESULTADO.NFe.infNFe.transp.veicTransp.UF
XML_17_veicTransp.RNTC = RESULTADO.NFe.infNFe.transp.veicTransp.RNTC

IF bAchou = False
IF HAdd(XML_17_veicTransp) = False THEN
nErros+=1
Info("xml_17")
END
END

//EDT_Result += CR+CR+"//VEICULO REBOQUE"+CR+CR

XML_18_reboque.CHAVE_N01 = nCHAVE_N01
XML_18_reboque.CHAVE_N05 = nCHAVE_N05
XML_18_reboque.placa = RESULTADO.NFe.infNFe.transp.reboque.placa
XML_18_reboque.UF = RESULTADO.NFe.infNFe.transp.reboque.UF
XML_18_reboque.RNTC = RESULTADO.NFe.infNFe.transp.reboque.RNTC

IF bAchou = False
IF HAdd(XML_18_reboque) = False THEN
nErros+=1
Info("xml_18")
END
END

//EDT_Result += CR+CR+"//VOLUMES"+CR+CR

XML_19_vol.CHAVE_N01 = nCHAVE_N01
XML_19_vol.CHAVE_N05 = nCHAVE_N05
XML_19_vol.qVol = RESULTADO.NFe.infNFe.transp.vol.qVol
XML_19_vol.esp = RESULTADO.NFe.infNFe.transp.vol.esp
XML_19_vol.marca = RESULTADO.NFe.infNFe.transp.vol.marca
XML_19_vol.nVol = RESULTADO.NFe.infNFe.transp.vol.nVol
XML_19_vol.pesoL = RESULTADO.NFe.infNFe.transp.vol.pesoL
XML_19_vol.pesoB = RESULTADO.NFe.infNFe.transp.vol.pesoB
XML_19_vol.nLacre = RESULTADO.NFe.infNFe.transp.vol.lacres.nLacre

IF bAchou = False
IF HAdd(XML_19_vol) = False THEN
nErros+=1
Info("xml_19")
END
END

END

END

//EDT_Result += CR+CR+"//INFORMAÇÕES ADICIONAIS"+CR+CR
XML_20_infAdic.CHAVE_N01 = nCHAVE_N01
XML_20_infAdic.infAdFisco = RESULTADO.NFe.infNFe.infAdic.infAdFisco
XML_20_infAdic.CERTIFICADO = RESULTADO.NFe.Signature.KeyInfo.X509Data.X509Certificate

IF bAchou = False
IF HAdd(XML_20_infAdic) = False THEN
nErros += 1
Info("xml_20")
END
END


ELSE
nErros += 1
Info("erro 1")
END


// Validate the addition
IF nErros = 0 //AND HError() = 0

IF HTransactionEnd() = True THEN
ToastDisplay("Gravou com sucesso!",toastLong,vaMiddle,haCenter)
ELSE
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro 01: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

ELSE IF nErros > 0 //OR HError() <> 0
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro 02: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

DO
IF ErrorInfo() = 0 AND HErrorInfo() = 0 THEN
IF HTransactionEnd() = True THEN
Info("Erros: "+nErros)
ToastDisplay("Gravou com sucesso!",toastLong,vaMiddle,haCenter)
ELSE
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro 01: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END
ELSE
// Delete the order lines
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro 03: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END
END

ELSE
HTransactionCancel()
Info("Algo ocorreu de errado e a nota nao foi importada!")
Info("Erro 04: "+ ErrorInfo() +" - "+HError() +" - "+ HErrorInfo())
END

TableDisplay(TABLEGRID_XML_10_prod,taInit)
TableDisplay(TABLEGRID_XML_10_prod,taReExecuteQuery)

//<infNFe Id="NFe35080599999090910270550010000000015180051273" versao="1.10">
//<ide>
//<cUF>35</cUF>
//<cNF>518005127</cNF>
//<natOp>Venda a vista</natOp>
//<indPag>0</indPag>
//<mod>55</mod>
//<serie>1</serie>
//<nNF>1</nNF>
//<dEmi>2008-05-06</dEmi>
//<dSaiEnt>2008-05-06</dSaiEnt>
//<tpNF>0</tpNF>
//<cMunFG>3550308</cMunFG>
//<tpImp>1</tpImp>
//<tpEmis>1</tpEmis>
//<cDV>3</cDV>
//<tpAmb>2</tpAmb>
//<finNFe>1</finNFe>
//<procEmi>0</procEmi>
//<verProc>NF-eletronica.com</verProc>
//</ide>
//<emit>
//<CNPJ>99999090910270</CNPJ>
//<xNome>NF-e Associacao NF-e</xNome>
//<xFant>NF-e</xFant>
//<enderEmit>
//<xLgr>Rua Central</xLgr>
//<nro>100</nro>
//<xCpl>Fundos</xCpl>
//<xBairro>Distrito Industrial</xBairro>
//<cMun>3502200</cMun>
//<xMun>Angatuba</xMun>
//<UF>SP</UF>
//<CEP>17100171</CEP>
//<cPais>1058</cPais>
//<xPais>Brasil</xPais>
//<fone>1733021717</fone>
//</enderEmit>
//<IE>123456789012</IE>
//</emit>
//<dest> -----------------------
//<CNPJ>00000000000191</CNPJ>
//<xNome>DISTRIBUIDORA DE AGUAS MINERAIS</xNome>
//<enderDest>
//<xLgr>AV DAS FONTES</xLgr>
//<nro>1777</nro>
//<xCpl>10 ANDAR</xCpl>
//<xBairro>PARQUE FONTES</xBairro>
//<cMun>5030801</cMun>
//<xMun>Sao Paulo</xMun>
//<UF>SP</UF>
//<CEP>13950000</CEP>
//<cPais>1058</cPais>
//<xPais>BRASIL</xPais>
//<fone>1932011234</fone>
//</enderDest>
//<IE> </IE>
//</dest>------------------------
//<retirada>
//<CNPJ>99171171000194</CNPJ>
//<xLgr>AV PAULISTA</xLgr>
//<nro>12345</nro>
//<xCpl>TERREO</xCpl>
//<xBairro>CERQUEIRA CESAR</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</retirada>------------------
//<entrega>
//<CNPJ>99299299000194</CNPJ>
//<xLgr>AV FARIA LIMA</xLgr>
//<nro>1500</nro>
//<xCpl>15 ANDAR</xCpl>
//<xBairro>PINHEIROS</xBairro>
//<cMun>3550308</cMun>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</entrega>---------------------
//<det nItem="1">
//<prod>
//<cProd>00001</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>dz</uCom>
//<qCom>1000000.0000</qCom>
//<vUnCom>1</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>12000000.0000</qTrib>
//<vUnTrib>1</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//<det nItem="2">
//<prod>
//<cProd>00002</cProd>
//<cEAN></cEAN>
//<xProd>Agua Mineral</xProd>
//<CFOP>5101</CFOP>
//<uCom>pack</uCom>
//<qCom>5000000.0000</qCom>
//<vUnCom>2</vUnCom>
//<vProd>10000000.00</vProd>
//<cEANTrib></cEANTrib>
//<uTrib>und</uTrib>
//<qTrib>3000000.0000</qTrib>
//<vUnTrib>0.3333</vUnTrib>
//</prod>
//<imposto>
//<ICMS>
//<ICMS00>
//<orig>0</orig>
//<CST>00</CST>
//<modBC>0</modBC>
//<vBC>10000000.00</vBC>
//<pICMS>18.00</pICMS>
//<vICMS>1800000.00</vICMS>
//</ICMS00>
//</ICMS>
//<PIS>
//<PISAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pPIS>0.65</pPIS>
//<vPIS>65000</vPIS>
//</PISAliq>
//</PIS>
//<COFINS>
//<COFINSAliq>
//<CST>01</CST>
//<vBC>10000000.00</vBC>
//<pCOFINS>2.00</pCOFINS>
//<vCOFINS>200000.00</vCOFINS>
//</COFINSAliq>
//</COFINS>
//</imposto>
//</det>
//----------------------------
//<total>
//<ICMSTot>
//<vBC>20000000.00</vBC>
//<vICMS>18.00</vICMS>
//<vBCST>0</vBCST>
//<vST>0</vST>
//<vProd>20000000.00</vProd>
//<vFrete>0</vFrete>
//<vSeg>0</vSeg>
//<vDesc>0</vDesc>
//<vII>0</vII>
//<vIPI>0</vIPI>
//<vPIS>130000.00</vPIS>
//<vCOFINS>400000.00</vCOFINS>
//<vOutro>0</vOutro>
//<vNF>20000000.00</vNF>
//</ICMSTot>
//</total>
//<transp>
//<modFrete>0</modFrete>
//<transporta>
//<CNPJ>99171171000191</CNPJ>
//<xNome>Distribuidora de Bebidas Fazenda de SP Ltda.</xNome>
//<IE>171999999119</IE>
//<xEnder>Rua Central 100 - Fundos - Distrito Industrial</xEnder>
//<xMun>SAO PAULO</xMun>
//<UF>SP</UF>
//</transporta>
//<veicTransp>
//<placa>BXI1717</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</veicTransp>
//<reboque>
//<placa>BXI1818</placa>
//<UF>SP</UF>
//<RNTC>123456789</RNTC>
//</reboque>
//<vol>
//<qVol>10000</qVol>
//<esp>CAIXA</esp>
//<marca>LINDOYA</marca>
//<nVol>500</nVol>
//<pesoL>1000000000.000</pesoL>
//<pesoB>1200000000.000</pesoB>
//<lacres>
//<nLacre>XYZ10231486</nLacre>
//</lacres>
//</vol>
//</transp>
//<infAdic>
//<infAdFisco>Nota Fiscal de exemplo NF-eletronica.com</infAdFisco>
//</infAdic>
//</infNFe>
//<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
// <SignedInfo>
// <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
// <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
// <Reference URI="#NFe35080599999090910270550010000000015180051273">
// <Transforms>
// <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
// <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></Transform>
// </Transforms>
// <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
// <DigestValue>xhTSDMH61e9uqe04lnoHT4ZzLSY=</DigestValue>
// </Reference>
// </SignedInfo>
// <SignatureValue>Iz5Z3PLQbzZt9jnBtr6xsmHZMOu/3plXG9xxfFjRCQYGnD1rjlhzBGrqt026Ca2VHHM/bHNepi6FuFkAi595GScKVuHREUotzifE2OIjgavvTOrMwbXG7+0LYgkwPFiPCao2S33UpZe7MneaxcmKQGKQZw1fP8fsWmaQ4cczZT8=</SignatureValue>
//<KeyInfo>
//<X509Data>
//<X509Certificate>cxvkkPolDUyBa7d7xwgm</X509Certificate>
//</X509Data>
//</KeyInfo>
//</Signature>
//</NFe>

ELSE

Info("Não existe o arquivo ou nao informado/encontrado")

END


Efetiva estoque

//1 : Sim
//2 : Não
SWITCH Dialog("Deseja dar entrada no estoque?")
// Sim
CASE 1

HReset(XML_10_prod_efetivo)
HReadSeek(XML_10_prod_efetivo,gsNfeID,EDT_Nfe,hIdentical)
FOR EACH XML_10_prod_efetivo
IF XML_10_prod_efetivo.gsNfeID = EDT_Nfe THEN
HDelete(XML_10_prod_efetivo)
END
END

HReset(XML_10_prod)
HReadSeek(XML_10_prod,gsNfeID,EDT_Nfe,hIdentical)
FOR EACH XML_10_prod
IF XML_10_prod.gsNfeID = EDT_Nfe
XML_10_prod_efetivo <= XML_10_prod
XML_10_prod_efetivo.Processado = 1
XML_10_prod_efetivo.DataProcessamento = DateSys() + TimeSys()
HAdd(XML_10_prod_efetivo)
END
END




// Não
CASE 2

END

ToastDisplay("Processamento Finalizado!")
TableDisplay(TABLEGRID_XML_10_prod_efetivo,taReExecuteQuery)


Tabelas estrutura

-- Script generated by WINDEV on 18/06/2019 14:00:43
-- Tables of SIIS_ANA.wda analysis
-- for Oracle

-- Deleting the XML_01_infNFe table
DROP TABLE XML_01_infNFe CASCADE CONSTRAINTS ;
-- Creating the XML_01_infNFe table
CREATE TABLE XML_01_infNFe (
Id NVARCHAR2 (255) DEFAULT NULL UNIQUE ,
versao NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) NOT NULL UNIQUE ,
Tipo VARCHAR2(1) );

-- Deleting the XML_02_ide table
DROP TABLE XML_02_ide CASCADE CONSTRAINTS ;
-- Creating the XML_02_ide table
CREATE TABLE XML_02_ide (
cUF NVARCHAR2 (255) DEFAULT NULL,
cNF NVARCHAR2 (255) DEFAULT NULL,
natOp NVARCHAR2 (255) DEFAULT NULL,
indPag NVARCHAR2 (255) DEFAULT NULL,
mod NVARCHAR2 (255) DEFAULT NULL,
serie NVARCHAR2 (255) DEFAULT NULL,
nNF NVARCHAR2 (255) DEFAULT NULL,
dEmi NVARCHAR2 (255) DEFAULT NULL,
dSaiEnt NVARCHAR2 (255) DEFAULT NULL,
tpNF NVARCHAR2 (255) DEFAULT NULL,
cMunFG NVARCHAR2 (255) DEFAULT NULL,
tpImp NVARCHAR2 (255) DEFAULT NULL,
tpEmis NVARCHAR2 (255) DEFAULT NULL,
cDV NVARCHAR2 (255) DEFAULT NULL,
tpAmb NVARCHAR2 (255) DEFAULT NULL,
finNFe NVARCHAR2 (255) DEFAULT NULL,
procEmi NVARCHAR2 (255) DEFAULT NULL,
verProc NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_02_ide_CHAVE_N01 ON XML_02_ide (CHAVE_N01);

-- Deleting the XML_03_emit table
DROP TABLE XML_03_emit CASCADE CONSTRAINTS ;
-- Creating the XML_03_emit table
CREATE TABLE XML_03_emit (
CNPJ NVARCHAR2 (255) DEFAULT NULL,
xNome NVARCHAR2 (255) DEFAULT NULL,
xFant NVARCHAR2 (255) DEFAULT NULL,
IE NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N02 NUMERIC(19,0) DEFAULT 0 NOT NULL UNIQUE );
CREATE INDEX WDIDX_XML_03_emit_CHAVE_N01 ON XML_03_emit (CHAVE_N01);

-- Deleting the XML_04_enderEmit table
DROP TABLE XML_04_enderEmit CASCADE CONSTRAINTS ;
-- Creating the XML_04_enderEmit table
CREATE TABLE XML_04_enderEmit (
xLgr NVARCHAR2 (255) DEFAULT NULL,
nro NVARCHAR2 (255) DEFAULT NULL,
xCpl NVARCHAR2 (255) DEFAULT NULL,
xBairro NVARCHAR2 (255) DEFAULT NULL,
cMun NVARCHAR2 (255) DEFAULT NULL,
xMun NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CEP NVARCHAR2 (255) DEFAULT NULL,
cPais NVARCHAR2 (255) DEFAULT NULL,
xPais NVARCHAR2 (255) DEFAULT NULL,
fone NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N02 NUMERIC(19,0) ,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_04_enderEmit_CH00079 ON XML_04_enderEmit (CHAVE_N02);
CREATE INDEX WDIDX_XML_04_enderEmit_CH00080 ON XML_04_enderEmit (CHAVE_N01);

-- Deleting the XML_05_dest table
DROP TABLE XML_05_dest CASCADE CONSTRAINTS ;
-- Creating the XML_05_dest table
CREATE TABLE XML_05_dest (
CNPJ NVARCHAR2 (255) DEFAULT NULL,
xNome NVARCHAR2 (255) DEFAULT NULL,
IE NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N03 NUMERIC(19,0) DEFAULT 0 NOT NULL UNIQUE );
CREATE INDEX WDIDX_XML_05_dest_CHAVE_N01 ON XML_05_dest (CHAVE_N01);

-- Deleting the XML_06_enderDest table
DROP TABLE XML_06_enderDest CASCADE CONSTRAINTS ;
-- Creating the XML_06_enderDest table
CREATE TABLE XML_06_enderDest (
xLgr NVARCHAR2 (255) DEFAULT NULL,
nro NVARCHAR2 (255) DEFAULT NULL,
xCpl NVARCHAR2 (255) DEFAULT NULL,
xBairro NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N03 NUMERIC(19,0) DEFAULT 0,
cMun NVARCHAR2 (255) DEFAULT NULL,
xMun NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CEP NVARCHAR2 (255) DEFAULT NULL,
cPais NVARCHAR2 (255) DEFAULT NULL,
xPais NVARCHAR2 (255) DEFAULT NULL,
fone NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_06_enderDest_CH00081 ON XML_06_enderDest (CHAVE_N03);
CREATE INDEX WDIDX_XML_06_enderDest_CH00082 ON XML_06_enderDest (CHAVE_N01);

-- Deleting the XML_07_retirada table
DROP TABLE XML_07_retirada CASCADE CONSTRAINTS ;
-- Creating the XML_07_retirada table
CREATE TABLE XML_07_retirada (
CNPJ NVARCHAR2 (255) DEFAULT NULL,
xLgr NVARCHAR2 (255) DEFAULT NULL,
nro NVARCHAR2 (255) DEFAULT NULL,
xCpl NVARCHAR2 (255) DEFAULT NULL,
xBairro NVARCHAR2 (255) DEFAULT NULL,
cMun NVARCHAR2 (255) DEFAULT NULL,
xMun NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_07_retirada_CHA00083 ON XML_07_retirada (CHAVE_N01);

-- Deleting the XML_08_entrega table
DROP TABLE XML_08_entrega CASCADE CONSTRAINTS ;
-- Creating the XML_08_entrega table
CREATE TABLE XML_08_entrega (
CNPJ NVARCHAR2 (255) DEFAULT NULL,
xLgr NVARCHAR2 (255) DEFAULT NULL,
nro NVARCHAR2 (255) DEFAULT NULL,
xCpl NVARCHAR2 (255) DEFAULT NULL,
xBairro NVARCHAR2 (255) DEFAULT NULL,
cMun NVARCHAR2 (255) DEFAULT NULL,
xMun NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_08_entrega_CHAVE_N01 ON XML_08_entrega (CHAVE_N01);

-- Deleting the XML_09_det table
DROP TABLE XML_09_det CASCADE CONSTRAINTS ;
-- Creating the XML_09_det table
CREATE TABLE XML_09_det (
nItem NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N04 NUMERIC(19,0) DEFAULT 0 NOT NULL UNIQUE );
CREATE INDEX WDIDX_XML_09_det_CHAVE_N01 ON XML_09_det (CHAVE_N01);

-- Deleting the XML_10_prod table
DROP TABLE XML_10_prod CASCADE CONSTRAINTS ;
-- Creating the XML_10_prod table
CREATE TABLE XML_10_prod (
CORRELACAO_ID NUMERIC(19,0) DEFAULT 0,
cProd NVARCHAR2 (255) DEFAULT NULL,
PROD_CODIGO_TISS NUMERIC(19,0) DEFAULT 0,
CHAVE_N04 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
cEAN NVARCHAR2 (255) DEFAULT NULL,
xProd NVARCHAR2 (255) DEFAULT NULL,
CFOP NVARCHAR2 (255) DEFAULT NULL,
uCom NVARCHAR2 (255) DEFAULT NULL,
qCom NVARCHAR2 (255) DEFAULT NULL,
vUnCom NVARCHAR2 (255) DEFAULT NULL,
vProd NVARCHAR2 (255) DEFAULT NULL,
cEANTrib NVARCHAR2 (255) DEFAULT NULL,
uTrib NVARCHAR2 (255) DEFAULT NULL,
qTrib NVARCHAR2 (255) DEFAULT NULL,
vUnTrib NVARCHAR2 (255) DEFAULT NULL,
nItem NVARCHAR2 (255) ,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0,
EntradaEstoque VARCHAR2(1) ,
SaidaEstoque VARCHAR2(1) ,
Processado VARCHAR2(1) ,
DataProcessamento DATE ,
AUDT_User_Add NUMERIC(19,0) DEFAULT 0,
AUDT_User_Update NUMERIC(19,0) DEFAULT 0,
AUDT_User_Del NUMERIC(19,0) DEFAULT 0,
AUDT_Data_Add DATE ,
AUDT_Data_Update DATE ,
AUDT_Data_Del DATE ,
gsNfeID VARCHAR2(50) ,
TransfereEstoque VARCHAR2(1) ,
uComEstoque VARCHAR2(255) ,
vComEstoque VARCHAR2(255) ,
vUnComEstoque VARCHAR2(255) ,
vProdEstoque VARCHAR2(255) );
CREATE INDEX WDIDX_XML_10_prod_CORRELA00084 ON XML_10_prod (CORRELACAO_ID);
CREATE INDEX WDIDX_XML_10_prod_cProd ON XML_10_prod (cProd);
CREATE INDEX WDIDX_XML_10_prod_PROD_CO00085 ON XML_10_prod (PROD_CODIGO_TISS);
CREATE INDEX WDIDX_XML_10_prod_cEAN ON XML_10_prod (cEAN);
CREATE INDEX WDIDX_XML_10_prod_xProd ON XML_10_prod (xProd);
CREATE INDEX WDIDX_XML_10_prod_nItem ON XML_10_prod (nItem);
CREATE INDEX WDIDX_XML_10_prod_CHAVE_N01 ON XML_10_prod (CHAVE_N01);
CREATE INDEX WDIDX_XML_10_prod_gsNfeID ON XML_10_prod (gsNfeID);

-- Deleting the XML_10_prod_efetivo table
DROP TABLE XML_10_prod_efetivo CASCADE CONSTRAINTS ;
-- Creating the XML_10_prod_efetivo table
CREATE TABLE XML_10_prod_efetivo (
cProd NVARCHAR2 (255) DEFAULT NULL,
PROD_CODIGO_TISS NUMERIC(19,0) DEFAULT 0,
CHAVE_N04 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
cEAN NVARCHAR2 (255) DEFAULT NULL,
xProd NVARCHAR2 (255) DEFAULT NULL,
CFOP NVARCHAR2 (255) DEFAULT NULL,
uCom NVARCHAR2 (255) DEFAULT NULL,
qCom NVARCHAR2 (255) DEFAULT NULL,
vUnCom NVARCHAR2 (255) DEFAULT NULL,
vProd NVARCHAR2 (255) DEFAULT NULL,
cEANTrib NVARCHAR2 (255) DEFAULT NULL,
uTrib NVARCHAR2 (255) DEFAULT NULL,
qTrib NVARCHAR2 (255) DEFAULT NULL,
vUnTrib NVARCHAR2 (255) DEFAULT NULL,
CORRELACAO_ID NUMERIC(19,0) ,
nItem NVARCHAR2 (255) ,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0,
AUDT_User_Add NUMERIC(19,0) DEFAULT 0,
AUDT_User_Update NUMERIC(19,0) DEFAULT 0,
AUDT_User_Del NUMERIC(19,0) DEFAULT 0,
AUDT_Data_Add DATE ,
AUDT_Data_Update DATE ,
AUDT_Data_Del DATE ,
EntradaEstoque VARCHAR2(1) ,
SaidaEstoque VARCHAR2(1) ,
Processado VARCHAR2(1) ,
DataProcessamento DATE ,
gsNfeID VARCHAR2(50) ,
TransfereEstoque VARCHAR2(1) ,
uComEstoque VARCHAR2(255) ,
vComEstoque VARCHAR2(255) ,
vUnComEstoque VARCHAR2(255) ,
vProdEstoque VARCHAR2(255) );
CREATE INDEX WDIDX_XML_10_prod_efetivo00086 ON XML_10_prod_efetivo (cProd);
CREATE INDEX WDIDX_XML_10_prod_efetivo00087 ON XML_10_prod_efetivo (PROD_CODIGO_TISS);
CREATE INDEX WDIDX_XML_10_prod_efetivo_cEAN ON XML_10_prod_efetivo (cEAN);
CREATE INDEX WDIDX_XML_10_prod_efetivo00088 ON XML_10_prod_efetivo (xProd);
CREATE INDEX WDIDX_XML_10_prod_efetivo00089 ON XML_10_prod_efetivo (CORRELACAO_ID);
CREATE INDEX WDIDX_XML_10_prod_efetivo00090 ON XML_10_prod_efetivo (nItem);
CREATE INDEX WDIDX_XML_10_prod_efetivo00091 ON XML_10_prod_efetivo (CHAVE_N01);
CREATE INDEX WDIDX_XML_10_prod_efetivo00092 ON XML_10_prod_efetivo (gsNfeID);

-- Deleting the XML_11_ICMS00 table
DROP TABLE XML_11_ICMS00 CASCADE CONSTRAINTS ;
-- Creating the XML_11_ICMS00 table
CREATE TABLE XML_11_ICMS00 (
orig NVARCHAR2 (255) DEFAULT NULL,
CST NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N04 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
modBC NVARCHAR2 (255) DEFAULT NULL,
vBC NVARCHAR2 (255) DEFAULT NULL,
pICMS NVARCHAR2 (255) DEFAULT NULL,
vICMS NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_11_ICMS00_CHAVE_N01 ON XML_11_ICMS00 (CHAVE_N01);

-- Deleting the XML_12_PISAliq table
DROP TABLE XML_12_PISAliq CASCADE CONSTRAINTS ;
-- Creating the XML_12_PISAliq table
CREATE TABLE XML_12_PISAliq (
CST NVARCHAR2 (255) DEFAULT NULL,
vBC NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N04 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
pPIS NVARCHAR2 (255) DEFAULT NULL,
vPIS NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_12_PISAliq_CHAVE_N01 ON XML_12_PISAliq (CHAVE_N01);

-- Deleting the XML_13_COFINSAliq table
DROP TABLE XML_13_COFINSAliq CASCADE CONSTRAINTS ;
-- Creating the XML_13_COFINSAliq table
CREATE TABLE XML_13_COFINSAliq (
CST NVARCHAR2 (255) DEFAULT NULL,
vBC NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N04 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
pCOFINS NVARCHAR2 (255) DEFAULT NULL,
vCOFINS NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_13_COFINSAliq_C00093 ON XML_13_COFINSAliq (CHAVE_N01);

-- Deleting the XML_14_ICMSTot table
DROP TABLE XML_14_ICMSTot CASCADE CONSTRAINTS ;
-- Creating the XML_14_ICMSTot table
CREATE TABLE XML_14_ICMSTot (
vBC NVARCHAR2 (255) DEFAULT NULL,
vICMS NVARCHAR2 (255) DEFAULT NULL,
vBCST NVARCHAR2 (255) DEFAULT NULL,
vST NVARCHAR2 (255) DEFAULT NULL,
vProd NVARCHAR2 (255) DEFAULT NULL,
vFrete NVARCHAR2 (255) DEFAULT NULL,
vSeg NVARCHAR2 (255) DEFAULT NULL,
vDesc NVARCHAR2 (255) DEFAULT NULL,
vII NVARCHAR2 (255) DEFAULT NULL,
vIPI NVARCHAR2 (255) DEFAULT NULL,
vPIS NVARCHAR2 (255) DEFAULT NULL,
vCOFINS NVARCHAR2 (255) DEFAULT NULL,
vOutro NVARCHAR2 (255) DEFAULT NULL,
vNF NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) );
CREATE INDEX WDIDX_XML_14_ICMSTot_CHAVE_N01 ON XML_14_ICMSTot (CHAVE_N01);

-- Deleting the XML_15_transp table
DROP TABLE XML_15_transp CASCADE CONSTRAINTS ;
-- Creating the XML_15_transp table
CREATE TABLE XML_15_transp (
modFrete NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) ,
CHAVE_N05 NUMERIC(19,0) DEFAULT 0 NOT NULL UNIQUE );
CREATE INDEX WDIDX_XML_15_transp_CHAVE_N01 ON XML_15_transp (CHAVE_N01);

-- Deleting the XML_16_transporta table
DROP TABLE XML_16_transporta CASCADE CONSTRAINTS ;
-- Creating the XML_16_transporta table
CREATE TABLE XML_16_transporta (
CNPJ NVARCHAR2 (255) DEFAULT NULL,
xNome NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N05 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
IE NVARCHAR2 (255) DEFAULT NULL,
xEnder NVARCHAR2 (255) DEFAULT NULL,
xMun NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0,
modFrete NVARCHAR2 (255) );
CREATE INDEX WDIDX_XML_16_transporta_C00094 ON XML_16_transporta (CHAVE_N01);

-- Deleting the XML_17_veicTransp table
DROP TABLE XML_17_veicTransp CASCADE CONSTRAINTS ;
-- Creating the XML_17_veicTransp table
CREATE TABLE XML_17_veicTransp (
placa NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N05 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
RNTC NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_17_veicTransp_C00095 ON XML_17_veicTransp (CHAVE_N01);

-- Deleting the XML_18_reboque table
DROP TABLE XML_18_reboque CASCADE CONSTRAINTS ;
-- Creating the XML_18_reboque table
CREATE TABLE XML_18_reboque (
placa NVARCHAR2 (255) DEFAULT NULL,
UF NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N05 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
RNTC NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0);
CREATE INDEX WDIDX_XML_18_reboque_CHAVE_N01 ON XML_18_reboque (CHAVE_N01);

-- Deleting the XML_19_vol table
DROP TABLE XML_19_vol CASCADE CONSTRAINTS ;
-- Creating the XML_19_vol table
CREATE TABLE XML_19_vol (
qVol NVARCHAR2 (255) DEFAULT NULL,
esp NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N05 NUMERIC(19,0) DEFAULT 0 UNIQUE ,
marca NVARCHAR2 (255) DEFAULT NULL,
nVol NVARCHAR2 (255) DEFAULT NULL,
pesoL NVARCHAR2 (255) DEFAULT NULL,
pesoB NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0,
nLacre NVARCHAR2 (255) );
CREATE INDEX WDIDX_XML_19_vol_CHAVE_N01 ON XML_19_vol (CHAVE_N01);

-- Deleting the XML_20_infAdic table
DROP TABLE XML_20_infAdic CASCADE CONSTRAINTS ;
-- Creating the XML_20_infAdic table
CREATE TABLE XML_20_infAdic (
infAdFisco NVARCHAR2 (255) DEFAULT NULL,
CHAVE_N01 NUMERIC(19,0) DEFAULT 0,
CERTIFICADO CLOB );
CREATE INDEX WDIDX_XML_20_infAdic_CHAVE_N01 ON XML_20_infAdic (CHAVE_N01);
-- Integrity constraints
ALTER TABLE XML_06_enderDest ADD FOREIGN KEY (CHAVE_N03) REFERENCES XML_05_dest (CHAVE_N03);
ALTER TABLE XML_04_enderEmit ADD FOREIGN KEY (CHAVE_N02) REFERENCES XML_03_emit (CHAVE_N02);
ALTER TABLE XML_20_infAdic ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_14_ICMSTot ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_09_det ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_08_entrega ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_07_retirada ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_03_emit ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_05_dest ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_15_transp ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_02_ide ADD FOREIGN KEY (CHAVE_N01) REFERENCES XML_01_infNFe (CHAVE_N01);
ALTER TABLE XML_10_prod ADD FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_13_COFINSAliq ADD FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_12_PISAliq ADD FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_11_ICMS00 ADD FOREIGN KEY (CHAVE_N04) REFERENCES XML_09_det (CHAVE_N04);
ALTER TABLE XML_16_transporta ADD FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);
ALTER TABLE XML_17_veicTransp ADD FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);
ALTER TABLE XML_18_reboque ADD FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);
ALTER TABLE XML_19_vol ADD FOREIGN KEY (CHAVE_N05) REFERENCES XML_15_transp (CHAVE_N05);


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/