Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
languagejava
themeMidnight
titleFA150CBR
#INCLUDE "Protheus.CH"

User Function FA150CBR()
    Local cCodBar := ParamIXB
    Local cCodAux := "''
    Local cAux := "''
    Local cNosNum := "''
    Local nSeqCdBr := 2
    Local nFor := 0
    Local nTot := 0

    cNosNum := "1" + Right(Alltrim(NossoNum()), 7)) // Customização do NossoNum

    cCodBar := Left(cCodBar ,22) + cNosNum + Right(cCodBar, 14)

    //Gerar novo DAC MOD11
    cCodAux := Substring(cCodBar, 1, 4) + Substring(cCodBar, 6, 39)

    nSeqCdBr := 2
	For nFor := 1 To 43
		If nSeqCdBr > 9
			nSeqCdBr := 2
		Endif
		cAux := StrZero((nSeqCdBr * Val(Left(Right(cCodAux, nFor), 1))), 2)
		nTot += Val(cAux)
		nSeqCdBr += 1
	Next

	nTot := nTot % 11
	nTot := If(nTot == 0 .Or. nTot == 1 .Or. nTot == 10 .Or. nTot == 11, 1, 11 - nTot)

	cCodBar := Left(cCodAux, 4) + Str(nTot, 1) + Right(cCodAux, 39)

Return cCodBar

...