cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop sapscript to change to new page

Former Member
0 Kudos

Hallo experts,

In a sap script form I have written code to chage to next page. For this I have 74 lines for a page and I count lines when counted lines are more then 74 then it changes to next page. But sometime the counter is less then 74 and it changes the page. This thing I dont understand. Is there any command that it stops this automatically change to new page?????

Note I have also used protect.

I have counted lines with Funciton module  READ_FORM_LINES. Here is the code Is there any better way to count lines in sapscript.

Please help I have wasted three days to solve the problem.

CALL FUNCTION 'READ_FORM_ELEMENTS'

   EXPORTING

     form           = print_co-forml

     language       = sy-langu

*   STATUS         = ' '

    TABLES

      elements       = lt_line

   EXCEPTIONS

     form           = 1

     unopened       = 2

     OTHERS         = 3 .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.


  LOOP AT lt_line INTO ls_line.

    REFRESH lt_tline.

    CLEAR ls_tline.

    CALL FUNCTION 'READ_FORM_LINES'

      EXPORTING

        element  = ls_line-element

        form     = print_co-forml

        language = sy-langu

        window   = ls_line-window

      TABLES

        lines    = lt_tline

      EXCEPTIONS

        element  = 1

        form     = 2

        unopened = 3

        OTHERS   = 4.

    IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.


    LOOP AT lt_tline INTO ls_tline.

      IF ls_tline-tdformat CA '=(/:*'.

        CONTINUE.

      ELSE.

        ADD 1 TO line_count.

        IF ls_line-window NE 'MAIN'.

          ADD 1 TO gv_lines_printed.

        ENDIF.

      ENDIF.

    ENDLOOP.

  ENDLOOP.

Thanks

best regards

waseem

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member213851
Active Contributor
0 Kudos

Hi Waseem,

As you count Number of lines to go to the Next page ,try below option to go to Next page if No. of lines are greater than 74 :

Add below check in main window of script :

if &gv_pagecount& GT '74' .

/: NEW-PAGE .

endif

Best Regards,

Sachin

former_member209818
Active Contributor
0 Kudos

Hi Waseem,

As you are using Protect - Endprotect, its causing the issue. There must be some "Include Text" of something which you are trying to print inside the Protect endprotect and Script is trying to print that in a single page. But if scripts finds that there is no sufficient space to print on current page it will trigger new page.

Inside the loop statement (    LOOP AT lt_tline INTO ls_tline.)... you are skipping the Command lines. but it may happen that using command line, some Include text is getting printed and you are not counting.. hope this may help you to tweak your logic