TOTAL DE PÁGINAS

Dicas e truques sobre Oracle Reports Builder - modo gráfico ou modo caractere, ascii, arquivo .PRT, etc
Responder
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 6
Registrado em: Sex, 07 Jan 2005 9:09 am
Localização: Assis/SP

TUDO BEM GALERA !!!!


GOSTARIA DE SABER COMO CONSIGO TRAZER PARA DENTRO DO UMA FORMULA COLUMN O VALOR DO TOTAL DE PÁGINAS DO RELATÓRIO.


RICARDO
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Cria um boilerplace e coloca o seguinte texto nele:

Selecionar tudo

Página &<PageNumber> de &<TotalPages>
Outra forma é você criar um FIELD e escolher no source ele "Total phisical Pages"
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 6
Registrado em: Sex, 07 Jan 2005 9:09 am
Localização: Assis/SP

CARO DR. GORI...

ESTOU PRECISANDO DE TRAZER O VALOR DO TOTAL DE PÁGINAS PARA DENTRO DE COLUNA FÓRMULA POIS EXECUTAREI CÁLCULOS COM ESTE VALOR.

RICARDO
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Dá uma olhada nesse tópico...
http://glufke.net/oracle/viewtopic.php?t=550

O cara fez algo parecido.
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 6
Registrado em: Sex, 07 Jan 2005 9:09 am
Localização: Assis/SP

ISSO NÃO PODERÁ ME AJUDAR !!!!

COMO O RELATÓRIO É LIVRO FISCAL MICROFILMADO ONDE CADA MICROFILME RECEBE 175 PÁGINAS, NECESSITAREI INFORMAR LOGO NO TERMO DE ABERTURA A QUANTIDADE DE PÁGINAS E A QUANTIDADE DE MICROFILMES = (TOTAL DE PÁGINAS / 175).



RICARDO
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Realmente, essa dica acima não te ajuda, pois você precisa recuperar o TOT PAGE NUM.

Eu achei um post no metalink. Eu testei e funcionou!

Selecionar tudo

Doc ID: 	Note:130432.1
Subject: 	HOW TO PRINT THE REPORT TOTAL PAGES ONLY AT THE LAST PAGE
Type: 	BULLETIN
Status: 	PUBLISHED
	
Content Type: 	TEXT/X-HTML
Creation Date: 	11-DEC-2000
Last Revision Date: 	05-DEC-2001


SCOPE & APPLICATION
-------------------
This document gives a workaround to get the report total pages number
and use it, in the format trigger of a field so that will be printed 
ONLY at the last page of the report.

The problem is that you cannot refer to a field with source total_pages   
in the format trigger of another field without getting the error 'REP-730
The following bind variable is not defined', and also there is not any build 
in function (like srw.get_page_num) to calculate the report total pages.     



HOW TO PRINT REPORT TOTAL PAGES AT LAST PAGE 
--------------------------------------------
 
1. Add in the report 2 fields :  total_pages with source 'Total Pages' and 
page_num with source 'Page Number'.
2. Create in the database a table page_num  to store the number of pages of the 
report.  You can also add in this table another column to store the session id
in order to insert the page numbers with a unique identifier
for this report instance and be able to use this technique for multiple reports.
The description of the table page_num will be:
 Name                            Type
 ------------------------------- ----
 SESSION_ID                      NUMBER(10)
 PAGE_NUM                        NUMBER(10)

(You can also use a local package variable to store the page number instead of 
inserting it in a database table).

In the format trigger of the field total_pages write the following code in order
to get the total pages of the report and insert this number in a table:     

function total_pagesFormatTrigger return boolean is                            
  page_num number;                                                              
  a number(3);                                                                  
begin                                                                           
  srw.get_page_num (page_num);                             
  a:= page_num;
  insert into page_num values(global.session_id,a);
  commit;                                                                                                                       
  return (TRUE);                                                                
end;   

global.session_id comes from a package variable you have previously created in 
order to get the session id. 

The package specification and body is as follows:
PACKAGE global IS
        session_id number(10) ;
END;

PACKAGE BODY global IS
begin
select  sid
into    session_id
from    v$session
where   audsid = userenv('sessionid') ;
END;
                                                                  
In the format trigger of the page_num field write the following code in order to    
retrieve the total pages from the database, compare it with the current page     
and print it if current page is equal to the last page:                                

function page_numFormatTrigger return boolean is                                   
  this_page number;                                                             
  a number;                                                                     
  b number;                                                                     
begin                                                                           
  srw.get_page_num(this_page);                                                  
  a := this_page;
  select max(page_num) into b from page_num 
  where session_id = global.session_id;                                                               
  if a = b then                                                                 
    return(TRUE);                                                              
  else                                                                          
    return(FALSE);                                                               
  end if;                                                                       
end;

Finally delete the records in the page_num table after the report ends 
in the After Report Trigger:
function AfterReport return boolean is
begin
  srw.do_sql('delete from page_num where session_id = ' || to_char(global.session_id));
  srw.do_sql('commit');
 return (TRUE); 
end;


ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 6
Registrado em: Sex, 07 Jan 2005 9:09 am
Localização: Assis/SP

CARO DR. GORI


FIZ TESTES COM ESTE CÓDIGO E AINDA NUM CONSEGUI UMA SOLUÇÃO.... O GRANDE PROBLEMA É QUE TENHO QUE TRAZER NA 1ª PÁGINA DO RELATÓRIO O TOTAL_PAGES / 175.




RICARDO
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Com essa dica acima, você consegue descobrir o número de paginas total, aplicando o

Selecionar tudo

select max(page_num) into b from page_num
  where session_id = global.session_id;
Pra colocar esse valor na pagina inicial, basta você colocar esse código acima dentro de um bloco PL/SQL de um FIELD qualquer E depois faz assim pra mostrar o valor de b no campo:

Selecionar tudo

srw.set_field(0, b);
ou seja, vada vez que o field aparecer na tela, ele vai buscar o MAX e mostrar no campo!

Tenta isso!
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 6
Registrado em: Sex, 07 Jan 2005 9:09 am
Localização: Assis/SP

CONSEGUI CHEGAR EM UMA SOLUÇÃO......


SÓ QUE TIVE QUE FAZER VÁRIAS ALTERAÇÕES NESTE CÓDIGO...
MUITO OBRIGADO PELA DICA... :!: :!: :!:

:D



RICARDO
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Bom, se não for incomodo, tem como você colocar aí o que você fez?
(tipo, daí fica a dica pra mais alguém)

valeu
Avatar do usuário
Toad
Rank: DBA Pleno
Rank: DBA Pleno
Mensagens: 253
Registrado em: Sex, 18 Nov 2005 2:14 pm
Localização: Seattle, WA
Contato:
Matheus Gonçalves
matheus.dev
twitter.com/developer__c

Mas dr_gori, apliquei esse exemplo, ele até retorna o valor correto, mas somente na última página. Eu preciso que esse valor seja mostrado em todas as páginas. Só que, quando ele inseriu o último valor na tabela (o da efetiva última página), ele já "criou" a página. Como fazer para que o valor da última página apareça em todas elas? Seria possível? Eu to me matando aqui e não chego a lugar nenhum.
Queria algo assim:

Página 1, exibe: 01/175
Página 2, exibe: 02/175
Página 3, exibe: 03/175

Lembrando que esse valor hipotético 175 eu consigo com alguns cálculos que envolvem o processo anterior ( insert into page_num values(global.session_id,a); ), portanto não posso usar &Total_Logical_Pages simplesmente.

Há algo que possa ser feito?
Avatar do usuário
passageiromr
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 7
Registrado em: Ter, 24 Out 2006 10:15 am
Localização: Santa Cruz do Rio Pardo
Contato:

Bom dia, a dica de pegar o número da ultima pagina, só que eu precisava passar esse número por extenso em um livro fiscal que estou fazendo, desde já obrigado.

atenciosamente Eli.
Avatar do usuário
Toad
Rank: DBA Pleno
Rank: DBA Pleno
Mensagens: 253
Registrado em: Sex, 18 Nov 2005 2:14 pm
Localização: Seattle, WA
Contato:
Matheus Gonçalves
matheus.dev
twitter.com/developer__c

Rafael.Steil
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Mensagens: 10
Registrado em: Seg, 09 Fev 2009 3:12 pm
Localização: Sapiranga

estou com o mesmo problema do ricardo alguém pode me ajudar , com obter o numero total de páginas na primeira página alterando a página inicial?
JOPA
Rank: Programador Sênior
Rank: Programador Sênior
Mensagens: 58
Registrado em: Sex, 30 Out 2009 9:52 am
Localização: Salvador - BA
Contato:
Atenciosamente,

João Paulo A. C. do Bomfim

"Deu certo? Deixa! Funcionou? Não mexa!"

Eu simplesmente consegui isso colocando 2 << Field >> em Body.

Dei um duplo-click no primeiro e, na guia Object, em Source > From: eu selecionei a opção << &Logical Page Number >> representando assim a Página Atual.

Já no segundo << Field >> eu fiz o mesmo procedimento, porém a opção selecionada foi << &Total Logical Pages >> representando o Total de Páginas geradas.

Página 1, exibe: 1/5
Página 2, exibe: 2/5
Página 3, exibe: 3/5


SUCESSO!!!

Não foi necessária nenhuma programação e, isso foi feito no Reports 2.5 aqui na empresa.
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Sim, mas o workaround citado acima é pra manipular essa informação. Digamos que a primeira página tem que ficar com o número 20, por exemplo. (pra ser anexado em livros fiscais, etc, que tem que ter a numeração conforme o livro anterior)...
JOPA
Rank: Programador Sênior
Rank: Programador Sênior
Mensagens: 58
Registrado em: Sex, 30 Out 2009 9:52 am
Localização: Salvador - BA
Contato:
Atenciosamente,

João Paulo A. C. do Bomfim

"Deu certo? Deixa! Funcionou? Não mexa!"

Sem problema.

Acabo de testar aqui.

Dei um duplo click no << field >> da Página Atual e existe um botão titulado << Page Numbering... >>.
Ao dar um click nele abre-se uma nova janela onde tem uma opção << Start at: >> alterei de 1 para 20.

Fiz o mesmo procedimento para o segundo << field >>.

SUCESSO!

Página 1, exibe: 20/25
Página 2, exibe: 21/25
Página 3, exibe: 22/25

lembrando: Reports 2.5
ferik
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Mensagens: 1
Registrado em: Qui, 17 Dez 2009 12:03 pm
Localização: LINS - SP
Fabio Erik Goncalves

Ola Pessoal,

Encontrei um codigo enviado pelo dr. Gori como segue abaixo:

<<<<INICIO>>>>>>>>>
Doc ID: Note:130432.1
Subject: HOW TO PRINT THE REPORT TOTAL PAGES ONLY AT THE LAST PAGE
Type: BULLETIN
Status: PUBLISHED

Content Type: TEXT/X-HTML
Creation Date: 11-DEC-2000
Last Revision Date: 05-DEC-2001


SCOPE & APPLICATION
-------------------
This document gives a workaround to get the report total pages number
and use it, in the format trigger of a field so that will be printed
ONLY at the last page of the report.

The problem is that you cannot refer to a field with source total_pages
in the format trigger of another field without getting the error 'REP-730
The following bind variable is not defined', and also there is not any build
in function (like srw.get_page_num) to calculate the report total pages.



HOW TO PRINT REPORT TOTAL PAGES AT LAST PAGE
--------------------------------------------

1. Add in the report 2 fields : total_pages with source 'Total Pages' and
page_num with source 'Page Number'.
2. Create in the database a table page_num to store the number of pages of the
report. You can also add in this table another column to store the session id
in order to insert the page numbers with a unique identifier
for this report instance and be able to use this technique for multiple reports.
The description of the table page_num will be:
Name Type
------------------------------- ----
SESSION_ID NUMBER(10)
PAGE_NUM NUMBER(10)

(You can also use a local package variable to store the page number instead of
inserting it in a database table).

In the format trigger of the field total_pages write the following code in order
to get the total pages of the report and insert this number in a table:

Selecionar tudo

function total_pagesFormatTrigger return boolean is                            
  page_num number;                                                              
  a number(3);                                                                  
begin                                                                            
  srw.get_page_num (page_num);                              
  a:= page_num; 
  insert into page_num values(global.session_id,a); 
  commit;                                                                                                                        
  return (TRUE);                                                                
end;   


global.session_id comes from a package variable you have previously created in
order to get the session id.

The package specification and body is as follows:

Selecionar tudo

PACKAGE global IS 
        session_id number(10) ; 
END; 

PACKAGE BODY global IS 
begin 
select  sid 
into    session_id 
from    v$session 
where   audsid = userenv('sessionid') ; 
END; 

In the format trigger of the page_num field write the following code in order to
retrieve the total pages from the database, compare it with the current page
and print it if current page is equal to the last page:

Selecionar tudo

function page_numFormatTrigger return boolean is                                    
  this_page number;                                                              
  a number;                                                                      
  b number;                                                                      
begin                                                                            
  srw.get_page_num(this_page);                                                  
  a := this_page; 
  select max(page_num) into b from page_num 
  where session_id = global.session_id;                                                                
  if a = b then                                                                  
    return(TRUE);                                                              
  else                                                                          
    return(FALSE);                                                                
  end if;                                                                        
end; 
Finally delete the records in the page_num table after the report ends
in the After Report Trigger:

Selecionar tudo

function AfterReport return boolean is 
begin 
  srw.do_sql('delete from page_num where session_id = ' || to_char(global.session_id)); 
  srw.do_sql('commit'); 
 return (TRUE); 
end;
<<<<FIM>>>>>>>>>

porem pelo que estou percebendo a trigger do field page_num esta sendo executado antes da trigger do field total_pages, ou seja quando pego o select max(page_num) obtenho como retorn null, sera que esse problema esta relacionado com hierarquia de execucao? tem como manipular isso, sera que alguém sabe o que estou fazendo errado?

desde já agradeco a atencao.

abraco
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 10 visitantes