Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Print page numbers

Former Member
0 Kudos

Hello,

I'd like to print out the page numbers of my alv. I tried a lot of coding. I thought the attached coding is working but it didnt. there was no output at printing. When i set a breakpoint into the form end_of_page the program jumps if I push the print button in this code, but no output.

if I try top_of_page then it works. but then I have the problem that I have the information also at screen output. I need this information only at printing!!!

Maybe there is another solution. I dont believe that there is no solution in alv to print out the page number.

thanks for help

Manuel Nagler

FORM build_print_params.

gd_prntparams-reserve_lines = '3'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

ENDFORM. " BUILD_PRINT_PARAMS

form END_OF_PAGE.

write: sy-uline(50).

skip.

write:/40 'Page:', sy-pagno .

endform.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

ALV event END_OF_PAGE is processed during printing. During list output, to screen, you won't be able to see it getting processed. If you place a break-point in your END_OF_PAGE routine and print the report to spool or printer, you will see the routine being processed.

What you have done so far is perfectly fine. You need one more thing though. Try the following code:


* assuming your list has 60 lines, you have reserved 3
DATA: prev_linno TYPE sy-linno.

FORM END_OF_PAGE.

  prev_linnno = sy-linno.
  sy-linno = 58.

  WRITE: sy-uline(50).
  SKIP.
  WRITE:/40 'Page:', sy-pagno .

  sy-linno = prev_linno.

ENDFORM. 

See if it helps.

Regards

6 REPLIES 6

Former Member
0 Kudos

Hi,

ALV event END_OF_PAGE is processed during printing. During list output, to screen, you won't be able to see it getting processed. If you place a break-point in your END_OF_PAGE routine and print the report to spool or printer, you will see the routine being processed.

What you have done so far is perfectly fine. You need one more thing though. Try the following code:


* assuming your list has 60 lines, you have reserved 3
DATA: prev_linno TYPE sy-linno.

FORM END_OF_PAGE.

  prev_linnno = sy-linno.
  sy-linno = 58.

  WRITE: sy-uline(50).
  SKIP.
  WRITE:/40 'Page:', sy-pagno .

  sy-linno = prev_linno.

ENDFORM. 

See if it helps.

Regards

0 Kudos

Hello,

your trick is really nice but unfortunately it doesnt work right:

with this code:

FORM end_of_page.

break aii-nag.

prev_linno = sy-linno.

sy-linno = 63.

  • WRITE: sy-uline(50).

SKIP 2.

WRITE:/40 'Page:', sy-pagno .

sy-linno = prev_linno.

ENDFORM.

there a short dump comes!!!

Possible reasons:

- The number of lines per page is zero, although output is not

to the screen.

Current contents of SY-LINCT: 65.

- The system field SY-LINNO was changed illegally.

Current contents of SY-LINNO: 66.

with this code:

FORM end_of_page.

break aii-nag.

prev_linno = sy-linno.

sy-linno = 63.

  • WRITE: sy-uline(50).

WRITE:/40 'Page:', sy-pagno .

SKIP 2.

sy-linno = prev_linno.

ENDFORM.

no short dump comes, but the page number is in the last line of my alv grid.

thanks for answer

manuel

0 Kudos

Hi,

What version of SAP are you working on? I tried that on a 4.6c and it worked ok.

BTW, have you tried commenting the line containing SKIP 2?

Regards

Message was edited by: Shehryar Khan

0 Kudos

Hello,

I also work on 4.6c. When I comment skip 2 there is no short dump, but the page number is within the last line of my result!!! Do you know any solution?

kind regards

manuel nagler

0 Kudos

Hello Shehryar,

now it works!!! With this code!! Thanks for help!

FORM end_of_page.

prev_linno = sy-linno.

sy-linno = 64.

SKIP.

WRITE:/40 'Page:', sy-pagno .

SKIP.

sy-linno = prev_linno.

ENDFORM.

Kind Regards

Manuel Nagler

0 Kudos

> Hello Shehryar,

>

> now it works!!! With this code!! Thanks for help!

>

> FORM end_of_page.

> prev_linno = sy-linno.

> sy-linno = 64.

> SKIP.

> WRITE:/40 'Page:', sy-pagno .

> SKIP.

> sy-linno = prev_linno.

> ENDFORM.

>

> Kind Regards

> Manuel Nagler

Where do you need to insert this code?