Strange txt symbol that prevents SEFAZ from reading . txt

Asked

Viewed 776 times

-2

I’m generating a file .txt with information from an electronic invoice, this is imported into the free application of the SEFAZ government for note generation.

The genexus is generating the file . txt with special characters.

When you break a page it puts a strange symbol on txt and this prevents SEFAZ from reading the .txt.

I want a procedure to clean these .txt or some other way to fix the problem.

H|7|NF NF: 6155|
I|54| | PAO DE ESPINAFRE|19023000 ||5906|CX |60.0000|97.9200|5875.20| |CX |60.0000|97.9200| | | | |1|||
M
N
N10d|0|400|
Q
Q04|08|
S
S04|08|
W
W02|0.00|0.00|0|0|42980.40|0|0|0|0|0|0|0|0|42980.40|
W23|||||||
X|1||
X03|FELIPPI ARMAZENAGENS LTDA|253175313|25 DE JULHO 870|SC|JARAGUA DO SUL|
X04|00825615000157|
X18||SC||
X26|480||||4212.000|4860.000|
Z||BASE DO CALCULO DO ICMS: 0.00 VALOR DO ICMS: 0.00 EMPRESA OPTANTE PELO SIMPLES NACIONAL
♀

This is an example of the end of a note, after the Z, it generates this character

THEN GENEXUS CONVERTS MY REPORT TEXT MODE INTO A TXT FILE WITH THE NAME I SAVED IN THE VARIABLE &Arqnom below the report source

For Each NotNum
   Where NotNum = &NotNum
      // Capa
      &B = &B +'|'+ Trim(cUF)+'|'+Trim(cNF)+'|'+Trim(NatDesSub)+'|2'+'|'+Trim(cMod)+'|'+Trim(serie)+'|'+Trim(nNF)+'|'+trim(dEmi)+'|'+trim(dSaiEnt)+'|'+trim(hSaiEnt)+'|1'+'|'+Trim(tpNF)+'|'+trim(tpImp)+'|'+trim(tpEmis)+'|'+trim(cDV)+'|'+trim(tpAmb)+'|'+trim(finNFe)+'|'+trim(procEmi)+'|'+trim(verProc)+' |'+'|'+'|'
      &B = Trim(&B)
      &C = &C +'|'+ Trim(xnome)+'|'+'|'+trim(IE)+'|'+'|'+'|'+'|'+'1'+'|'
      &C = Trim(&C)
      &C02 = '|'+ Trim(cnpj)
      &C02 =  Trim(&C02)
      &C05 = &C05 + '|'+ Trim(xLgr)+'|'+trim(nro)+'|'+trim(xCpl)+'|'+trim(xBairro)+'|'+trim(cMun)+'|'+trim(xMun)+'|'+Trim(UF)+'|'+trim(CEP)+'|'+trim(cPais)+'|'+trim(xPais)+'|'+trim(Fone)+'|'
      &C05 = Trim(&C05)
         &X03 = &X03 +'|'+ trim(traxnome)+'|'+trim(traie)+'|'+trim(traxender)+'|'+trim(trauf)+'|'+trim(traxmun)+'|'
         &X03 = trim(&X03)
         &X04 = &X04 +'|'+ Trim(tracnpj)+'|'
         &X04 = trim(&X04)
         &X18 = &X18 +'|'+ trim(traplaca)+'|'+trim(travuf)+'|'+'|'
         &X18 = trim(&X18)
      &E = &E +'|'+ Trim(FxNome)+'|'+Trim(FIE)+'|'+'|'+'|'
      &E = Trim(&E)
      &E02 = &E02 +'|'+ trim(Fcnpj)
      &E02 = trim(&E02)
      &E05 = &E05 +'|'+ Trim(FxLgr)+'|'+trim(Fnro)+'|'+trim(FxCpl)+'|'+trim(FxBairro)+'|'+trim(FcMun)+'|'+trim(FxMun)+'|'+Trim(FUF)+'|'+trim(FCEP)+'|'+trim(FcPais)+'|'+trim(FxPais)+'|'+trim(Ffone)+'|'
      &E05 = Trim(&E05)
      Print capa
      For Each cItem
         Where cImprime = 'S'
         &Item = cItem
         &NotImportada = 'NF '+trim(numnota)
         &NotImportada = trim(&NotImportada)
         &H = &H +'|'+ Trim(str(cItem))+'|'+&NotImportada+'|'
         &H = Trim(&H)
         &vProd = Trim(vProd) + '00000000'
         &I = &I +'|'+ Trim(cProd)+'| '+Trim(cEAN)+'| '+trim(xProd)+'|'+Trim(NCM)+' |'+'|'+trim(CFOP)+'|'+Trim(uCom)+' |'+Trim(qCom)+'|'+Trim(vUnCom)+'|'+trim(vProd)+'|'+' |'+trim(uCom)+' |'+trim(qCom)+'|'+trim(vUnCom)+'| '+'| '+'| '+'| '+'|'+trim(indTot)+'|'+'|'+'|'
         &I = Trim(&I)         
         Do 'N10d'
         Print ITENS
         &H = ''
         &I = ''
     EndFor      
         &W02 = &W02 +'|'+ Trim(totvbc)+'|'+trim(totvicms)+'|'+'0|'+'0|'+trim(totvprod)+'|'+'0|'+'0|'+'0|'+'0|'+'0|'+'0'+'|'+'0'+'|'+'0|'+trim(totvnf)+'|'
         &W02 = trim(&W02)
         &X = &X +'|'+ trim(modfrete)+'|'
         &X = trim(&X)+'|'
         &X26 = &X26 +'|'+ trim(qvol)+'|'+'|'+'|'+'|'+trim(pesol)+'|'+trim(pesob)+'|'
         &X26 = trim(&X26)
         &Z = &Z +'|'+'|'+ 'BASE DO CALCULO DO ICMS: '+ trim(totvbc) + ' VALOR DO ICMS: ' + trim(totvicms) + ' EMPRESA OPTANTE PELO SIMPLES NACIONAL'
         &Z= trim(&Z)
         Print FIM
EndFor

msg('Arquivo TXT gerado com sucesso')

Sub 'N10d'
   &N10d = ''
   &Q04 = ''
   &S04 = ''
   For Each NotNum cItem 
      Where NotNum = &NotNum
      Where cItem  = &Item
      &N10d = &N10d +'|'+'0'+'|'+trim(CST)+'|'
      &N10d = Trim(&N10d)
      &Q04 = &Q04 +'|'+trim(uTrib)+'|'
      &Q04 = trim(&Q04)
      &S04 = &S04 +'|'+ Trim(uTrib)+'|'
      &S04 = Trim(&S04)
      exit
   EndFor
EndSub
//
  • 3

    You had put two tags of languages. Or the problem is with one or the other? Right now? Only with this information is difficult to answer. I would say that the program that is generating this file is putting this character, has to look all the code and take out the code that puts this intruder.

  • 1

    <gambiarra>A very simple way to fix the problem is after the file is generated, open it, delete the and save. </gambiarra>

  • Wouldn’t this character be Ctrl-Z that windows always include at the end of a text file? I don’t know much about visual basic but there must be an option to create the file as "binary"; this should prevent the inclusion of Z at the end.

  • 1

    Where’s your programming question?

1 answer

1

When a text file is created using "Open For Append", a blank line is always placed below the written line. In this case I use the function below to remove the blank line.


    Private Function RemoverLinhaEmBranco(ByVal sTexto As String)

    Dim i                     As Long
    Dim vtrLinhas()           As String
    Dim strTexto              As String

    vtrLinhas = Split(sTexto, vbCrLf)

    For i = LBound(vtrLinhas) To UBound(vtrLinhas)

        If Trim(vtrLinhas(i))  vbNullString Then
            If i = LBound(vtrLinhas) Then
                strTexto = strTexto & vtrLinhas(i)
            Else
                strTexto = strTexto & vbCrLf & vtrLinhas(i)
            End If
        End If

    Next i

    RemoverLinhaEmBranco = strTexto

End Function

  • 1

    Sorry, I didn’t notice it was an answer in my analysis queue, I thought it was a question. I will remove the above comment since it makes no sense. But anyway your answer is not very clear regarding the question, if you can explain a little better what your solution helps to solve the question, it is clearer, for those who read it. (Only that the question also does not help much, I read and re-read the question and did not understand the real problem of OP. Hehe)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.