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: 

Page No. in ALV output

Former Member
0 Kudos

Hi,

How can i have page number like

Page X of Y format in ALV output

Thanxs in advance

sree

8 REPLIES 8

Former Member
0 Kudos

Hi,

Check this thread

Thanks & Regards,

Judith.

former_member185932
Participant
0 Kudos

Unfortunately I couldn't find an easy way of adding 'Page X of Y' to an ALV report, certainly nothing as easy as with Smartforms/SAPScript.

To get the 'Y' part of the page number I counted the number of lines in the internal table being output, took into consideration any totalling that would be applied and then divided the total number of lines by the lines per page.

*   Determine the number of full pages and the remaining lines.
    w_total_pages = w_loc_lines div w_loc_recs_per_page.
    w_loc_recs_remaining = w_loc_lines mod w_loc_recs_per_page.
    if w_loc_recs_remaining > 0.
      add 1 to w_total_pages.
    endif.
*   Add the page number to the top-of-page.
    wa_loc_commentary-typ = 'H'.
    w_loc_pagno_char = sy-pagno.
    w_loc_pagno_total = w_total_pages.
    concatenate text-t02 w_loc_pagno_char text-t03 w_loc_pagno_total
                into wa_loc_commentary-info separated by space.
    condense wa_loc_commentary-info.
    append wa_loc_commentary to i_loc_commentary.
  endif.
* Populate the Page header.
  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary = i_loc_commentary.

0 Kudos

Hi Bourne,

Thank you very much.

I was on leave for all these days. and also i did not tried it..

Please give me a day. i wil impliment it and come back to you.

regards

sree

0 Kudos

Hi jonathan,

i did not get the correct output,

the output is

PAGE NO. 0 of 8,

PAGE NO. 0 of 8,

PAGE NO. 0 of 8,...................

hete it is always 0.

can you please tell me where iam making the mistake.

here is the code.

<b>data: w_pagno_char(3),

w_total_pages(3),

w_recs_remaining(2) type c.

w_pagno_char = sy-pagno.

describe table tbl_final lines w_count.

w_total_pages = w_count div sy-linct.

w_recs_remaining = w_count mod sy-linct.

if w_recs_remaining > 0.

add 1 to w_total_pages.

endif.

  • Heading

st_alv_line-typ = c_head.

st_alv_line-info = text-023.

append st_alv_line to tbl_alv_listheader.

clear st_alv_line.</b>

Thanks in advace.

sree

0 Kudos

When you populate field <b>st_alv_line-info</b> in your code you are passing text-023. However, in the example that I provided the <b>info</b> field is populated as follows:

concatenate text-t02 w_loc_pagno_char text-t03 w_loc_pagno_total
                into wa_loc_commentary-info separated by space.

In this code text-t02 is 'Page:', <b>w_loc_pagno_char</b> contains the current page number, text-t03 is 'to', then <b>w_loc_pagno_total</b> is the total number of pages which will populate the <b>info</b> field with, for example, <i>Page 1 or 10</i>.

Let me know if you need any further help.

Regards,

JB

0 Kudos

Hi JB,

Iam sorry,

I pasted wrong code. the corrected code

  • page number

st_alv_line-typ = c_head.

concatenate 'page no.' w_pagno_char 'of' w_total_pages into

st_alv_line-info separated by space.

condense st_alv_line-info.

append st_alv_line to tbl_alv_listheader.

clear st_alv_line.

Thanx & regards

0 Kudos

The only thing I can see is that you may not have defined the variable <b>w_pagno_char</b> prior to the code you have pasted as follows:

w_pagno_char = sy-pagno.

If you have defined this variable then could you please post your entire subroutine and I will take a look at it.

Thanks and regards,

JB

0 Kudos

Hi following is my code and iam unable to print like 1 of 8 and 2 of 8

actually its not incrementing the first variable.

what to do

&----


*& Form XTOP_OF_PAGE

&----


  • Header Of Top Of Page

----


FORM xtop_of_page. "#EC CALLED

DATA:it_list_commentary TYPE STANDARD TABLE OF slis_listheader,

wa_list_commentary TYPE slis_listheader,

v_count type i,

v_total,

v_remaining.

sy-linct = 15.

describe table i_final lines v_count.

v_total = v_count div sy-linct.

v_remaining = v_count mod sy-linct.

if v_remaining > 0.

add 1 to v_total.

endif.

wa_list_commentary-typ = 'H'.

wa_list_commentary-info = v_total.

APPEND wa_list_commentary TO it_list_commentary.

WRITE:/ v_name1,210 sy-datum.

WRITE:/ v_name2,150 sy-pagno.

WRITE:/ v_stras.

WRITE:/ v_pstlz,v_ort01.

WRITE:/100 text-051.

IF NOT s_period-high IS INITIAL.

WRITE:/100 text-053,s_period-low.

ENDIF.

IF NOT s_period-high IS INITIAL.

WRITE: text-054,s_period-high.

ENDIF.

WRITE:/ text-052,v_agreement_number.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_list_commentary

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "XTOP_OF_PAGE