Skip to Content
author's profile photo Former Member
Former Member

OOPS ALV - SY-PAGNO and SY-CPAGE equal to 0

Hi ABAPers,

I need some help.

I am displaying an ALV Grid using OOPS concept using Docking containers and Easy Splitter and Set_Table_For_First_Display method.

In the top container, I am displaying my TOP-OF-PAGE but when I try to display the page number, it is coming as 0.

I checked in debug and found that both sy-pagno and sy-cpage are returning 0.

It seems like it is not understanding the end of the page to populate it.

I would like to know how I can overcome this problem.

Is there a method in which I can specify the number of lines in the grid or the container or somewhere or is there some other method...??

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Sep 06, 2013 at 09:27 AM


    I just did a small test.

    It seems that sy-pagno work only when I am submiting the report to batch and a spool is generated

    (which make a sense).



    My code:

    * registers the event handlers

    SET HANDLER ob_event_receiver_1->toolbar







    * ob_event_receiver_1->delayed_callback

    * ob_event_receiver_1->delayed_changed_sel_callback


    ob_event_receiver_1->after_user_command FOR ob_gui_alv_grid_1 .

    And in the class:

    METHODS: print_top_of_page

    FOR EVENT print_top_of_page OF cl_gui_alv_grid

    IMPORTING table_index .

    METHOD print_top_of_page .

    WRITE: / sy-datum , sy-uzeit , sy-uname , 'Page:' , sy-pagno .

    WRITE: / sy-title .

    WRITE: / .


    Add a comment
    10|10000 characters needed characters exceeded

    • Hi ,

      That is why I did the test.

      When I switch to list display SY-PAGNO remain equal to 1 .


      My full method code:

      METHOD print_top_of_page .

      DATA: it_name_1 TYPE TABLE OF string .

      FIELD-SYMBOLS: <st_name_1> LIKE LINE OF it_name_1 .

      DATA: it_name_2 TYPE TABLE OF string .

      FIELD-SYMBOLS: <st_name_2> LIKE LINE OF it_name_2 .

      DATA: rg_fieldname TYPE RANGE OF fieldname ,

      ra_fieldname LIKE LINE OF rg_fieldname .

      IF sy-pagno EQ 1 .

      * APPEND:' ' TO it_name_1 .

      ra_fieldname-sign = 'I' .

      ra_fieldname-option = 'EQ' .

      LOOP AT it_name_1 ASSIGNING <st_name_1> .

      SPLIT <st_name_1> AT space INTO TABLE it_name_2 .

      LOOP AT it_name_2 ASSIGNING <st_name_2> .

      ra_fieldname-low = <st_name_2> .

      TRANSLATE ra_fieldname-low TO UPPER CASE.

      ra_fieldname-sign = 'I'.

      ra_fieldname-option = 'CP'.

      APPEND ra_fieldname TO rg_fieldname .

      ENDLOOP .

      ENDLOOP .

      DATA: program TYPE rsvar-report .

      DATA: it_rsparams TYPE rsparams_tt .

      DATA: it_yca_tab_sav_p TYPE TABLE OF yca_tab_sav_p .

      FIELD-SYMBOLS: <st_yca_tab_sav_p> LIKE LINE OF it_yca_tab_sav_p .

      program = sy-cprog .

      IF p_exname IS NOT INITIAL .

      * Restore the field catalog .

      SELECT * INTO TABLE it_yca_tab_sav_p

      FROM yca_tab_sav_p


      exname EQ p_exname .

      LOOP AT it_yca_tab_sav_p ASSIGNING <st_yca_tab_sav_p> .

      APPEND <st_yca_tab_sav_p>-rspa TO it_rsparams .

      ENDLOOP .

      ENDIF .

      IF it_rsparams IS INITIAL .



      curr_report = program


      selection_table = it_rsparams


      not_found = 1

      no_report = 2

      OTHERS = 3.

      ENDIF .

      DELETE it_rsparams

      WHERE sign EQ space AND option EQ space AND low EQ space .

      DELETE it_rsparams


      selname NOT IN rg_fieldname .

      ENDIF .

      WRITE: / sy-datum , sy-uzeit , sy-uname , 'Page:' , sy-pagno .

      WRITE: / sy-title .

      WRITE: / .

      IF sy-pagno = 1 .



      report = program

      seltext = abap_true

      newpage = abap_true


      sel_tab = it_rsparams


      sel_tab_empty = 1

      OTHERS = 2.

      ENDIF .

      ENDMETHOD . "print_top_of_page

  • Posted on Sep 06, 2013 at 08:26 AM

    You will not any information of those system fields out of actual list processing.

    Else the number of displayed lines can be determined with the actual internal table size and methods like get_filtered_entries (return list of filtered index). But that result is dynamic if you don't disable filter option in ALV toolbar, so you have to handle events like after_refresh (and prevent infinite loop there)



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 06, 2013 at 08:54 AM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.