11-08-2005 1:40 PM
Hi
I can find the current page number using sy-pagno. But how do i find total pages that are there. Like i want to display "Page number 1 of 8" at the bottom of every page.
11-08-2005 2:18 PM
Thanks. But one more question. I am printing the page number in the End-Of-Page Event. Say suppose the last page has got just 2 lines. Then in this case the End-of-page is not getting fired and page number is not printed for last page alone. Any solution.
11-08-2005 1:51 PM
Hi,
If you know exactly the number of lines per page you can find the total pages dividing the total lines by the lines per page. I don't know a better way. I'm sorry.
Hope it helps.
Regards,
Mireia
11-08-2005 1:56 PM
Here is some sample code.
report zrich_0004
line-size 80
line-count 65
no standard page heading.
data: imara type table of mara with header line.
selection-screen begin of block b1 with frame title text-001 .
parameters: p_check type c.
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
top-of-page.
perform top_of_page.
************************************************************************
* FORM GET_DATA
************************************************************************
form get_data.
select * into corresponding fields of table imara
from mara up to 300 rows.
endform.
************************************************************************
* FORM WRITE_REPORT
************************************************************************
form write_report.
data: xpage(4) type c.
loop at imara.
write:/ imara-matnr.
endloop.
write sy-pagno to xpage left-justified.
do sy-pagno times.
read line 1 of page sy-index.
replace '****' with xpage into sy-lisel.
modify current line.
enddo.
endform.
************************************************************************
* Form top_of_page
************************************************************************
form top_of_page.
write:/32 'Test Program',
at 62 'Page:', at 67 sy-pagno, 'of', '****'.
endform.
Regards,
Rich Heilman
11-08-2005 2:18 PM
Thanks. But one more question. I am printing the page number in the End-Of-Page Event. Say suppose the last page has got just 2 lines. Then in this case the End-of-page is not getting fired and page number is not printed for last page alone. Any solution.
11-08-2005 2:44 PM
Hi,
You can skip n lines so that you can reach the end of line and therefore the end-of-page event is fired. If you can calculate the lines, that would solve your problem.
Hope this is helpful.
Regards,
Mireia
11-08-2005 2:48 PM
Ok, I have modified my program a bit. Pay close attention to the code in BOLD.
report zrich_0004
line-size 80
<b>line-count 65(1)</b>
no standard page heading.
data: imara type table of mara with header line.
selection-screen begin of block b1 with frame title text-001 .
parameters: p_check type c.
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
<b>end-of-page.
perform end_of_page.</b>
************************************************************************
* FORM GET_DATA
************************************************************************
form get_data.
select * into corresponding fields of table imara
from mara up to 315 rows.
endform.
************************************************************************
* FORM WRITE_REPORT
************************************************************************
form write_report.
data: xpage(4) type c.
<b> data: lines_left type i.</b>
loop at imara.
write:/ imara-matnr.
<b> at last.
if sy-linno < 64.
lines_left = ( sy-linct - sy-linno ) - 1.
skip lines_left.
sy-pagno = sy-pagno - 1.
elseif sy-linno = 64.
skip 1.
sy-pagno = sy-pagno - 1.
endif.
endat.</b>
endloop.
write sy-pagno to xpage left-justified.
do sy-pagno times.
read line 65 of page sy-index.
replace '****' with xpage into sy-lisel.
modify current line.
enddo.
endform.
************************************************************************
* Form end_of_page
************************************************************************
<b>form end_of_page.
write:/32 'Test Program',
at 62 'Page:', at 67 sy-pagno, 'of', '****'.
endform.</b>
Regards,
Rich Heilman
11-08-2005 2:59 PM
Thankyou everyone.Special Thanks to Sailaja and Heilman.
11-08-2005 2:38 PM
Hi Shanmugham,
We can get END-OF-PAGE triggered by taking the sy-linct, sy-linno count. Following is the sample code how to trigger it. In similar way, you can get end-of-page triggered by keeping track of SY-LINCT, SY-LINNO.
Report zdemo1 line count 20(1).
Start-of-selection.
Data: m type i.
Write: / this is first line.
Do 5 times.
Write: / the number is, sy-index.
Enddo.
M = sy-linct, sy-linno 1.
Skip x.
End-of-page.
Write: / page end.
The output of above example is as follows :
This is first line.
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
After skipping 10 lines
Page end
In this case, with all write statement, you dont reach to the end of page. After all write statement, m is calculated in this case:
M = 20 8 1, So m is 12. And 11 lines are skipped after write statement and end of page is reached. (In this case you have 6 write statement so 6 lines + 1 line for page number and 1 horizontal line which is displayed for any list. So cursor is on 8th line and is subtracted from total line count i.e, 20.)
Regards,
Sailaja.
Dont forget to reward points if answer is helpful to you.
12-05-2005 8:56 AM
I want to get current secondary line data by using sy-lisel.But following codde not work .sy-lisel just includes previous first basis list line data. Why?
START-OF-SELECTION.
PERFORM GF_GET_TCDATA.
END-OF-SELECTION.
SET PF-STATUS 'STATUS_100'.
PERFORM PRINT_LIST.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SET PF-STATUS 'STATUS_100'.
PERFORM PRINT_DETAIL.
PERFORM UPDATE_PAGTOTAL.
ENDIF.
......
FORM UPDATE_PAGTOTAL.
DATA: xpage(4) TYPE c.
WRITE sy-pagno TO xpage LEFT-JUSTIFIED.
DO sy-pagno TIMES.
READ LINE 6 OF PAGE sy-index.
REPLACE '***' WITH xpage INTO sy-lisel.
MODIFY CURRENT LINE.
ENDDO.
ENDFORM.
thanks.