Bancos
Como configurar o leiaute de remessa de cobrança em formato CNAB 240 para o Banco do Brasil?
BANCOS.CAD_BANCO.FAQ-3114
Ver link com documentação do banco:
http://office.bancobrasil.com.br/office/texto/novidades/anexo.html
Para configurar o arquivo CNAB de remessa de títulos de cobrança para o Banco do Brasil deve ser feita a seguinte configuração no cadastro do banco:
"Aba Banco"
Código do banco no jBoleto: 0
Tamanho do nosso número: 17
Layout CNAB: 240
Dígito do banco: 9
"Aba Carteira"
Código da Carteira: 0
Título: 0
"Aba Retorno"
Código retorno: 02
Descrição do código: entrada confirmada
Histórico: OBSERVACOES
"Aba Movimentos"
Código do Movimento: 01
Título: 01
"Aba Layout ( CNAB )"
= CNAB 240
== Cabeçalho 
=== Sequencia 1:
$str.rightPad($banco.getFebraban(),3,"0") 
$str.repeat("0", 4) 
0 
$str.repeat(" ", 9) 
2 
$str.leftPad($lop.getDocumentoCliente(),14,"0") 
$str.leftPad($lop.retornarConvenio(), 18, "0") 
$str.repeat(" ", 2) 
$str.leftPad($conta.retornoAgencia(), 5, "0") 
$str.rightPad($conta.retornoDigitoAgencia(), 1) 
$str.leftPad($conta.retornoContaCorrente(), 12, "0") 
$str.rightPad($conta.retornoDigitoContaCorrente(), 1 ) 
$str.repeat(" ", 1) 
$str.rightPad($conta.getNomeCedente().toString(),30," ").substring(0,30) 
$str.rightPad($banco.getNomeBanco(),30," ").substring(0,30) 
$str.repeat(" ", 10) 
1 
$str.rightPad($banco.getDataAtual(),8," ") 
$str.rightPad($banco.getHoraAtual(),6," ") 
$str.leftPad($remessa,6,"0") 
030 
$str.repeat("0", 5) 
$str.repeat(" ", 20) 
$str.repeat(" ", 20) 
$str.repeat(" ", 11) 
$str.repeat(" ", 3) 
$str.repeat("0", 3) 
$str.repeat(" ", 2) 
$str.repeat(" ", 10)
=== Sequencia 2
$str.leftPad($banco.getFebraban(),3,"0") 
0001 
1 
R 
01 
00 
020 
$str.repeat(" ", 1) 
2 
$str.leftPad($lop.getDocumentoCliente(),15,"0") 
$str.leftPad($lop.retornarConvenio(), 18, "0") 
$str.repeat(" ", 2) 
$str.leftPad($conta.retornoAgencia(), 5, "0") 
$str.rightPad($conta.retornoDigitoAgencia(), 1) 
$str.leftPad($conta.retornoContaCorrente(), 12, "0") 
$str.rightPad($conta.retornoDigitoContaCorrente(), 1 ) 
$str.repeat(" ", 1) 
$str.rightPad($conta.getNomeCedente().toString(),30," ").substring(0,30) 
$str.repeat(" ", 40) 
$str.repeat(" ", 40) 
$str.leftPad($remessa,8,"0") 
$str.rightPad($banco.getDataAtual(),8," ") 
$str.repeat("0", 8) 
$str.repeat(" ", 33)
== Corpo (títulos)
=== Sequencia 1:
$str.leftPad($banco.getFebraban(),3,"0") 
0001 
3 
$str.leftPad($sequenciaItens,5,"0") 
P 
$str.repeat(" ", 1) 
01 
$str.leftPad($conta.retornoAgencia(), 5, "0") 
$str.rightPad($conta.retornoDigitoAgencia(), 1) 
$str.leftPad($conta.retornoContaCorrente(), 12, "0") 
$str.rightPad($conta.retornoDigitoContaCorrente(), 1 ) 
$str.repeat(" ", 1) 
$str.rightPad($titulo.retornoNossoNumero(),20," ") 
$str.leftPad($lop.retornarCarteira(),1,"0") 
1 
$lop.retornaQuemEmite()#*1 - $titulo.getTipo()*# 
$lop.retornaQuemEmite()#*1 - $titulo.getEmissao()*# 
$lop.retornaQuemEmite()#*1 - $titulo.getDistribui()*# 
$str.rightPad($titulo.retornaNumeroDocumento(), 15," ") 
- $str.leftPad($titulo.getId().toString(),15,"0") numero do titulo *#
 
$str.rightPad($titulo.retornoDataVencimento().toString(),8,"0") 
$str.leftPad($titulo.getSaldo().toText().replace(",", "").replace(".", ""),15,"0") 
$str.repeat("0", 5) 
$str.repeat(" ", 1) 
$str.leftPad($lop.retornarEspecieTitulo(), 2, "0") 
$lop.valueOfAceite()#* Aceite *# 
$str.rightPad($titulo.retornoDataEmissao().toString(),8,"0") 
1 
$str.rightPad($titulo.retornoDataVencimento().toString(),8,"0") 
$str.leftPad($titulo.retornoJuroDia().replace(",", "").replace(".", ""),15,"0") 
0#* Codigo do desconto 1 *# 
$str.repeat("0", 8) 
$str.repeat("0", 15) 
$str.repeat("0", 15) 
$str.repeat("0", 15)#*$str.leftPad($titulo.retornoAbatimento().replace(",", "").replace(".", ""),15,"0")*# 
$str.rightPad($titulo.retornaNumeroDocumento(), 25," ") 
1 
$str.leftPad($lop.getDiasProtesto().toText(), 2, "0") 
2 
$str.repeat("0", 3) 
09 
${str.repeat("0", 10)} 
${str.repeat(" ", 1)}
== Sequencia 2:
$str.leftPad($banco.getFebraban(),3,"0") 
0001 
3 
$str.leftPad($sequenciaItens,5,"0") 
Q 
$str.repeat(" ", 1) 
01 
$str.rightPad($titulo.getPessoaTipo(),1) 
$str.leftPad($titulo.getPessoaDocumento(),15,"0") 
$str.rightPad($titulo.getPessoaNome(),40).substring(0,40) 
$str.rightPad($titulo.getPessoaEnderecoBairro(),40).substring(0,40) 
$str.rightPad(" ",15).substring(0,15) 
$str.rightPad($titulo.getPessoaCep().replace("-", "").replace(".", ""),8).substring(0,8) 
$str.rightPad($titulo.getPessoaCidade(),15).substring(0,15) 
$str.rightPad($titulo.getPessoaUf(),2).substring(0,2) 
$str.repeat("0", 1) 
$str.repeat("0", 15) 
$str.repeat(" ", 40) 
$str.repeat("0", 3) 
$str.repeat(" ", 20) 
$str.repeat(" ", 8)
== Sequencia 3:
${str.leftPad($banco.getFebraban(),3,"0")} 
0001 
3 
$str.leftPad($sequenciaItens,5,"0") 
R 
$str.repeat(" ", 1) 
01 
${str.repeat("0", 1)} 
${str.repeat("0", 8)} 
${str.repeat("0", 15)} 
${str.repeat("0", 1)} 
${str.repeat("0", 8)} 
${str.repeat("0", 15)} 
2 
$str.rightPad($titulo.retornoDataVencimento().toString(),8,"0") 
$str.leftPad($lop.retornarPercentualMulta().replace(",", "").replace(".", ""),15,"0") 
${str.repeat(" ", 10)} 
${str.rightPad( ${titulo.retornarInstrucao(1)} ,40).substring(0,40)} 
${str.rightPad( ${titulo.retornarInstrucao(2)} ,40).substring(0,40)} 
${str.repeat("0", 3)} 
${str.repeat("0", 4)} 
${str.repeat(" ", 13)} 
${str.repeat("0", 8)} 
${str.repeat(" ", 33)}
== Rodapé
=== Sequencia 1:
$str.leftPad($banco.getFebraban(),3,"0") 
0001 
5 
$str.repeat(" ", 9) 
$str.leftPad($sequenciaB,6,"0") 
$str.repeat("0", 6) 
$str.repeat("0", 17) 
$str.repeat("0", 6) 
$str.repeat("0", 17) 
$str.repeat("0", 6) 
$str.repeat("0", 17) 
$str.repeat("0", 6) 
$str.repeat("0", 17) 
$str.repeat(" ", 8) 
$str.repeat(" ", 117)
=== Sequencia 2:
$str.leftPad($banco.getFebraban(),3,"0") 
9999 
9 
$str.repeat(" ", 9) 
$str.leftPad( "1",6,"0") 
$str.leftPad($sequencia,6,"0") 
$str.repeat("0", 6) 
$str.repeat(" ", 205)
Atenção:
Retirar os espaços em branco antes e no final de cada linha de configuração, conforme acima apresentado, pois o Velocity interpreta espaços em branco, o que pode acarretar em problemas na geração dos arquivos ou em seu conteúdo.
OBS: Quando o código estiver funcional e apto para a implementacão no sistema do cliente, tomar cuidado ao copiar e colar, poderá gerar espaços excedentes no final de cada linha.
Configuração dos LOPs para Banco do Brasil